Exceptions
There is a situation where an explicit deviation from the FORTRAN standard is acceptable, namely array
transfer to underlying subroutines. On the one hand, it is accepted that the dimension number and
size in a current array are different to the number and size in an associated dummy argument array
declarator, while on the other hand it is accepted that arrays are transferred by using the start
address. In both situations explicit use is therefore made of the FORTRAN characteristic that array
transfer means no more than start address transfer.
It goes without saying that this option goes against programming ethics and should therefore be
avoided wherever possible, although its use is inevitable in larger packages. Several reasons are:
- In certain subroutines, the option preferred from a structural point of view is to use an array as
an -dimensional array (e.g. for the matrix structure), whereas in other subroutines an -dimensional
array is preferred (e.g. for the linear solver). If the same dimension were used in both subroutines,
the address calculations would need to be carried out time and again. This has a negative effect on
efficiency and definitely on readability.
- Another reason for array transfer by using start addresses, is that it avoids the number of parameters
in a routine at top level and therefore avoids errors. From a structural point of view, however, it is
preferred to work with several arrays in the underlying subroutines.
It is clear that the above approach is not without its risks and is therefore not allowed, except in
the top layer of subroutines the user needs to handle. All underlying subroutines must be neat and tidy.
In addition, if these options are used, the array bounds need to be checked carefully, because neither
checkers nor debuggers are then able to carry out the checks.
The SWAN team 2022-08-10