[Omp] Passing private arrays to subroutines

Håkan Lane h.l at operamail.com
Wed Jan 10 03:23:52 PST 2007


This is a part of the code.

real(kind=doubl),dimension(:,:),allocatable: Me,Ke,Fe,...

!$OMP parallel &
!$OMPprivate(Me,Ke,Fe,Ce,ene,info,(many more variables)
!$OMP& Pprev,tnr,bvarde,lvarde,hvarde) &
!$OMP&shared(gridet,elements,materials,sections,normals0,orientations,ellist, &
!$OMP&A,B,nodf,many more variables)

do i=lvarde,hvarde

     kel=ellist(i)       
    call get_elmat(gridet,elements,materials,sections, &
                  normals0,orientations,nodf,elemf,normf,  &
                  delta_nodf,delta_elemf,delta_time,time,mfac,&
                  flagProb,flagFint,nlgeom,L2Fieldnr,kel,   &
                  nrhs,nee,eqindx,Me,Ke,Fe,Ce,ene,info,accv)

many more commands

end do

The compiler won't allow Me,Ke and the others to be unassociated when entering the parallel region. I have tried many options, including allocate them first outside the parallel region and then again in the parallel region and deallocating them after every iteration and allocate them again in the next iteration. I keep getting the segmentation fault after a while.

Get_elmat is located in another module of the program. I have not included the interface in this module. The subroutine is not overloaded. It should not do anything with the status of the arrays. It works fine with the serial version.

Håkan Lane





> ----- Original Message -----
> From: "Meadows, Lawrence F" <lawrence.f.meadows at intel.com>
> To: "Håkan Lane" <h.l at operamail.com>, omp at openmp.org
> Subject: RE: [Omp] Passing private arrays to subroutines
> Date: Wed, 10 Jan 2007 00:14:00 -0800
> 
> 
> Can you be more specific? Fortran pointers? Real (f90-style) 
> fortran pointers or cray-style pointers? Do you have a simple 
> example that fails?
> 
> Private allocatables must be unallocated on entry to a parallel 
> region (2.8.3.3 of the 2.5 specification).
> Pointers need to be associated within the parallel region, just 
> like any private variable. Also note the restrictions on 
> firstprivate for pointers (2.8.3.4).
> 
> So really, you need to allocate and/or associate any pointer-based 
> private objects after entering the parallel region, and deallocate 
> them before exiting the region (assuming they were allocated) to 
> avoid memory leaks.
> 
> OpenMP doesn't change any of the rules about when interfaces are required.
> 
> Good Fortran style is to put everything in modules and use them; 
> then you don't need interface blocks.
> 
> Hope this helps. As I say, send us an example and we can tell you 
> what is wrong.
> 
> -- Larry
> 
> 
> -----Original Message-----
> From: omp-bounces at openmp.org [mailto:omp-bounces at openmp.org] On 
> Behalf Of Håkan Lane
> Sent: Tuesday, January 09, 2007 2:40 PM
> To: omp at openmp.org
> Subject: [Omp] Passing private arrays to subroutines
> 
> 
> I have tried for several days now to pass a set of pointers made 
> private by !$OMP parallel private from a do-loop in a calling 
> routine in one module to a subroutine in another. No matter how I 
> do it, I seem to get a segmentation fault sooner or later. I can 
> not see the logic as to where they occur.
> 
> I would be grateful if someone could provide the rules for this. I 
> have tried both with pointers and allocatable, but it does not work.
> 
> Please let me know what I need to in terms of interfaces (not 
> necessary in the serial version), allocation and deallocation and 
> directives.
> 
> Håkan Lane
> 
> 
> --
> _______________________________________________
> Surf the Web in a faster, safer and easier way:
> Download Opera 9 at http://www.opera.com
> 
> Powered by Outblaze
> _______________________________________________
> Omp mailing list
> Omp at openmp.org
> http://openmp.org/mailman/listinfo/omp

>


-- 
_______________________________________________
Surf the Web in a faster, safer and easier way:
Download Opera 9 at http://www.opera.com

Powered by Outblaze


More information about the Omp mailing list