8 Use of numerical libraries: NAG
There are many libraries of subroutines performing mathematical and graphics operations. The library you are encouraged to use here is the NAG library, which has an on-line documentation system. One important feature of the NAG library in particular is that all the variables are of double precision type, and all arguments must be declared as such when NAG routines are called. The on-line information is available via the link on the course web page.
When using the NAG library you must tell the linker where to find the library code. This is done by adding some extra information to the f95 command line; e.g. let’s imagine we were compiling and linking (to form an executable program) a simple program in the file ex.f90. The command we need is:
f95 -o ex ex.f90 -lnag
The -lnag tells the linker to search the NAG library file for the code that it needs.
8.1 A simple NAG example
8.2 A non-trivial NAG example: matrix determinant
Use the link on the course web page to bring up the NAG documentation. Find the documentation for the routine F03AAF.
The first page of the documentation appears slightly cryptic:
The note at the beginning draws attention to the bold italicised term real, which you should simply interpret as “double precision” or real(kind(1.0d0)) in all NAG documentation.
One would expect a subroutine which calculates a determinant to need arguments including the array in which the matrix is stored, the size of the matrix, and a variable into which to place the answer. Here there are just a couple extra.
Further examples of F95 programs calling the NAG library can be found in the lecture handout on the Physics of Computational Physics.