ARCHIVED: On the RDC at IU, how can I use IMSL?
On this page:
- Introduction
- Compiling a Fortran 77 fixed-form program
- Compiling a Fortran 90 free-form program
- Compiling a C program
- Running your compiled program
- Documentation
Introduction
IMSL (International Mathematical Subroutine Library) consists of more than 500 mathematical subroutines that you can use in some programs. On the Research Database Complex (RDC) at Indiana University, Version 5 is available for Fortran 77, Fortran 90, and C.
In order to both compile and run a program that includes IMSL
subroutine calls, IMSL requires that you set a number of environment
variables that point to the library directories and the license file
and set appropriate compiler flags. This process has been simplified
on the RDC through the use of predefined setup scripts. One version of
these scripts exists for csh and tcsh users,
and another for sh, ksh, and
bash shell users.
Compiling a Fortran 77 fixed-form program
Suppose you have a program file, prog1.f, in fixed
Fortran 77 format, which invokes the IMSL library routine TWOMV, as
follows:
To compile the above program, if you use the sh,
ksh, or bash shell, enter:
Note: The above line starts with a period followed by a space.
If you use the csh or tcsh shell, enter:
Then, in any shell, enter:
xlf90 $IMSLF90 -qfixed -o prog1 prog1.fTo optimize performance, you can add the optimization and architecture flags.
Compiling a Fortran 90 free-form program
Suppose you want to compile the following Fortran90 program, named
prog2.f:
! Use files
use rand_gen_int
use show_int
! Declarations
real (kind(1.e0)), parameter:: zero=0.e0
real (kind(1.e0)) x(5)
type (s_options) :: iopti(2)=s_options(0,zero)
character VERSION*48, LICENSE*48, VERML*48
external VERML
! Start the random number generator with a known seed.
iopti(1) = s_options(s_rand_gen_generator_seed,zero)
iopti(2) = s_options(123,zero)
call rand_gen(x, iopt=iopti)
! Verify the version of the library we are running
! by retrieving the version number via verml().
! Verify correct installation of the license number
! by retrieving the customer number via verml().
!
VERSION = VERML(1)
LICENSE = VERML(4)
WRITE(*,*) 'Library version: ', VERSION
WRITE(*,*) 'Customer number: ', LICENSE
! Get the random numbers
call rand_gen(x)
! Output the random numbers
call show(x,text=' X')
! Generate error
iopti(1) = s_options(15,zero)
call rand_gen(x, iopt=iopti)
end
To compile the above program, if you use the sh,
ksh, or bash shell, enter:
Note: The above line starts with a period followed by a space.
If you use the csh or tcsh shell, enter:
Then, in any shell, enter:
xlf90 $IMSLF90 -o prog2 prog2.fCompiling a C program
IMSL Version 5 also supports C programs. Following is a sample
program, named prog3.c:
To compile the above program, if you use the sh,
ksh, or bash shell, enter:
Note: The above line starts with a period followed by a space.
If you use the csh or tcsh shell, enter:
Then, in any shell, enter:
xlc $IMSLC -o prog3 prog3.cAs with Fortran, you can also add the optimization and architecture flags to optimize performance.
Running your compiled program
If your job requires less than 20 minutes of CPU time, you can run the
job interactively on any RDC node. Just use cd to go to
the directory containing the program's executable and enter:
./progname
Replace progname with the name of the executable file.
If the program will require more than 20 minutes of CPU time, you must
submit it to the LoadLeveler batch queueing system. This means you
must create a batch script that sets up the appropriate IMSL
environment variables and then runs the compiled program. Following is
a sample script to run a pre-compiled Fortran serial job if you use
sh, ksh, or bash:
Note: There is a space following the period at the
start of the line following the #@ queue statement.
Following is a sample script to run a pre-compiled serial Fortran 77 or
Fortran 90 job if you use csh or tcsh:
Following is a sample script to run a pre-compiled serial C program if
you use sh, ksh, or bash:
Note: There is a space following the period at the
start of the line following the #@ queue statement.
Following is a sample script to run a pre-compiled serial C program
if you use csh or tcsh:
Documentation
For more information about IMSL, see the IU IMSL web page.




