fortran Because of COMMON, the alignment of object is inconsistent with its type
2013-02-22 19:49
239 查看
最近,好几个人问到公共块出错的问题,都是出于一个原因,特在这里把老贴整理一下供大家参考。
问题: 20924057
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) ---------------------------^
解答:
这是老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字节整数倍位置开始存储。
准则:作为好的编程习惯,建议在公共块中,把实型变量排在前边,把整型数据放在后边,就不会有对位不整的错误!
仅供参考。
补充:(05.06.01)
公共块不是用堆栈实现的,是内存中的一段连续存储的数据。
按照Fortran的规定,当读取双精度数据时,总是假定前面的数据长度是双精度数字节长度(8个字节)的整数倍。
对于本例,ASA(1,1)从第29个字节开始存放8个字节;可是读取的时候,要从第33个字节(28不是8的倍数,32是28之后最小的8的倍数)开始读入8个字节,这就是定位(alignment)错误。
所以F90之后不提倡用公共块共享数据,而可用更为灵活的module来代替公共块共享数据。
公共块是过时的语言功能
问题: 20924057
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) ---------------------------^
解答:
这是老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字节整数倍位置开始存储。
准则:作为好的编程习惯,建议在公共块中,把实型变量排在前边,把整型数据放在后边,就不会有对位不整的错误!
仅供参考。
补充:(05.06.01)
公共块不是用堆栈实现的,是内存中的一段连续存储的数据。
按照Fortran的规定,当读取双精度数据时,总是假定前面的数据长度是双精度数字节长度(8个字节)的整数倍。
对于本例,ASA(1,1)从第29个字节开始存放8个字节;可是读取的时候,要从第33个字节(28不是8的倍数,32是28之后最小的8的倍数)开始读入8个字节,这就是定位(alignment)错误。
所以F90之后不提倡用公共块共享数据,而可用更为灵活的module来代替公共块共享数据。
公共块是过时的语言功能
相关文章推荐
- - No enclosing instance of type Test is accessible. Must qualify the allocation with an enclosing in
- 错误:created a ThreadLocal with key of type ……but failed to remove it when the web application was stopped. This is very likely to create a memory leak.
- 继承“JdbcDaoSupport”后,报“The hierarchy of the type AccoutDaoImpl is inconsistent”的解决方案
- The hierarchy of the type is inconsistent错误
- The hierarchy of the type XXX is inconsistent异常排查方式
- 继承“HibernateDaoSupport”后,报“The hierarchy of the type AccoutDaoImpl is inconsistent”的解决方案
- 异常-----Can't convert the date to string, because it is not known which parts of the date variable are in use. Use ?date, ?time or ?datetime built-in, or ?string.\u003Cformat> or ?string(format) built-
- The hierarchy of the type class is inconsistent
- 'ddlXXX' has a SelectedIndex which is invalid because it does not exist in the list of items
- The name or security ID (SID) of the domain specified is inconsistent with the trust information for that domain
- 使用slidingmeu_actionbarsherlock_lib的问题和The hierarchy of the type MainActivity is inconsistent
- The hierarchy of the type is inconsistent
- webview使用遇到 It is possible that this object was over-released, or is in the process of deallocation错误的解决办法
- The hierarchy of the type is inconsistent
- 继承“HibernateDaoSupport”后,报“The hierarchy of the type AccoutDaoImpl is inconsistent”的解决方案
- 'ddlCities' has a SelectedValue which is invalid because it does not exist in the list of items
- The hierarchy of the type is inconsistent
- the name or security ID(SID) of the domain specified is inconsistent with the trust information for that domain
- 继承一个类的时候报错:The hierarchy of the type 'Class name' is inconsistent
- The hierarchy of the type MyMessageInbound is inconsistent