3

This code compiles and runs just fine under Intel and GNU:

program simplarray

        implicit none

        real, allocatable, dimension(:,:,:) :: a

        character(len=32) :: cmdarg
        integer :: n = 0

        call get_command_argument(1, cmdarg)
        read(cmdarg,'(i)') n

        print '("n=",i5)', n
        call flush(6)

        allocate(a(n,n,2))
        print '("a is dimensioned  ", 3i5)', shape(a)

        deallocate(a)

end program

Output:

>  ./a.out 50
n=   50
a is dimensioned     50   50    2

But Cray doesn't like it at all:

> ./a.out 10
n=   10
Illegal instruction (core dumped)

Now, here's the kicker: If I replace the command line input with just a simple setting of n, everything is fine:

        integer :: n = 10

!        call get_command_argument(1, cmdarg)
!        read(cmdarg,'(i)') n

Now I get

./a.out
n=   10
a is dimensioned     10   10    2

Update: Tried just reading from a regular text file:

integer :: n

open(unit=11, file='size.txt')
read(11,*) n
close(11)

Cray doesn't like that either. Same problem.

So, if n comes from the command line, Cray can read n. It thinks n is an integer and can even write out its value. But it can't use n in the allocate statement. (BTW, I have experimented in several ways with the format of the read statement, to no avail.) What is going on?

UPDATES in response to some comments:

First, is it possible I have discovered a bug? I moved this to another Cray platform, where it runs just fine. The Cray version on both machines is 12.0.3.

Second, my build was pretty simple, just

ftn simplarray.F90

I am building and compiling on the login nodes, which are Intel Broadwells.

15
  • 1
    Is get_command_argument available in Cray? It seems to be the root of your problem. Commented Nov 17, 2021 at 15:46
  • 1
    This seems related to this question: Fortran code executes under Intel and GNU, fails under Cray Commented Nov 17, 2021 at 15:52
  • 1
    get_command_argument was implemented in 2003 standard. What compiler standard does Cray support? Try GETARG instead? - stackoverflow.com/a/13844047/13813219 Commented Nov 17, 2021 at 15:53
  • 2
    Can you tell us exactly how you compiled this, and whether the architecture of the login nodes on your Cray is the same as the compute nodes. It's possible you've compiled for the compute nodes but are running on the login, or vice versa Commented Nov 17, 2021 at 15:56
  • 2
    ftn is the generic fortran compiler driver on Crays - so I am afraid what you have edited into the question tells us nothing. You need to tell us what modules you loaded beforehand. You also need to tell us where you are running the code - it looks like on the front end but by default on all Crays I know ftn builds for the compute nodes. Are you running on the login nodes? What is the architecture of your compute nodes? Commented Nov 17, 2021 at 16:17

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.