[mpich-discuss] MPI / openmp - big static arrays fortran

William Gropp wgropp at illinois.edu
Sun Mar 15 09:29:54 CDT 2015


Because the module could be used in a routine, not just the main program, Fortran probably allocates it off of the stack (the way it manages memory).  If there is one thread, then it is easy to make that stack very large.

If multiple threads *might* be used, it gets harder.  Typically, the Fortran compiler and runtime divides the memory in to multiple stacks, one for each (potential) thread.  This reduces the amount of space available to each thread’s stack, and can cause problems with data that is allocated on the stack.  The two common options are (a) don’t allocate the space like this - allocate it dynamically or (b) tell the compiler that you need larger stacks for the threads.

Bill

On Mar 15, 2015, at 5:25 AM, Jan Wittke <wittke at geo.uni-koeln.de> wrote:

> Hi,
> 
> I have a strange problem. When I compile this code:
> 
> module user
>   implicit none
>   
>   type user_type
>     real :: value
>     integer, dimension(30,30) :: array
>   end type
> 
> end module
> 
> program test_mpi
>  use user
>  implicit none
>  
>  integer, parameter :: num = 1e5
>  type(user_type),  dimension(num)    :: var
> 
>  var(1)%value = 19.
>  
>  write(*,*) var(1)%value
> 
>             end program
> 
> with gfortran and run it there is no problem.
> Now If I compile this program with
> 
>     mpifort -fcoarray=lib -fopenmp  testmod.f95 -lcaf_mpi
> 
> and run it with 
>  
>    mpirun -np 1 ./a.out
> 
> I got an error Segmentation fault (signal 11)
> 
> Now if if compile it with 
> 
>    mpifort -fcoarray=lib testmod.f95 -lcaf_mpi
> 
> everything is fine. 
> Why is it a problem to add the option  -fopenmp with this code?
> Doing some web searches suggests that using big static array 
> will not work .
> 
> Thanks
> Jan
> _______________________________________________
> discuss mailing list     discuss at mpich.org
> To manage subscription options or unsubscribe:
> https://lists.mpich.org/mailman/listinfo/discuss

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mpich.org/pipermail/discuss/attachments/20150315/cff210c0/attachment.html>
-------------- next part --------------
_______________________________________________
discuss mailing list     discuss at mpich.org
To manage subscription options or unsubscribe:
https://lists.mpich.org/mailman/listinfo/discuss


More information about the discuss mailing list