Fortran automatic deallocation and OpenMP

General OpenMP discussion

Fortran automatic deallocation and OpenMP

Postby jhogg » Mon Jan 23, 2012 5:50 am

Since Fortran 95 allocatable arrays automatically deallocate when they go out of scope. How does this interact with OpenMP if they are private?

For example, is the following code (a) valid, and (b) if so, where does priv_array get deallocated?

Code: Select all
subroutine foo
   implicit none
   
   integer, dimension(:), allocatable :: priv_array, global_array

   allocate(global_array(10))
!$OMP PARALLEL DEFAULT(NONE) PRIVATE(priv_array) SHARED(global_array)
   allocate(priv_array(5))
   print *, "SIZES = ", size(global_array), size(priv_array)
!$OMP END PARALLEL
   ! global array is deallocated automatically on exit from subroutine, but what about each priv_array?
end subroutine foo
jhogg
 
Posts: 1
Joined: Mon Jan 23, 2012 5:44 am

Re: Fortran automatic deallocation and OpenMP

Postby ftinetti » Tue Jan 24, 2012 4:56 am

Hi,

I didn't find any thing on deallocation in section 2.9.3.3 of the spec. where I assume it should be. My guess is that those become deallocated, but as I do not trust my guesses (and I would not suggest others to do so) I would explicitly deallocate those variables at the end of each parallel region.

HTH.
ftinetti
 
Posts: 582
Joined: Wed Feb 10, 2010 2:44 pm


Return to Using OpenMP

Who is online

Users browsing this forum: No registered users and 7 guests