[Omp] Declaring private and shared variables

Meadows, Lawrence F lawrence.f.meadows at intel.com
Thu Aug 17 13:43:38 PDT 2006


You appear to be using free form. It is odd that you didn't get a compiler
warning. Please see section 2.1.2 of the OpenMP 2.5 standard. The
OpenMP directives follow the usual Fortran continuation lexical conventions.
so, for example:

!$omp parallel do &
!$omp& shared(a, &
!$omp  b),private(c)

Fixed form is different but the same idea, and I've added more & then
you need for free form... you need to understand Fortran lexical
conventions.

If you still have problems please contact your compiler vendor

Regards,

Larry Meadows

>-----Original Message-----
>From: omp-bounces at openmp.org [mailto:omp-bounces at openmp.org] 
>On Behalf Of Hakan Lane
>Sent: Thursday, August 17, 2006 2:07 PM
>To: omp at openmp.org
>Subject: [Omp] Declaring private and shared variables
>
>Hello all,
>
>I have problems with making a parallel a loop do the same things as the
>corresponding serial routine. I
>have noticed that I have to state the names of all variables 
>in the shared
>and private lists. The problem for this part is that there are 
>so many of
>them that the compiler won´t allow so long lines. As a 
>consequence, I think
>that I will have to split it up. I have tried by doing:
>!$OMP parallel
>!$OMP shared(....)
>!$OMP private(.....)
>However, the shared variables do not have the right values 
>after the loop. I
>have tried both !$OMP do and finding the upper and lower 
>iteration limits
>for each processor manually, as indicated below. Can you see 
>how I should do
>it instead?
>
>Regards,
>
>Håkan Lane
>Email: Hakan.Lane at epfl.ch
>
>!$OMP parallel
>!$OMP
>shared(gridet,elements,materials,sections,normals0,orientations
>,ellist,A,B,n
>odf,elemf,normf,delta_nodf,num,delta_elemf,delta_time,time,mfac
>,nrhs,flagMat
>,flagProb,flagFint,nlgeom,L2Fieldnr,flaghht,energy,flux,nflux)
>!$OMP
>private(Me,Ke,Fe,Ce,ene,info,accv,nee,eqindx,tnr,lvarde,varde,h
>varde,kel,eqi
>nd,eqindxp,work,col,i)
>
>anttrad=omp_get_num_threads()
>tnr=omp_get_thread_num()
>bas=num/anttrad
>varde=tnr*bas
>lvarde=nint(varde)+1
>print *,tnr,lvarde
>if (tnr.LT.(anttrad-1)) then
>    varde=(tnr+1)*bas
>    hvarde=nint(varde)
>else
>    hvarde=num
>end if
>
>
>do i = lvarde,hvarde
>
>        kel = ellist(i)
>
>    !$OMP critical
>    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)
>   !$OMP end critical
>
>  if (flagProb.GT.0) then
>   do eqind=1,nee
>  do col=1,nee
>   Fe(eqind,1)=Fe(eqind,1)+Me(eqind,col)*accv(col)
>  end do
> end do
> Ke(1:nee,1:nee) = Ke(1:nee,1:nee)*mfac(2) +
>Ce(1:nee,1:nee)*mfac(1)+Me(1:nee,1:nee)
>    deallocate(accv)
>  end if
>  !$OMP critical
>  call add_elmat2crs(Ke,Fe,eqindx,nee,ene,flagMat,        &
>                      nrhs,work,A,B,energy,flux,nflux)
>  !$OMP end critical
>
>  end do
>
>  !$OMP barrier
>  !$OMP end parallel
>
>_______________________________________________
>Omp mailing list
>Omp at openmp.org
>http://openmp.org/mailman/listinfo/omp
>


More information about the Omp mailing list