University Information Technology Services
Research and Academic Computing

A NAG Sample Program

The following is an example of how to compile, link and run a program which invokes the NAG subroutine libraries. This program finds the complex square root, by invoking the NAG library routine A02AAF, as follows:

On the SP systems, Compile with something like:

     xlf a02aaf.f -lnag -o sqrt
(which reads "Run the Fortran compiler, with input in the file named a02aaf.f, using the NAG Libraries, and write the output to a file named sqrt.")

On the Sun E10000:

f77 a02aaf.f -L/libapps/NAG/asliR4/lib -lnag_flsol18da -o sqrt
After compiling, run the output file ["sqrt"], and in response to
     A02AAF Example Program Results
press return once [the first line returned is ignored] and then enter the values of A and B
     3.0    4.0
to obtain the square root of A + B I. For example:
     A02AAF Example Program Results
     
     3.0   4.0
     
     YR    YI    XR       XI
     3.0   4.0   2.0000   1.0000
indicates that the square root of 3 + 4 I (which is 2 + I) has real part 2, and imaginary part 1.