科学Fortran编译错误 [英] Scientific Fortran Compile Error

查看:151
本文介绍了科学Fortran编译错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究科学建模程序,并且还没有让我的程序能够编译。我没有触及我的教授坚持以前工作的代码,只有makefile。经过多次尝试后,我得到的最远处是这个错误:

 第1112行的错误:xxmf声明错误:可调整尺寸非参数
upcase:
intrpl:
splin:
mtrnpr:

我的教授坚持认为这只是一个编译问题,应该有一些涉及全局变量的选项,我可以使用它来解决这个问题。我发现的最接近的是使用选项

  -Mipa = safeall 

在makefile中,但我不确定是否将它放在正确的位置,或者因为我仍然得到相同的错误。

解决方案

Oof - 听起来就像你有一个旧代码,可以和你的主管特定版本的古代f77编译器一起工作,但是一段时间你会慢慢地让它感到心痛,因为标准编译器会做正确的事情。

可调整数组是事物像这样:

$ $ p $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $

- 也就是说,按照您在C. Fortran90及更高版本中的方式或多或少地传递数组允许您使用假定形状的数组

 < code $子程序mysub90(a)
实际a(:)
n = size(x,1)

这是一个更清洁的方式,因为编译器确保正确传递数组的大小。



所以这听起来像是你的监督者的代码正在使用这种类型的结构,而不是是子例程中的参数,可能是在运行时创建特定大小数组的方式。标准的Fortran77从来没有允许这样做,但有几个编译器作为扩展。幸运的是,您现在可以使用可分配数组作为执行此操作的标准方式,因此我建议只更改变量现在给你一个可分配数组的麻烦。



顺便说一句,有很多静态代码分析工具可以让你主动发现像这样的问题并跟踪他们失望了。 了解是一款优秀的商业版本,具有大约2周的评估许可证,将会发现许多问题。 Forcheck 虽然不像用户友好,但是非常全面。使用类似这样的工具拖动你的主管代码踢球和尖叫到2010年将是一个噱头,但这将是一个很好的投资你的时间。另一个很好的工具是eclipse + photran ,但不幸的是,已经主要假设你有很好的fortran90代码 - 它会是一段时间后,你可以使用它。



(在任何人开始对fortran做出尖锐的评论之前 - 是的,是的,这里有很多糟糕的fortran代码,但现在对于fortran来说,这不是唯一的,是。)


I'm working on scientific modelling program and have yet to get my program to even compile. I haven't touched the code which my professor insists previously worked, only the makefile. After many attempts, the furthest I've gotten was this error:

Error on line 1112: Declaration error for xxmf: adjustable dimension on non-argument
   upcase:
   intrpl:
   splin:
   mtrnpr:

My Professor insists that it's merely a compiling problem and that there should be some option involving global variables that I can use that'll fix this. The closest I've found is using the option

 -Mipa=safeall

in the makefile, but I'm not sure if I'm putting it in the right place or if it made a difference since I still get the same error.

解决方案

Oof -- Sounds like you have an old code which works fine with your supervisor's particular version of an ancient f77 compiler, but is going to cause heartache for you for a while as you slowly bring it up to standard so that standards-compilant compilers will do the right thing.

Adjustable arrays are things like this:

subroutine mysub(a,n)
integer n
real a(n)

-- which is to say, passing arrays more or less the way you do in C. Fortran90 and onwards allows you to use assumed-shape arrays

subroutine mysub90(a)
real a(:)
n=size(x,1)

which is a lot cleaner, as the compiler is ensuring the correct size of the array is being passed.

So it sounds like your supervisor's code is using this sort of construct in something that isn't an argument in a subroutine, presumably as a way of creating arrays of a particular size at runtime. Standard Fortran77 never allowed that, but several compilers did as extensions. Luckily, you can use allocatable arrays now as a standard way of doing this, so I'd suggest just changing the variable giving you grief now to an allocatable array.

Incidentally, there are a lot of static code analysis tools out there that will allow you to proactively find problems like this and track them down. Understand is a good commercial one with a ~2 week evaluation license that will find a lot of problems. Forcheck, though not nearly as user friendly, is very thorough. Using tools like these to drag your supervisors code kicking and screaming into the 2010s will be a bit of a slog, but it'll be an excellent investment of your time. Another good set of tools is eclipse + photran, but unfortunately that already mostly assumes you have nice fortran90 code -- it'll be a while before you can be using that.

(And before anyone starts making snarky comments about fortran -- yes, yes, there's a lot of old crappy fortran code out there, but that's hardly unique to fortran now, is it.)

这篇关于科学Fortran编译错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆