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

Issue with OpenMP and automatic lhs allocation of string variable

OP1
New Contributor III
24 Views

I believe that the code shown below (built with ifx 2026.0.0 on Windows 11) is standard-compliant; however, it crashes with the message: "forrtl: severe (153): allocatable array or pointer is not allocated".

PROGRAM P
IMPLICIT NONE (TYPE, EXTERNAL)

CHARACTER(LEN = :), ALLOCATABLE :: S

S = '' ! The code will work if this line is commented out.
!$OMP PARALLEL PRIVATE(S)
    S = 'Hi!' 
    WRITE(*, *) S
!$OMP END PARALLEL 

END PROGRAM P

Similar codes, where the allocatable variable is an integer array, do not exhibit the same behavior. It seems the bug is limited to the automatic lhs allocation of S on line 8.

0 Kudos
1 Reply
JohnNichols
Honored Contributor I
13 Views

It runs on latest ONEAPI, but throws the errors and then performs ok

You cannot debug it, it sticks on line 6. 

PROGRAM P
IMPLICIT NONE (TYPE, EXTERNAL)

CHARACTER(:), ALLOCATABLE :: S

!S = 'A' ! The code will work if this line is commented out.
!$OMP PARALLEL PRIVATE(S)
    S = 'Hi!' 
    WRITE(*, *) S
!$OMP END PARALLEL 

END PROGRAM P

  But this runs, remove the null assignment of S, why do you need it, as you note?  The standard Intel note does not have LEN = 

0 Kudos
Reply