From ScorecWiki

Jump to: navigation, search

Using OpenMP with the GNU gfortran compilers:

0) Using the gfortran compiler allows to have openmp embedded (I have read on the web that g95 does not).

1) In the compilation line, just use -fopenmp after gfortran. Openmp in invoked with !$OMP PARALLEL ...{the code that need parallelization}... !$OMP END PARALLEL. Find a tutorial on the Internet for more details.

2) As far as I have experienced, some versions of the compiler lead to conflicts when using both OpenMP and IO subroutines. In this case, use another version of the compiler.

3) If the fortran code uses allocatable variables, consider modifying all the variables into non-allocatable variable so that the code can run with any version of gcc/gfortran. It is anyway better to limit or prevent the use of "global" variables in parallel computing.

4) If step 2 is not possible, then be aware that:

4.1) Allocatable variables are compatible with openmp only since openmp2.5 (that is gcc/gfortran4.3.0) for simple openmp declarations (PRIVATE, SHARED)

4.2) For the allocatable variables that are passed through a module to a subroutine inside a parallel openmp block and that are modified inside the subroutine, their values after the subroutine has terminated is the one before the subroutine started. {This may be a bug of gcc/gfortran4.3.X and above ... it is still unclear to me}

4.3) Allocatable variables are accepted for REDUCTION operations only since openmp3.0 (that is gcc/gfortran4.4.0).

5) there are several gcc/gfortran compilers installed at SCOREC:

5.1) for the most recent machines (Debian OS), check:

       + '/usr/bin/gcc-4.1' (gcc4.1.3), 
       + '/usr/bin/gcc' (gcc4.3.2) and 
       + '/usr/local/gcc/4.4.3/bin/gcc' (gcc4.4.3)

5.2) for the older systems (Redhat OS), check:

       + '/usr/bin/gcc32' (gcc3.2.3) and 
       + '/usr/bin/gcc' (gcc3.4.6).

Using OpenMP with the Intel ifort compilers:

1) To invoke OpenMP with the ifort compiler, use -openmp after ifort. The rest of the syntax is similar to the GNU compilers.

2) If possible use an Intel compiler that uses libiomp.* and not libguide.*. I have had problems with libguide.* (conflicts with OpenMP). As far as I know, the change occurred for version 10.0.0 of the Intel compilers.

3) At SCOREC, you'll find the Intel compilers at:

       + '/usr/local/intel/...'
Personal tools