Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29010 Discussions

Passing nested arguments to subroutine

Basu__Sourish
Beginner
557 Views

Hi all,

I've just started using Intel's fortran compiler (I used to use IBM's). Among other changes, I noticed that passing an intrinsic function of an array as the argument to a subroutine resulted in a segmentation fault. Basically, if A is an array, then a call to

some_subroutine(A)

is fine, but, for example,

some_subroutine(transpose(A))

causes a segfault. I'm attaching a minimal code that will reproduce this. I compiled it with

ifort -m64 -r8 -O3 -o bad_ifort bad_ifort.F90

The segfault does not happen for small matrices, but my problem size is in fact a few thousand by a few thousand, and I never had a problem with this when I was using xlf. Is this a limitation of Intel's fortran compiler, or is there a compiler switch that I need to use?

Cheers,

Sourish

0 Kudos
4 Replies
jimdempseyatthecove
Honored Contributor III
557 Views

When you port, it is a good practice to use the /gen:interfaces /warn:interfaces

as well as to enable all runtime checks.

Jim Dempsey

0 Kudos
mecej4
Honored Contributor III
557 Views

When you use "transpose(B)" as an actual argument, a temporary array of the requisite size needs to be allocated (on the stack or the heap, depending on which compiler options have been used). Use the "stack" shell command of your system (ulimit -s for the bash shell) to raise the stack size from the default size, which can be quite small on some Linux/Unix distributions.

0 Kudos
Basu__Sourish
Beginner
557 Views

Thanks for the feedback, guys. Unfortunately, the warn:interfaces and gen:interfaces (-warn interfaces and -gen-interfaces on a unix system) did not solve my problem. Also, on the cluster I'm working on there is no "stack" command, but when I try ulimit, I get

$ ulimit
unlimited

Does this mean that the stack size is not small?

0 Kudos
Basu__Sourish
Beginner
557 Views

@mecej4, thanks for the suggestion. I just discovered the 'ulimit -s', and setting that to 'unlimited' solved my problem. Alternatively, adding

-heap-arrays `ulimit -s`

also works!

0 Kudos
Reply