Compile and launch a FORTRAN code with OpenMP directives
- OpenMP is a shared-memory parallel programming model. For more information on OpenMP,
see http://www.openmp.org.
- pgf77 and pgf90 Fortran compilers support the OpenMP Fortran Application Program Interface.
Use -mp option to instruct the compiler to interpret user-inserted OpenMP shared-memory parallel
programming directives and generate an executable file which will utilize multiple processors
in a shared-memory parallel system. Here is a typical compilation command:
$ pgf90 -mp -o myprog.e myprog.f
Without -mp, the compiler will ignore user-inserted shared-memory parallel programming
directives and pragmas.
- The next is a typical shell script, saved in file "omp.sh", for submitting the OpenMP job through SGE:
--------------------------------------------
#!/bin/bash
#$ -V
#$ -cwd
#$ -pe threaded 2
#
export OMP_NUM_THREADS=$NSLOTS
time myprog.e
--------------------------------------------
- The line "#$ -pe
threaded 2" specifies the SGE Parallel Environment 'threaded' (which is the proper
one to use for OpenMP jobs) with 2 slots, i.e. $NSLOTS=2.
The maximum number of slots is limited to 8 in one node.
- Submit the job through SGE:
$qsub omp.sh
- Check the status of the job:
$qstat -f
(Ju)
Back to Aster Q/A