回 帖 发 新 帖 刷新版面

主题:[原创]用Gfortran运行.f程序,出现warning之后,runtime直接停止

用Gfortran运行.f程序,出现warning之后,runtime直接停止。请问大神,该程序出现了什么问题,需要什么样的改进!本人纯属菜鸟!希望得到帮助,好人一生平安!

回复列表 (共3个回复)

沙发

http://cepa.fnal.gov/psm/simulation/mcfast/version_doc/v5_2/simulator/alignment_notes.html

看这个介绍。这是定义common的时候的错误。有4条规则。
1 In any common block or structure, all 8 byte variables must start at an 8 byte boundary, relative to the start of the common block or structure.
2 Similarly all 4 byte variables must start at a 4-byte boundary relative to the start of the structure or common.
3 If a structure contains any 4 byte variables, its total length must be divisible by 4 without remainder.
4 If a structure contains any 8 byte variables, its total length must be divisible by 8 without remainder.

意思就是,8字节的变量要放在一起,4字节的也要放在一起,就是8字节和4字节的不能混着放,可以放在一起,但是不能相互间隔的放。然后就是如果有8字节变量,整个common的长度要被8整除,如果有4字节的要被4整除。

这些都是为了保证在不同的机器上可以运行通过,不同编译器可能不同吧,有的可以自动填充padding来保证这些规则。

板凳


平时不会用common,一般用module,没有这些问题。楼主可以试一下。

3 楼

哦,忘了精华贴还有mltx老师的详细解析
http://bbs.pfan.cn/post-78830.html

我来回复

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