2

Can you please tell me exactly where to place the OpenMp THREADPRIVATE directive for the common block? Immediately after the description of this block, immediately after the description of this block and all other variables of any kind, or only after all DATA blocks? Example:

SUBROUTINE SCHNEVPDH (RZ,FLAT,FLON,R,T,L,BN,BE,BV)
      PARAMETER   (IBO=0,JBO=1,KDIM=8,LDIM=4)
      DIMENSION   FN(0:KDIM,0:KDIM), CONSTP(0:KDIM,0:KDIM)
      DIMENSION   CML(KDIM), SML(KDIM)
      DIMENSION   DELT(0:LDIM)
      DIMENSION   BINT(0:KDIM,0:KDIM,1-IBO-JBO:LDIM),
     *            BEXT(0:KDIM,0:KDIM,1-IBO-JBO:LDIM)
      COMMON    /CONST/UMR,PI
     *          /AMTB/BINT,BEXT,RE,TZERO,IFIT,IB,KINT,LINT,KEXT,
     *              LEXT,KMAX,FN
      CHARACTER*1 IE,RESP
      DATA ((CONSTP(N,M), M=0,N), N=0,KDIM)
     *   /4*1.,1.73205,0.866025,1.,2.44949,1.93649,0.7905691,1.,
     *    3.16228,3.35410,2.09165,0.739510,1.,3.87298,5.12348,
     *    4.18330,2.21853,0.701561,1.,4.58258,2*7.24569,4.96078,
     *      2.32681,0.671693,1.,5.29150,9.72111,11.4564,9.49918,
     *      5.69951,2.42182,0.647260,1.,6.,12.5499,16.9926,16.4531,
     *      11.8645,6.40755,2.50683,0.626707/
!$OMP THREADPRIVATE(/CONST/)
!$OMP THREADPRIVATE(/AMTB/)
      IBF   =  2
      T1=1.
      T2=12.
      CALL TBFIT (T1,T2,IBF,THINT,TZERO)

Is this directive in the right place? The same question applies to SAVE type variables.

  • 2
    Looks good to me. I would put the `threadpviate` closer to the actual `COMMON` statement, but the way you have it is fine. `SAVE` declarations can also go anywhere. Fortran does not care much in what order you give the various parts of a declaration. Btw, it would be a good idea to use `IMPLICIT NONE` in all your programs. – Victor Eijkhout Feb 08 '22 at 04:57
  • @VictorEijkhout, thank you for your answer. Yes, I know about `IMPLICIT NONE`, but this code is not mine and it consisits of tens of thousands of lines of code... That's why I'm trying do not many changes in this code. – Владимир Ивонин Feb 08 '22 at 08:04
  • 2
    If the "const" common block really is just constants (so is never changed) leaving it shared should be fine. There's no need for each thread to have its own copy. – Jim Cownie Feb 08 '22 at 15:41

0 Answers0