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

allocate in internal subprogram

tjcamp
Beginner
482 Views
I am using IFC Version 7.0 Build 20021028Z on RH 7.2.

Here is the problem:
An allocatable array declared in an external subprogram then allocated in an internal subprogram is no longer allocated after the internal subprogram returns and the save attribute is used. Here is the test code:

SUBROUTINE W3WAVE(NSEAL)
INTEGER,INTENT(IN) :: NSEAL
!REAL, ALLOCATABLE :: HS(:) !OK
REAL, ALLOCATABLE, SAVE :: HS(:) !Not OK
CALL W3INIT
PRINT*,'IN W3WAVE AFTER W3INIT: ' &
,ALLOCATED(HS),SIZE(HS)
RETURN
CONTAINS
SUBROUTINE W3INIT
ALLOCATE(HS(NSEAL))
PRINT*,'IN W3INIT: ' &
,ALLOCATED(HS),SIZE(HS)
RETURN
END SUBROUTINE W3INIT
END SUBROUTINE W3WAVE

PROGRAM W3SHEL
CALL W3WAVE(360)
END PROGRAM W3SHEL

Here is the output with the save attribute enabled:
IN W3INIT: T 360
IN W3WAVE AFTER W3INIT: F 0

Here is the output without the save attribute:
IN W3INIT: T 360
IN W3WAVE AFTER W3INIT: T 360

This test code works fine on other platforms / compilers -- indicating to me a problem with ifc. I welcome any helpful response.
Thanks,
TC
0 Kudos
2 Replies
Steven_L_Intel1
Employee
482 Views
Looks like this is fixed in the current version 7.1.

Steve
0 Kudos
tjcamp
Beginner
482 Views
Thanks for the quick reply.
I'll check it out.
TC
0 Kudos
Reply