ARCHIVED: On the RDC at IU, how can I use IMSL?

On this page:


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:

PROGRAM PROG1 INTEGER IDO, IPRINT, NROWX, NROWY REAL CONPRM, CONPRV, STAT(25), X(7), Y(9) EXTERNAL TWOMV C DATA X/72., 75., 77., 80., 104., 110., 125./ DATA Y/111.,118., 128.,138.,140.,150.,163.,164.,169./ C IDO=0 NROWX=7 NROWY=9 IPRINT=2 CONPRM=95.0 CONPRV=0.0 CALL TWOMV(IDO,NROWX,X,NROWY,Y,CONPRM,CONPRV,IPRINT,STAT) END

To compile the above program, if you use the sh, ksh, or bash shell, enter:

. /usr/local/bin/imsl.sh

Note: The above line starts with a period followed by a space.

If you use the csh or tcsh shell, enter:

source /usr/local/bin/imsl.csh

Then, in any shell, enter:

xlf90 $IMSLF90 -qfixed -o prog1 prog1.f

To 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:

. /usr/local/bin/imsl.sh

Note: The above line starts with a period followed by a space.

If you use the csh or tcsh shell, enter:

source /usr/local/bin/imsl.csh

Then, in any shell, enter:

xlf90 $IMSLF90 -o prog2 prog2.f

Compiling a C program

IMSL Version 5 also supports C programs. Following is a sample program, named prog3.c:

#include < imsl.h > main () { float rinfp; rinfp = imsl_f_machine(7); printf("Real Positive Machine Infinity = %15.5f\n",rinfp); }

To compile the above program, if you use the sh, ksh, or bash shell, enter:

. /usr/local/bin/imsl.sh

Note: The above line starts with a period followed by a space.

If you use the csh or tcsh shell, enter:

source /usr/local/bin/imsl.csh

Then, in any shell, enter:

xlc $IMSLC -o prog3 prog3.c

As 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:

#@ class = serial #@ initialdir = /N/u/jdoe/Libra/imslprogs #@ output = prog1.out #@ error = prog1.err #@ queue . /usr/local/bin/imsl.sh ./prog1 $IMSLF90

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:

#@ class = serial #@ initialdir = /N/u/jdoe/Libra/imslprogs #@ output = prog1.out #@ error = prog1.err #@ queue source /usr/local/bin/imsl.csh ./prog1 $IMSLF90

Following is a sample script to run a pre-compiled serial C program if you use sh, ksh, or bash:

#@ class = serial #@ initialdir = /N/u/jdoe/Libra/imslprogs #@ output = prog3.out #@ error = prog3.err #@ queue . /usr/local/bin/imsl.sh ./prog3 $IMSLC

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:

#@ class = serial #@ initialdir = /N/u/jdoe/Libra/imslprogs #@ output = prog3.out #@ error = prog3.err #@ queue source /usr/local/bin/imsl.csh ./prog3 $IMSLC

Documentation

For more information about IMSL, see the IU IMSL web page.