Using the IMSL Libraries from Visual Fortran

To use the IMSL libraries, you need to:

  1. Set the necessary IMSL environment variables for your development environment by executing the DFVARS.BAT file (see Using the Compiler and Linker from the Command Line). This sets the INCLUDE path and library (linker) search paths.

    Within the Fortran Command Prompt (command-line window) in the Compaq Visual Fortran program folder, the DFVARS.BAT file is already executed. Within the visual development environment, the equivalent of DFVARS.BAT file (as installed by Visual Fortran) is executed. You can view these directory paths within the visual development environment by:

    1. In the Tools menu, click Options.
    2. Click the Directory tab.
    3. In the drop-down list for Show Directories, select Library files and view the library paths.
    4. In the drop-down list for Show Directories, select Include files and view the include file paths.
    5. Click OK if you have changed any information.

  2. The easiest way to pass IMSL libraries to the Linker is to specify the /imsl compiler option.

    Alternatively, if you wish to explicitly include the IMSL libraries, do the following in the visual development environment:

    1. If not already open, open your Project Workspace (File menu, Open Workspace).
    2. In the Project menu, click on Settings.
    3. Click on the Link tab and add the IMSL library names (explained in Library Naming Conventions) to the Project Options box as follows:
      imsl.lib imsls_err.lib imslmpistub.lib
        
    4. Click OK if you have changed any information.

  3. Make IMSL routines and their interfaces available to your program:

The free-form Fortran 95/90 example program below invokes the function AMACH and the subroutine UMACH from the IMSL Libraries. The AMACH function retrieves real machine constants that define the computer's real arithmetic. A value for positive machine infinity is returned (Infinity). The subprogram UMACH retrieves the output unit number.

!  This free-form example demonstrates how to call
!  IMSL routines from Visual Fortran.
!
! The module numerical_libraries includes the Math and
! Stat libraries; these contain the type declarations
! and interface statements for the library routines.

  PROGRAM SHOWIMSL

  USE NUMERICAL_LIBRARIES
  INTEGER NOUT
  REAL RINFP

! The AMACH function and UMACH subroutine are
! declared in the numerical_libraries module

  CALL UMACH(2,NOUT)
  RINFP = AMACH(7)
  WRITE(NOUT,*) 'REAL POSITIVE MACHINE INFINITY = ',RINFP
  END PROGRAM

For information on compiling and linking with the visual development environment, see Building Programs and Libraries.


Note: IMSL routines are in general not multithread safe. In a multithread environment, you should take care that no two IMSL routines are active at the same time. To insure this, use multithread control techniques. For further information, see Creating Multithread Applications.