Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
149 Views

Intel fortran compiler and automatic array declaration

Hi

I tried to run the SWEEP3D benchmark with intel compiler on a SMP server. The benchmark is mainly a Fortran 77 program but it needs an automatic array variables in one subroutine as shown below:

c...AUTOMATIC ARRAYS
double precision Sigt(it,jt,kt)
double precision Pflux(it,jt,kt)
double precision Srcx(it,jt,kt)

Where it, jt and kt are given as a subroutine's argument.

I can compile to program, but it crashed when the subroutine that uses automatic array is called.
My question: how to make intel compiler recognizes this is an Fortran77 but with automatic array allocation ? SUN compiler can do this very well.

Thanks

Laksono Adhianto
0 Kudos
10 Replies
Highlighted
149 Views

The compiler recognizes this just fine. The problem is probably that automatic arrays are created on the stack and you have insufficient stacksize limit. Try raising the limit with:

limit stacksize unlimited

or

ulimit -a

and see if it helps. I would suggest as an alternative to make the arrays allocatable. So you would replace the declarations with:

double precision Sigt(:,:,:)
double precision Pflux(:,:,:)
double precision Srcx(:,:,:)

and then add at the beginning of the routine:

allocate (Sigt(it,jt,kt), Pflux(it,jt,kt), Srcx(it,jt,kt))

Nothing else needs to change.
0 Kudos
Highlighted
Beginner
149 Views

I had the exactly the same problem. For large array sizes, the automatic declaration produced a "signal 11" seg fault crash. The above solution works. However, in the above declaration of the arraysone has to include the "allocatable" keyword to make it work, e.g.
real(kind=8),allocatable ::a(:),...
accompanied by an
allocate(a(N),...)
statement works, while a simple
real(kind=8) :: a(N)
at the beginning of a subroutine crashed for me for large array sizes. The crash happensdirectly after calling the subroutine.While it looks like a stack overflow, an increase of stack size to unlimited or compilation with the -save optiondoes not help!
Is this a bug in the compiler?
0 Kudos
Highlighted
149 Views

Again, your a(N) in the declaration creates an automatic array which is always allocated on the stack when the routine is called. (This assumes that a is not an argument to the routine.) If N is large, you'll use a lot of stack. Whether or not you can get this to work by increasing the stack limit depends on your system configuration. There also tends to be a hard upper limit of 1GB for the stack.

I recommend using ALLOCATABLE local arrays rather than automatic arrays when the array is likely to be large.
0 Kudos
Highlighted
Beginner
149 Views

Why do you recommend to use an allocatable array instead of an automatic array for large arrays? Conceptually it seems to be the same inside a subroutine. Has the former any performance advantages or something else?

Thanks,

Miguel
0 Kudos
Highlighted
149 Views

I recommend it because an allocatable array is not restricted by the stacksize limit - you can allocate as large an array as the OS will allow you for virtual address space.

There is a small performance disadvantage for the allocation and deallocation, which is why I recommend it when you know the array is likely to be large.
0 Kudos
Highlighted
Black Belt
149 Views

Allocatable also gives you the opportunity to build in error checking, to confirm success of the operation.
0 Kudos
Highlighted
Beginner
149 Views

I guess that the overhead due to the allocation/deallocation is small compared to the typical number of operations one is going to perform on a large array, or?



More interesting for me is to know the overall performance comparison. Mainly to know, if there are any differences in the read/write performance and in the dummy variable associations.



Thanks in advance,



Miguel

Message Edited by mhermanns on 10-27-2005 10:38 AM

0 Kudos
Highlighted
149 Views

If you're talking an automatic array, it's not a dummy argument.

Yes, my thought was that a large array would have many operations that would be more significant than the fixed allocate/deallocate time. I would not expect any noticeable impact of the actual array references.
0 Kudos
Highlighted
Beginner
149 Views

What I mean with dummy argument is that I have an automatic array created in a subroutine and I pass it to another one as an argument.

If the performance is the same and the only difference is the overhead of allocation/deallocation, then I agree that it is better to do allocatables.

Thanks for the information.

Miguel
0 Kudos
Highlighted
149 Views

No difference at all in passing the array.
0 Kudos