Search code examples
compiler-errorsstaticfortranlarge-data

Why can't I allocate an intent(out)?


What is up with this issue where I can't allocate something with intent(out)? I've seen it in some manuals online that you can't use intent(out) with allocate.

Before I used a static array, so it wasn't a problem but now I have very large arrays and I run into these R_X86_PC64 errors where the compiler doesn't like the size of my static arrays unless I use intel with -mcmodel=medium -shared-intel flags.

PGI will compile the code, but seg faults at the allocate. It doesn't mind the exact same allocation in the main program, but in subroutine as intent(out) no dice...

Is there a similar command to intel for pgi where I can have big static arrays and go back to doing that?

Any other suggestions?


Solution

  • module MyMod
    
    implicit none
    
    contains
    
    subroutine MySub ( array )
    
       real, dimension (:), allocatable, intent (out) :: array
       integer :: N
    
       write (*, '( "Input array size: " )', advance="no" )
       read (*, *) N
    
       allocate (array (N))
    
       array = 1.0
    
    end subroutine MySub
    
    end module MyMod
    
    
    program main
    
    use MyMod
    
    implicit none
    
    real, dimension (:), allocatable :: B
    
    call MySub (B)
    
    write (*, *) allocated (B), size (B)
    
    deallocate (B)
    
    write (*, *) allocated (B)
    
    end program main