回 帖 发 新 帖 刷新版面

主题:有个程序请教mltx老师

这个程序是一本参考书的源程序,不过是用fortran77编写的,现在用visual fortran编译,就出错,可是我一直就发觉不了错误的原因,请大师出来指点一二,谢谢!我已把源程序上传到http://upload.programfan.com/upfile/200505071357513.rar了

回复列表 (共6个回复)

沙发

是杆系结构静力分析计算程序,

板凳

编译错误都是警告错误,暂时可以忽略。

问题是在
SUBROUTINE ADDELM(A,S,LM,ND,NEQ,IUBW)
中,你用了aSa数组;可是,在这个子程序中,你并没有定义这个数组,也没从公共块传递这个数组。

这是一个致命错误。好像你改动过程序,把S改为aSa了。我只是猜测。

3 楼

你说的没错,我传上去的程序是我改动了一点的程序,我刚刚把最原始的原程序编译了一下,出现的是以下提示:

Compiling Fortran...
D:\FRAME2D.FOR
D:\FRAME2D.FOR(314) : Warning: Because of COMMON, the alignment of object is inconsistent with its type   [ASA]
      COMMON /EM/LM(6),ND,ASA(6,6),RF(6),SA(6,6)
--------------------------^
D:\FRAME2D.FOR(314) : Warning: Because of COMMON, the alignment of object is inconsistent with its type   [RF]
      COMMON /EM/LM(6),ND,ASA(6,6),RF(6),SA(6,6)
-----------------------------------^
D:\FRAME2D.FOR(314) : Warning: Because of COMMON, the alignment of object is inconsistent with its type   [SA]
      COMMON /EM/LM(6),ND,ASA(6,6),RF(6),SA(6,6)
-----------------------------------------^
D:\FRAME2D.FOR(315) : Warning: Because of COMMON, the alignment of object is inconsistent with its type   [SF]
     1   ,SF(6),T(3,3)
----------^
D:\FRAME2D.FOR(315) : Warning: Because of COMMON, the alignment of object is inconsistent with its type   [T]
     1   ,SF(6),T(3,3)
----------------^
D:\FRAME2D.FOR(472) : Warning: Because of COMMON, the alignment of object is inconsistent with its type   [ASA]
      COMMON /EM/ LM(6),ND,ASA(6,6),RF(6),SA(6,6),
---------------------------^
D:\FRAME2D.FOR(472) : Warning: Because of COMMON, the alignment of object is inconsistent with its type   [RF]
      COMMON /EM/ LM(6),ND,ASA(6,6),RF(6),SA(6,6),
------------------------------------^
D:\FRAME2D.FOR(472) : Warning: Because of COMMON, the alignment of object is inconsistent with its type   [SA]
      COMMON /EM/ LM(6),ND,ASA(6,6),RF(6),SA(6,6),
------------------------------------------^
D:\FRAME2D.FOR(473) : Warning: Because of COMMON, the alignment of object is inconsistent with its type   [SF]
     1     SF(6),T(3,3)
-----------^
D:\FRAME2D.FOR(473) : Warning: Because of COMMON, the alignment of object is inconsistent with its type   [T]
     1     SF(6),T(3,3)
-----------------^
D:\FRAME2D.FOR(682) : Warning: Because of COMMON, the alignment of object is inconsistent with its type   [ASA]
      COMMON /EM/LM(6),ND,ASA(6,6),RF(6),SA(6,6)
--------------------------^
D:\FRAME2D.FOR(682) : Warning: Because of COMMON, the alignment of object is inconsistent with its type   [RF]
      COMMON /EM/LM(6),ND,ASA(6,6),RF(6),SA(6,6)
-----------------------------------^
D:\FRAME2D.FOR(682) : Warning: Because of COMMON, the alignment of object is inconsistent with its type   [SA]
      COMMON /EM/LM(6),ND,ASA(6,6),RF(6),SA(6,6)
-----------------------------------------^
D:\FRAME2D.FOR(683) : Warning: Because of COMMON, the alignment of object is inconsistent with its type   [SF]
     1   ,SF(6),T(3,3)
----------^
D:\FRAME2D.FOR(683) : Warning: Because of COMMON, the alignment of object is inconsistent with its type   [T]
     1   ,SF(6),T(3,3)
----------------^

FRAME2D.OBJ - 0 error(s), 15 warning(s)

请问是哪有问题?

4 楼

这是老Fortran的规则。看你的公共语句:

COMMON /EM/LM(6),ND,ASA(6,6),RF(6),SA(6,6),SF(6),T(3,3)

根据程序的隐含规则,LM(6),ND一共是7个整型数,每个整型数4个字节,共28个字节,不是8字节的整倍数。紧跟着是双精度的ASA(6,6),每个数是8个字节,可是ASA(1,1)不能从8字节整倍数位置开始存储,这就是the alignment of object is inconsistent with its type 的意思。

对于警告错误,可以忽略,一般不致于影响执行结果。如果要改的话,有几种办法:

1)在公共语句中,把双精度数放在前边,整形数跟在后边;

2)在ASA()前插一个整型变量(哪怕是没用的),用来占用4个字节,以使得后面的双精度数可以从8字节整数倍位置开始存储。

仅供参考。

5 楼

谢谢,果然是这个问题,我已调通了,高兴!

6 楼


可不可以把你的程序发给我一份heiye135@163.com
谢谢

我来回复

您尚未登录,请登录后再回复。点此登录或注册