OpenMP uses the ``fork-join'' model of parallel execution with threads sharing variables. Lightweight threads are part of the POSIX standard so are efficiently implemented in most UNIX operating systems. OpenMP simply provides a Fortran API to manage these threads. C and C++ APIs have also been released. Program execution begins with a ``master'' thread. Sections of the program are executed by a ``team'' of threads between directives. The master becomes a member of the team, e.g.
! one thread only here ... !$OMP parallel ! this is a parallel section ! everything is shared across a team ! of threads with the program replicated ... !$OMP end parallel ! threads joined ! now only one thread again ...
Furthermore, OpenMP provides additional directives for the work sharing of computations within parallel regions, for the synchronization and for the definition of the data environment.
The ADAPTOR compilation system translates an OpenMP program to a program using explict POSIX threads. ADAPTOR is a source-to-source translation and therefore needs an additional Fortran compiler. Additionally, ADAPTOR provides runtime support that is written in C and has to be linked with the compiled Fortran program.
If the ADAPTOR system has been installed with runtime support for PThreads, the compilation of an OpenMP program is started as follows:
adaptor -openmp <prog>.f adaptor -omp -sm <prog>.f
The compiler driver adaptor invokes the source-to-source translation fadapt, the native Fortran compiler (that does not have to support OpenMP), and links the object file with ADAPTOR OpenMP runtime and the PThreads library.
fadapt -omp -sm <prog>.f ifc -auto -O3 <prog>_adp.f -c -o <prog.o> ifc -o <executable> <prog>.o -L$(PHOME) -ladp_sm_pthreads -lpthread