| 查看: 1091 | 回复: 2 | |||
mplanck至尊木虫 (职业作家)
之上又是啥子虫虫?
|
[交流]
【求助】fortran 程序windows 下编译正确,而linux下出错 已有2人参与
|
|
如题,一个cpc上下的程序,windows 下编译得到结果正确, 放在linux下就出问题: 用f77, fort77 编译,在两个sub模块结尾提示 Error on line 1679: Declaration error for rvv: adjustable dimension on non- argument Error on line 1679: wr_ardecls: nonconstant array size 但我的数组没问题呀 再用gfortran,f95编译,编译通过,但结果不对 再用ifort编译,编译也通过,又出来一个不对的新结果 真搞不懂为什么这样? 麻烦虫虫门指点下,谢谢! 附出错部分代码: 其中报错的一个sub模块代码如下,1679行对应于最后一行,即‘end’所在行;再就是 整个代码中没有找到wr_ardecls这个东西,不知道咋搞的。非常感谢! c------------------------------------------------------------------------ subroutine dcludcmp(a,n,np,indx,d,ierror) c this is the double complex version of the homonyme sbr. from Numerical c Recipes implicit double complex(a-h,o-q,s-z) implicit double precision (r) parameter (tiny=(1.0d-30,1.0d-30)) dimension a(np,np),indx(n),rvv(n) d=dcmplx(1.d0,0.d0) ierror=0 do 12 i=1,n raamax=0.d0 do 11 j=1,n if (cdabs(a(i,j)).gt.raamax) raamax=cdabs(a(i,j)) 11 continue if (raamax.eq.0.d0)then write (*,*) 'singular matrix in dcludcmp' ierror=1 return endif rvv(i)=1.d0/raamax 12 continue do 19 j=1,n if (j.gt.1) then do 14 i=1,j-1 sum=a(i,j) if (i.gt.1)then do 13 k=1,i-1 sum=sum-a(i,k)*a(k,j) 13 continue a(i,j)=sum endif 14 continue endif raamax=0.d0 do 16 i=j,n sum=a(i,j) if (j.gt.1)then do 15 k=1,j-1 sum=sum-a(i,k)*a(k,j) 15 continue a(i,j)=sum endif rdum=rvv(i)*cdabs(sum) if (rdum.ge.raamax) then imax=i raamax=rdum endif 16 continue if (j.ne.imax)then do 17 k=1,n dum=a(imax,k) a(imax,k)=a(j,k) a(j,k)=dum 17 continue d=-d rvv(imax)=rvv(j) endif indx(j)=imax if(j.ne.n)then if(cdabs(a(j,j)).eq.0.d0) a(j,j)=tiny dum=1.d0/a(j,j) do 18 i=j+1,n a(i,j)=a(i,j)*dum 18 continue endif 19 continue if(cdabs(a(n,n)).eq.0.d0) a(n,n)=tiny return end c--------------------------------------------------------------------------- |
» 猜你喜欢
参与限项
已经有3人回复
假如你的研究生提出不合理要求
已经有7人回复
实验室接单子
已经有4人回复
全日制(定向)博士
已经有4人回复
对氯苯硼酸纯化
已经有3人回复
求助:我三月中下旬出站,青基依托单位怎么办?
已经有12人回复
不自信的我
已经有12人回复
所感
已经有4人回复
要不要辞职读博?
已经有7人回复
北核录用
已经有3人回复

snoopyzhao
至尊木虫 (职业作家)
- 程序强帖: 16
- 应助: 157 (高中生)
- 贵宾: 0.02
- 金币: 18844.7
- 红花: 29
- 帖子: 3803
- 在线: 1422.4小时
- 虫号: 183750
- 注册: 2006-02-13
- 专业: 污染生态化学
★ ★ ★
小木虫(金币+0.5):给个红包,谢谢回帖交流
余泽成(金币+2):辛苦了! 2010-07-17 10:46:06
小木虫(金币+0.5):给个红包,谢谢回帖交流
余泽成(金币+2):辛苦了! 2010-07-17 10:46:06
|
不要用 f2c 编译你的程序,用 gfortran 或其它正宗的 Fortran 编译器,呵呵 用第二个错误提示 google 一下,你会发现,你不是遇到这个错误的第一人,呵呵…… f2c does not support automatic arrays; g77 does, as do most other f77 compilers (and all f90+). 至于结果不同,最大的可能是一些 local variable 没有赋值,这在 Fortran,尤其是一些老的程序中是非常常见的。用 gfortran 编译时加上 -fno-automatic -finit-local-zero 之类的参数试试…… |
2楼2010-07-17 08:56:26
mplanck
至尊木虫 (职业作家)
之上又是啥子虫虫?
- 应助: 0 (幼儿园)
- 金币: 22899.2
- 散金: 5216
- 红花: 19
- 帖子: 3980
- 在线: 760.8小时
- 虫号: 468030
- 注册: 2007-11-27
- 性别: GG
- 专业: 原子和分子物理

3楼2010-07-17 11:27:26












回复此楼