Compute Canada

How do I use the NAG Fortran 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 Library is used by directly linking the static or dynamic versions of the library to the program that uses it. Other libraries should be used in conjunction with it, such as socket or intl. The libraries and auxilliary files reside in /opt/nag/flsol20dal. The following lines are typical for a compilation with the NAG libraries:


f90 -c -dalign -mt program.f

Linking (static):

f90 -o program.exe -dalign -mt -lsocket -lnsl -lintl -xlic_lib=sunperf \
program.o /opt/nag/flsol21dcl/lib/libnag_spl.a

Linking (dynamic):

f90 -o program.exe -dalign -mt -lsocket -lnsl -lintl -xlic_lib=sunperf \
program.o -Bdynamic -R/opt/nag/flsol21dcl/lib -L/opt/nag/flsol21dcl/lib -lnag_spl

Note that the -dalign option is necessary to avoid bus errors. The nsl, intl, and socket libraries are necessary only in some cases, but it is recommended to include them in the link list. The version of the Fortran library used in the above compilation/linking lines makes use of the Sun Performance Library (spl) for optimized execution of basic mathematical operations. It is recommended to use this version on the SunFire cluster of HPCVL. It is also recommended to use the f90 compiler, since it is the one that is supported by Sun.

For the actual usage of the routines in the library, a large number of example programs are available in/opt/nag/flsol21dcl/examples/source. They should be consulted together with the documentation. The routines do not require any header files or special setup, but can be used directly. Routines should be declaredEXTERNAL in most cases. A simple example is

A02ACF divides one complex number x=(a,b) by another y=(c,d) to yield a third z=(e,f)

To use the routine, all that needs to be done is declaring a,b,c,d,e,f as DOUBLE PRECISION and call it.