- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am using Fortran Compiler XE 15.0.1.148 .
When I compile and run the following simple program in Debug mode, it runs fine without any errors or warnings. However, it crashes if I compile it in optimized Release mode. I can prevent it from crashing if I disable the /Qopenmp option. My guess is that the problem has something to do with having a derived type variable declared as private in OpenMP loop.
program test_derived_type implicit none type T integer,allocatable:: a(:) end type T type(T):: b integer i, s s = 0 !$OMP parallel do default(none), schedule(dynamic), & !$OMP& private(i,b), reduction(+:s) do i = 1, 100 print*, i allocate( b%a(i) ) b%a = 1 s = s + sum(b%a) deallocate(b%a) end do ! i !$OMP end parallel do write(*,*) 's =', s stop end program test_derived_type
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
My reading of the OpenMP 4.0 standard (Section 1.6 Normative References, page 22, line 25) suggests that allocatable components of derived types are not supported in OpenMP regions.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Add COPYIN(b) next to the private(i,b).
Outside the scope of the parallel region b%a surprisingly is defined as an un-allocated array. Meaning the array descriptor is initialized to represent an unallocated array (in this case of rank 1).
Without the COPYIN, the variables in the PRIVATE are undefined. Meaning not set or initialized. Therefore b%a will be undefined, which is not the same as unallocated.
Jim Dempsey
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page