首页 > 解决方案 > Fortran 代码在 Intel 和 GNU 下执行,在 Cray 下失败

问题描述

我使这个程序尽可能简单:

module buffers
complex(8), allocatable :: iobuff(:,:)
end module buffers


program useAllocate

use buffers

integer(kind=4) :: rc=0
character(len=16) :: instr

integer(kind=8) :: abwds
integer(kind=4) :: anbs

call get_command_argument(1, instr)
read(instr,*) abwds
call get_command_argument(2, instr)
read(instr,*) anbs

call allocateBuffers(abwds, anbs, rc)

end program




SUBROUTINE allocateBuffers(arg_buff_wds, arg_num_buffs, retcode)

use buffers

IMPLICIT none

integer(kind=8), INTENT(in)  :: arg_buff_wds
integer(kind=4), INTENT(in)  :: arg_num_buffs
integer(kind=4), INTENT(out) :: retcode

print *,'allocating iobuff ', arg_buff_wds,'X',arg_num_buffs
ALLOCATE(iobuff(arg_buff_wds, arg_num_buffs), stat = retcode)
print *,'iobuff allocated'
print *,'iobuff has shape ',shape(iobuff)
DEALLOCATE(iobuff)
print *,'iobuff freed'

END SUBROUTINE allocateBuffers

它在 Intel 或 GNU 构建下运行良好:

> ./a.out 3 3
allocating iobuff                      3 X           3
iobuff allocated
iobuff has shape            3           3
iobuff freed

但是 Cray Fortran,由于某种原因无法处理分配:

> ./a.out 3 3
allocating iobuff  3 X 3
Illegal instruction (core dumped)

有人知道为什么吗?

(注意:complex(8)类型iobuff不是问题;无论我定义什么类型,代码都会失败并出现相同的错误iobuff。请注意,各种类型的变量来自我真正想要理解的更大的代码。)

标签: fortrancray

解决方案


推荐阅读