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

   print *, "SIZES = ", size(global_array), size(priv_array)
   ! global array is deallocated automatically on exit from subroutine, but what about each priv_array?
end subroutine foo
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


I didn't find any thing on deallocation in section 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.

Posts: 603
Joined: Wed Feb 10, 2010 2:44 pm

Return to Using OpenMP

Who is online

Users browsing this forum: No registered users and 4 guests