Skip to main content

7.4) Compiling And Submitting OpenMP Jobs (cont'd)


So putting that all together, to compile with OpenMP parallelisation use:

[bash]
$ ifort –openmp –o omp_prog omp_prog.f90
[/bash]

To then run the code on 4 cores, first set the number of processes and then execute:

[bash]
$ export OMP_NUM_THREADS=4
$ ./omp_prog
[/bash]

This example assumes you are running on the login node. The login node should only be used for short tests and not production jobs. As with serial jobs, OpenMP jobs can be submitted to the batch queue with the appropriate script. To request n cores in the shared memory environment use the –pe smp n directive. The system will then automatically set OMP_NUM_THREADS to the value of n.