Civil Engineering Reference
In-Depth Information
.
.
END SUBROUTINE ninety_nine
and compiled.
A “module” would constitute the interface between library and calling program. It
would take the form
MODULE main
INTERFACE
SUBROUTINE one(args1)
(Parameter declarations)
END SUBROUTINE one
SUBROUTINE two(args2)
(Parameter declarations)
.
.
etc.
SUBROUTINE ninety_nine(args99)
(Parameter declarations)
END SUBROUTINE ninety_nine
END INTERFACE
END MODULE main
Thus the interface module would contain only the subroutine “headers”, that is the
subroutine's name, argument list, and declaration of argument types. This is deemed to be
safe because the compiler can check the number and type of arguments in each call (one
of the greatest sources of error in FORTRAN 77).
The libraries would be interfaced by a statement USE main at the beginning of each
test program. For example
PROGRAM test_program1
USE main
.
.
.
END PROGRAM test_program1
However, it is still quite tedious to keep updating two files when making changes to a
library (the library and the interface module). Users with straightforward Fortran 95 libraries
may well prefer to omit the interface stage altogether and just create a module containing
the subroutines themselves. These would then be accessed by USE library_routines
in the example shown below. This still allows the compiler to check the numbers and types
of subroutine arguments when the test programs are compiled. For example
MODULE library_routines
CONTAINS
SUBROUTINE one(args1)
.
.
.
END SUBROUTINE one
SUBROUTINE two(args2)
.
.
etc.
Search WWH ::




Custom Search