A commonly used method for checking the validity of scientific formulas is to carry the units-of-measurement for each provided quantity through the calculation and seeing if it makes sense at the end. Such checking is often done by hand, but rarely incorporated into programs written for scientific purposes. The goal of this work is to provide a practical tool that is able to partially infer and verify the units-of-measurement provided on physical formulas within large-scale computational science programs written in Fortran. While systems for specifying and checking units-of-measurement in programs have existed for many decades, none see extensive usage in practice. A large amount of scientific software is written in Fortran, and many of these packages are themselves very large pieces of work: millions of lines of code in some cases. Annotating units-of-measurement on relevant formulas within very large bodies of source code is a challenging task in itself, but it can be partially automated. Then, the checking algorithm must also scale to be able to process thousands of Fortran modules in a reasonable amount of time and memory. Part of the Camfort project is intended to provide this sort of units-of-measurement lightweight verification for Fortran programs. The Camfort checker is able to work on each module separately, compiling the relevant information about each into its own binary format that can be re-used whenever one module depends upon another. Fortran functions, subroutines and variables are each assigned a ``prinicipal unit'' that describes their behaviour from the units-of-measurement perspective. Functions that work independently of specific units-of-measurement may be assigned ``polymorphic units'' that uses unit-variables to describe how the function transforms its input units into its output units.
Cornwallis South West,
University of Kent,