1

I have made this program as simple as I can:

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

It works just fine under an Intel or a GNU build:

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

But Cray Fortran, for some reason can't handle the allocate:

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

Anyone have any idea why?

(NOTES: The complex(8) type of iobuff is not the problem; the code fails with the same error no matter what type I define iobuff to be. Note that the various types of the variables come from the much bigger code I am really trying to understand.)

bob.sacamento
  • 6,283
  • 10
  • 56
  • 115
  • How are you compiling this? – Mansoor Feb 01 '21 at 19:14
  • 3
    You seem to compile Fortran code on a various set of compilers. It is then very important to mention that `integer(kind=8)` is very bad practice. I strongly suggest you to make use of the `iso_fortran_env` module and the variables `INT32` and `INT64` therein. See [this answer](https://stackoverflow.com/a/3170438/8344060) for a bit more information on `kind` – kvantour Feb 01 '21 at 19:37
  • @M.A Just ftn `ab.F90`. Just for grins I tried `ftn -I . ab.F90`. Same result. I use the same commands for Intel and GNU. – bob.sacamento Feb 01 '21 at 19:48
  • 1
    Try to simplify the code even further, it is still quite long. As much as possible. Delete and test, delete and test, delete and test. I uncovered several bugs in the Cray compiler when compiling my code several years ago. – Vladimir F Героям слава Feb 01 '21 at 19:55
  • If you change abwds to be an int32, and obviously also the corresponding dummy argument, what happens? Also what version of the cray compiler? – Ian Bush Feb 02 '21 at 09:41
  • The program seems to work all right with `Cray Fortran : Version 10.0.4`. – jacob Feb 21 '21 at 13:00

0 Answers0