Civil Engineering Reference
In-Depth Information
statements at all and just be a list or collection of declarations or data which is globally
accessible to the program unit which invokes it by a USE statement. Its main employment
later in the topic will be to contain either a collection of subroutines and functions which
constitute a “library” or to contain the “interfaces” between such a library and a program
which uses it.
1.9.9 Subprogram libraries
It was stated in the Introduction to this Chapter that what will be presented in Chapter
4 onwards is not a monolithic program but rather a collection of test programs which all
access a common subroutine library which contains about 70 subroutines and functions. In
the simplest implementation of Fortran 95 the library routines could simply be appended
to the main program after a CONTAINS statement as follows:
PROGRAM test_one
.
.
.
.
CONTAINS
SUBROUTINE one(p1,p2,p3)
.
.
.
END SUBROUTINE one
SUBROUTINE two(p4,p5,p6)
.
.
.
END SUBROUTINE two
.
etc.
END PROGRAM test_one
This would be tedious because a sub-library would really be required for each test
program, containing only the needed subroutines. Secondly, compilation of the library
routines with each test program compilation is wasteful.
What is required, therefore, is for the whole subroutine library to be precompiled and
for the test programs to link only to the parts of the library which are needed.
The designers of Fortran 95 seem to have intended this to be done in the following
way. The subroutines would be placed in a file:
SUBROUTINE one(args1)
.
.
.
END SUBROUTINE one
SUBROUTINE two(args2)
.
.
etc.
SUBROUTINE ninety_nine(args99)
.
Search WWH ::




Custom Search