- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I'm having problems with a derived type variable containing
allocatable components declared shared in an openmp parallel
section. I've attached a minimal code to reproduce the problem
below. It executes when compiled with Ifort versions 11.0, 11.1, 12.0,
12.1, but crashes with 13.0, 13.1, 14.0, partially depending on
optimization flags. I typically get the error message:
forrtl: severe (151): allocatable array is already allocated
even though the print statement tells me it's not. I'm not completely
sure the code complies with the openmp specification, but at least I
cannot see an obvious problem. Any feedback would be appreciated.
All the best,
John
MODULE DERIVED_TYPE
IMPLICIT NONE
TYPE ALLOCATABLE_TYPE
REAL, DIMENSION(:), ALLOCATABLE :: vector
END TYPE ALLOCATABLE_TYPE
CONTAINS
SUBROUTINE INIT(var, len)
INTEGER, INTENT(IN) :: len
TYPE(ALLOCATABLE_TYPE), INTENT(INOUT) :: var
PRINT *, ALLOCATED(var%vector)
ALLOCATE(var%vector(1:len))
END SUBROUTINE INIT
END MODULE DERIVED_TYPE
PROGRAM TEST
USE DERIVED_TYPE
IMPLICIT NONE
TYPE(ALLOCATABLE_TYPE) :: var
CALL OMP_SET_NUM_THREADS(1)
!$OMP PARALLEL PRIVATE(var)
CALL INIT(var, 1)
!$OMP END PARALLEL
END PROGRAM TEST
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Try changing PRIVATE(var) to FIRSTPRIVATE(var).
Reason, you want to copy in the "not allocated" state of var into the parallel region
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks, Jim, that did the trick!
Best, John
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page