robin wrote:
> IMHO the simplest and most important of the conversions are:
> 1. conversion to free form source input.
> 2. wrapping the main program around the subroutines and functions,
> (with the help of the CONTAINs statement).
> This approach requires a minimum of effort, and is unlikely to
> introduce new bugs (but note that any conversion to the modern
> form is likely to find pre-existing bugs)
> The above checks subroutine interfaces and may pick up some
> typos in the original code.
Your second part is likely to introduce errors (hard to find ones
at that) due to host association. Since your old F77 code is likely
not using IMPLICIT NONE, any implicitly declared variables
in your procedures are actually visible in the host. So, if you
tend to use i as a loop index a lot, for example, the i in your
procedures will be the same as the i in your main program - and
the same as the i in all your other procedures. The fortran standard
explicitly states that the variable has the widest possible scope
in such instances.
Even if your main code uses IMPLICIT NONE, the declaration in
the main code will apply to all the internal procedures as well uness
explicitly overridden there. So, if you forget to declare something
in one of your procedures and it happens to have the same name as
something declared in the host (or the same name as something
imported into the host though USE association), there will be no
error reported. This rather changes the semantics of your programs.
Even if you add IMPLICIT NONE to all of your procedures, the
problem in the last paragraph still occurs. IMPLICIT NONE
doesn't help if the "undeclared" symbol is actually declared
in the host.
I've always thought Fortran's host association rules were upside-
down. The scope of a variable should be the narrowest possible
and you should have to explicitly import anything you want to share
with the host. This should be true for both internal procedures
and module procedures. (There were some experiments in the
70's to the effect that such restrictive rules improved productivity.)
--
J. Giles
|