主题:有个程序请教mltx老师
youngstar
[专家分:0] 发布于 2005-05-07 14:09:00
这个程序是一本参考书的源程序,不过是用fortran77编写的,现在用visual fortran编译,就出错,可是我一直就发觉不了错误的原因,请大师出来指点一二,谢谢!我已把源程序上传到http://upload.programfan.com/upfile/200505071357513.rar了
3 楼
youngstar [专家分:0] 发布于 2005-05-08 21:40:00
你说的没错,我传上去的程序是我改动了一点的程序,我刚刚把最原始的原程序编译了一下,出现的是以下提示:
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 楼
mltx [专家分:20880] 发布于 2005-05-08 22:21:00
这是老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字节整数倍位置开始存储。
仅供参考。