In that vein, it would seem that the best "conversion" might be
encapsulation. If the f77 code works and does not do things that are (or may
be) on the obsolescence list (computed GOTOs, for example) then the best
thing to do IMHO is to encapsulate the f77 into one or more modules and
write an f90 front end.
For example, if the f77 code used static storage at the main line and dummy
arguments to pass that storage up and down the code, a module with
allocatable arrays can be created; the allocated arrays can be passed as
sections to the underlying f77, which need be none the wiser. Changing
locally declared arrays from e.g. fixed to automatic could then be done on
an as-needed basis, i.e. only if there is a need for a failsafe (can't use
automatic then anyway, only allocated! :-) )
The same can be said of the f77 practice of parallel arrays instead of
structures - create the derived types in modules, and pass the subtypes into
the f77 logic.
Another example: if you want to represent a finite element, you can build an
element type which would use pointers to the master storage array that was
created for the f77 implementation. The element type need not have an
element matrix as a component at all! I know implementations where the
element matrices were implemented as three dimensional arrays, with the
first index the element number. In this case, an element type or object
would implement its "element matrix" as an index to that 3-D array (minimal
repercussions, minimal overhead) along with other encapsulated element data
to be passed into the f77 routines as appropriate.
Alvaro Fernandez
On Wed, 4 Feb 2004, Ian Chivers wrote:
> I was teaching last week (a one week fortran 95 course) and both groups
> on the course were involved or about to become involved in converting
> large production codes from 77 to 95.
Ian
It would be nice to know what exactly each group means by "converting from
77 to 95". Since almost all of f77 was included in f95 (and the bits
that were lost are features that practically nobody used and are anyway
supported by all the f95 compilers that I know) in a technical sense
their programs are almost certainly already written in f95. So the
term "converting" could mean any of a number of things, e.g.
- removal of features that were never standard, e.g. REAL*8 etc.
- conversion from fixed-format lines to free-format lines
- conversions from all upper-case to lower-case in statement lines
- addition of INTENT specifications to appropriate procedure arguments
- elimination of most labels, e.g. change labelled-DO to DO with END DO
- conversions from free-standing subprogram units to module procedures
- conversion of common blocks to storage in a module
- conversion of static arrays to automatic, allocatable or pointer arrays
- and so on.
--
Clive Page,
Dept of Physics & Astronomy,
University of Leicester, U.K.
|