Number Crunching on Bama

There are several mathematics and statistics libraries on Bama for users who are writing their own code. They come from different sources and have different properties. Individual users will have to decide which is right for their application. The libraries all get included in the executable program in the final, linking step. The examples we'll give here all involve Fortran, but calls can be made from C using the appropriate technique for C-Fortran interfacing. To learn more about the C-Fortran interface go to the online documentation for the Sun Workshop: http://www.bama.ua.edu/workshop/fortran/prog_guide

The libraries we have currently are the Sun Performance Library from Sun Microsystems, IMSL from Visual Numerics, and Numerical Recipes.

First a word about "linking" is in order. The Fortran compilers on the Sun will process source code as far along as they are able unless told to stop. This means that once the code is compiled into object code, the compiler will automatically pass the information along to the link editor. It is typical, then, to include the names of the libraries to be linked to in the compilation step. The final, executable program will contain enough information to self-load when it is run by typing its name. This is in contrast to UA1VM where users had to do each step explicitly (compile, link, run). Even though the link command is available as "ld", it is best to link with the compiler. For instance, suppose you have compiled several Fortran 77 programs; a main one, and two containing subroutines. The command would look like this:

f77 main.f sub1.f sub2.f -o main

At the completion of this you would have an executable file called "main" and the object files, main.o, sub1.o, and sub2.o. To make a change to the code in the main routine, the most efficient command to recompile and link the programs would be this:

f77 main.f sub1.o sub2.o

The compiler recognizes that the named subroutine files are already in object code and will pass them along directly with main.o to the linker. To link object code files without recompiling you would type:

f77 main.o sub1.o sub2.o

This behavior is common among all the compilers available on Bama.

Sun Performance Library

This library is included with the Sun compilers. It is optimized for the compiler/computer that is called Bama (a Sun UE 6000 with Sun compilers) and should produce fast-running routines. It is also designed to utilize more than one CPU on multi-processor machines. Bama has 8 CPUs, so this aspect can be used to advantage.

This library is based on a number of standard libraries: LAPACK, LINPACK, BLAS1, BLAS2, BLAS3, FFTPACK, and VFFTPACK. These overlap somewhat with the IMSL libraries but may run faster on Bama due to the optimization for Sun computers. The basic command to link in with this library is:

f77 -dalign myprog.f -xlic_lib=sunperf

where myprog.f is the name of your source code file. This looks different from usual linking syntax (using -xlic_lib instead of -l) due to the Sun Performance Library licensing.

Information on making full use of this library is beyond the scope of this Tipsheet. You should refer to the web documentation at

http://bama.ua.edu/workshop/perflib/perflib_ref

(note that the last part is perflib_ref). Start by reading the material in the "preface."

IMSL

This is a very complete library, licensed from Visual Numerics, Inc. It includes a full suite of mathematics and statistics subroutines that are designed to be efficient and fast. Currently, the routines need to be linked using the Fortran90 compiler. There is a Fortran77 version of the library, but only some routines will compile into F77. It is best to use F90, then.

The Fortran90 routines are written for multi-processor machines, as with the Sun Performance Library, although they are not necessarily optimized for Bama. The current set of manuals for these is kept at the Help Desk, A-203 Gordon Palmer. Online documentation is available at the Visual Numerics web site

http://www.vni.com/products/imsl/alphabetized_functions.html

(Note that there is an underscore "_" between "alphabetized" and "functions"). Interestingly, when you go to the VNI web site and look at examples of how to use the subroutine calls, you end up at a web site at the National Institute of Standards (NIST).

To use the IMSL routines on Bama you must run a command that sets up an environment variable for you. Without this you would have to type a very long string of library names each time you try to recompile. To start using IMSL using the ksh, type:

. imsl (that's dot space imsl)

Csh users should replace the "." with the word "source". You need only type this once each session in which you are going to use IMSL. To compile and link to make an executable called "myprog" you would use the command

f90 myprog.f90 -o myprog $LINK_FNL

Numerical Recipes

The Numerical Recipes library comes from the book "Numerical Recipes, 2 nd Edition", by Press, Teukolsky, Vetterling, and Flannery. This is a varied collection of math and statistics routines that is outlined in the book. That is the best reference if you want to use any of them in your program. The ISBN number for the book is 0-521-43064-X and the publisher is Cambridge University Press.

To link to this library on Bama use this command:

f77 myprog.f -lnum_rec

The "-l" switch gets passed by the compiler to the loader and tells it to go get the library named "num_rec".

 

© 1999, The University of Alabama. The information included here is for the University of Alabama central computing facility as it was configured on the document date. It may or may not apply to other Unix systems.