遇到了fortran77编译错误,自己上网查了很长时间,算是初步解决了数组维数的问题,不过还有错误,需要进一步解决。
下面列出具体问题和解决办法。
原有的f77程序,在我的虚拟机ubuntu系统下编译出错,上面是部分makefile代码,我将FFLAGS路径修改后还是有问题,具体问题如下:
l****@ubuntu:~/Downloads/soft3$ make
f77 -O2 -w -I/usr/lib/openmpi/include -I/usr/lib/openmpi/lib -c -o e2d3ts.o e2d3ts.f
e2d3ts:
Error on line 138: Declaration error for t0: adjustable dimension on non-argument
Error on line 138: wr_ardecls: nonconstant array size
Error on line 138: wr_ardecls: nonconstant array size
/usr/bin/f77: aborting compilation
make: *** [e2d3ts.o] Error 25
感觉应该是可调数组维数的问题,提示错误的源程序如下:
c
subroutine e2d3ts(nconv,redf,linear_niter,
1 iter_method_sles,npreconditioner)
implicit real*8 (a-h,o-z)
include "mpi2d3t.i"
include "snesf.h"
c
dimension t0(n,0:imcell+1,0:jmcell+1)
dimension linear_niter(1)
主要的原因应该是上面源代码数组定义部分不是标准f77格式,所以原来的f77不能完全编译代码,解决的办法是安装g77,方法如下:
过去的不少程序都是用g77编译的,在新的Ubuntu 10.04 Linux系统下,g77已经被gfortran完全替代了。然而,问题是gfortran并不能完全兼容过去的g77,完成修改程序似乎也是个不大可能的任务。
Ubuntu 10.04,可以自动安装新版gcc(但是已经没有了g77)。用如下方法安装g77的。
1. 在/etc/apt/source.list中最后头添加如下源(以root的身份,或用 sudo):
- deb http://hu.archive.Ubuntu.com/ubuntu/ hardy universe
- deb-src http://hu.archive.Ubuntu.com/ubuntu/ hardy universe
- deb http://hu.archive.Ubuntu.com/ubuntu/ hardy-updates universe
- deb-src http://hu.archive.Ubuntu.com/ubuntu/ hardy-updates universe
2. 安装aptitude
- sudo apt-get install aptitude
3. 然后执行如下:
- sudo aptitude update
- sudo aptitude install g77
4. 现在用g77就可编译我原来的程序了。