Compute Canada

How do I use the NAG Fortran SMP Library?

Please note: The FAQ pages at the HPCVL website are continuously being revised. Some pages might pertain to an older configuration of the system. Please let us know if you encounter problems or inaccuracies, and we will correct the entries.

The Fortran SMP Library is used essentially the same way as the Fortran Library. However, a few additional options have to be included to enable the features compiled into the SMP Library. Since the latter was built by using OpenMP compiler directives, these have to be enabled in the compilation of the calling routines as well, even if they are not used. The library resides in /opt/nag/fss0621dcl/. The following lines are typical for a compilation with the NAG libraries:


f90 -c -dalign -xopenmp -xO3 program.f

Linking (static):

f90 -o program.exe -dalign -xopenmp -xO3 -lsocket -lnsl \
-xlic_lib=sunperf program.o /opt/nag/fsso621dcl/libnagsmp.a

Linking (dynamic):

f90 -o program.exe -dalign -xopenmp -xO3 -lsocket -lnsl -xlic_lib=sunperf program.o \
-Bdynamic -L/opt/nag/fssol21dcl/lib -R/opt/nag/fssol21dcl/lib -lnagsmp

Note that the -dalign option above is necessary to avoid bus errors. The -xopenmp option, and the optimization option -xO3 are necessary to enable and support compiler parallelization, even if no parallelization directives are included in the calling routines. The nsl, socket, and sunperf libraries are necessary only in some cases, but it is recommended to include them in the link list. The f90 compiler must be used for compiling and linking.

The optimization and parallelization options are repeated in the link step to ensure that all necessary information is included in the executable. Some of them might not be necessary, but it is usually better to err on the safe side.

As for the Fortran Library, a large number of example programs are available under/opt/nag/fsso621dcl/examples/source. They should be consulted together with the documentation. The routines are used in exactly the same way as the serial versions in the Fortran Library. For an example, see above.

The number of processors (or more accurately light-weight processes) to be used in a program that uses the NAG Fortran SMP Library is determined by the environment variable OMP_NUM_THREADS. At execution time this variable is set to the number of processors to be used. Note that it is useful to determine the scaling properties of your program with test runs and restrict yourself to a number of processors that lies well within the range of scaling.

setenv OMP_NUM_THREADS 8 (csh, tcsh) OMP_NUM_THREADS=8;
export OMP_NUM_THREADS (ksh, bash)