I have an issue with a Fortran code that I am trying to parallelize using OpenMP. This is a code for Monte Carlo particle transport and it has several COMMON blocks that I marked as private using the THREADPRIVATE directive. A (very very very small) example of this code could be:
[ VARIABLES DEFINITIONS, COMMON BLOCKS, ETC]
C$OMP PARALLEL DO
C$OMP END PARALLEL DO
END PROGRAM TUTOR2
[ VARIABLES DEFINITIONS, COMMON BLOCKS, ETC ]
[ A LOT OF CODE ]
Well, as you can see the COMMON block /RANDOMM/ is first declared inside a SUBROUTINE (in this case SHOWER) and not the main program. This happens with a lot of COMMON blocks with this code. The variables inside RANDOMM block are initialized inside another subroutine before the PARALLEL DO directive. Therefore, I need to copy the values of RANDOMM block from the master thread to the slave threads, but as this block is first declared inside a subroutine I cannot use the COPYIN clause.
Is there a better approach to this problem than declaring all the COMMON blocks needed as private in the main program?. Thanks for your help!.