Programming hints


On this page you will find some usefull hints for programming.


* Using the NAG Fortran - lib for Linux 2.0.x with gcc 2.7.x:

The NAG Fortran-library is very usefull for numerical mathematics.

Here you find two examples for including NAG-routines in your C-program. I did it with fllux17d9 and NAGWare_f90-Compiler. The lib libnag.a is located in /usr/local/lib.

You may compile the code with the C-compiler. For linking the program, NAGWare_f90 is required.

If you want to use a routine from the lib, e.g abc123(), you have to call it in the following way in your C-program: abc123_(). The underscore is necessary. You have to take care of the lenght of the types of variables (e.g. DOUBLE PRECISSION <--> double). On calling a NAG-routine you have to use pointers in C! For using the variables (common-blocks) you have to take a look at the man-pages of the routines!

The first example generates random-numbers.
Click here g05dcf.tgz or here g05dcf.c to get the code.

The second example uses the Adams-method for integrating a system of first order ordinary differential equations.
Click here d02cbf.tgz or here d02cbf.c to get the code.



Last Update:

© 1997  Bernhard Seiwald, bse@sbox.tu-graz.ac.at