Setting Up Programming Environment

1. Load the compiler module

We will work with the GNU compiler for compiling and testing OpenMP code.

$ source module.sh

2. Compile your OpenMP application

Compilation

$ g++ <source_file>.cc -fopenmp -o <output>
$ gfortran <source_file>.f90 -fopenmp -o <output>

For example:

Example compilation

$ g++ Hello-world.cc -fopenmp -o Hello-World
$ gfortran Hello-world.f90 -fopenmp -o Hello-World

3. Execute your application

$ ./<output>

For example:

$ ./Hello-World

Hello world from the master thread
Hello world from thread id 0 from the team size of 5
Hello world from thread id 3 from the team size of 5
Hello world from thread id 1 from the team size of 5
Hello world from thread id 4 from the team size of 5
Hello world from thread id 2 from the team size of 5