Using IMSL and NAG FORTRAN Subroutine Libraries

The NAG and IMSL subprograms are public libraries and can be accessed by using the "-l" and "-L" options in the f77 compile command. The -l option specifies the library name and the -L option specifies the directory in which the library resides. On the UNIX systems, the IMSL and NAG are public libraries stored in the /opt/lib directory. For example, if "main.f" calls your subprograms stored in the file "sub.f" as well as other subprograms in the NAG FORTRAN subroutine library, then you can compile and link all the routines by typing
    f77 main.f sub.f -o main.exe -L/opt/lib -lnag
And for calling IMSL routines, the command is
    f77 main.f sub.f -o main.exe -L/opt/lib -lsocket -lnsl -limsl
The options "-lsocket" and "-lnsl" are required only for IMSL.

An alternative to using the "-L" compiler option is using the LD_LIBRARY_PATH environment variable. This is described below.

Using the LD_LIBRARY_PATH Environment Variable

An alternative to using the "-L" option is to use the LD_LIBRARY_PATH environment variable by adding the command
    setenv LD_LIBRARY_PATH /opt/lib:${LD_LIBRARY_PATH}
to your .localenv file. Then, the f77 command is
     f77 main.f sub.f -o main.exe -lnag
and in the case of accessing IMSL routines
    f77 main.f sub.f -o main.exe -lsocket -lnsl -limsl
Rather than typing in this long command you can define the following alias in your .localalias file:
  alias f77imsl 'f77 \!* -o \!^:r.exe  -limsl -lsocket -lnsl'
Then you would type
   f77imsl main.f sub.f
You must be using the current collection of startup files, "dotfiles", for this to work. The files .cshrc, .login, .localenv, and .alias are stored in the /opt/proto directory. Typing
        ~consult/proto/xsetup
will back up your current "dotfiles" and replace them with the /opt/proto versions. This is strongly recommended. Instructions are available on U-Discover!. Select the following entries: Computing & Technology/ Instructions, Tips and Answers/ UNIX/ Configuring Your Account.

                                                                
 *****************************************************************
 *                                                               *
 *                   Correspondence to VS FORTRAN                *
 *                                                               *
 *****************************************************************
 *                                                               *
 *       VS FORTRAN                      UNIX                    *
 *       ==========                      ====                    *
 *                                                               * 
 *                 Accessing NAG Library Routines                *   
 *                 ==============================                *    
 *                                                               *       
 *                                                               *   
 * global txtlib vsf2fort nagvlib                                *
 * fortvs2 main                                                  *        
 * load main (start       f77 main.f -o main.exe -L/opt/lib -lnag* 
 *                         main.exe                              *              
 *                                                               *
 *                         (See text for alternative methods.)   *       
*                                                               *     
*                                                               *    
*                                                               *       
*                 Accessing IMSL Library Routines               *   
*                 ===============================               *    
*                                                               *       
*                                                               *   
* global txtlib vsf2fort imsl1 imsl2                            *
* fortvs2 main                                                  *        
* load main (start        f77 main.f -o main.exe -L/opt/lib     *
*                                       -lsocket -lnsl -limsl   *
*                         main.exe                              *              
*                                                               *
*                         (See text for alternative methods.)   *       
*                                                               *    
*****************************************************************

University of Delaware
Last revised: August 24, 1995