By rchrd on Jun 22, 2007
Here's a new article from Michael Ingrassia, one of the lead developers in the Fortran Compiler team at Sun:
HOW TO CALL A LIBRARY FUNCTION OR SUBROUTINE FROM FORTRAN
The Fortran language, both the standard language adhered to by all vendors and the extended language offered to Sun customers, contains several different models for how to call library functions. Confusion can result if you aren't clear about which model you should use for the particular library function you are calling. In this paper we try to describe the different models and provide examples of what might go wrong.
In general, any function found in a library can be called from Fortran. (Subroutines are rarer; for convenience we'll consistently refer to functions in this article where we should properly say function/subroutine). Here's a recipe for how to do it, which contains several specific recommendations for good coding practices.
To start , gather the following information:
- The name of the function/subroutine
- The correct declaration for the function/subroutine
(sometimes this is provided in a file which must be included into your program)
- The name of the library in which the function is supplied
(not required for intrinsic functions)
Depending on what you find, there are 5 different models determining how to properly call this function:
- It's a standard Fortran intrinsic
- It's a non-standard Fortran intrinsic
- It's a non-intrinsic Fortran run-time library function
- It's a non-intrinsic function not supplied in the Fortran run-time libraries, but callable from Fortran
- It's not a Fortran-callable function
Lets look at each situation in detail.