plusFORT Version 6

Fortran Code Restructuring

SPAG, the plusFORT restructuring tool, can unscramble spaghetti Fortran 66 code, and convert it to structured Fortran 77. It also converts back and forth between standard Fortran 77, and code with VAX and Fortran 90 extensions such as DO WHILE, ENDDO, CYCLE, EXIT and SELECT CASE.

SPAG does not change the meaning of a program, or even the order in which statements are executed; it does change the way the program logic is written down, making it much easier to understand and maintain. Blocks of code are reordered so that logically related sections are physically close, and jumps in control flow are minimised. SPAG may also replicate small code fragments where this improves the re-structured code. SPAG computes complexity metrics before and after restructuring.

Re-formatting

SPAG contains a powerful code beautifier, with dozens of options controlling spacing, case, labels, indentation, use of CONTINUE etc. You can use SPAG to switch back and forth between the F77 and F90 source forms. But SPAG goes much further:

* SPAG identifies, and optionally removes dead code (statements which could never be executed) and clutter (variables or PARAMETERs which are declared but never used).
* SPAG allows you to switch programs to explicit typing by adding declarations for implicitly defined variables. Explicit typing, which in Fortran is normally enforced using IMPLICIT NONE, allows your compiler to detect errors which might otherwise remain undetected for years.
* SPAG can rewrite your declarations from scratch using either Fortran 77 or Fortran 90 notation.
* SPAG provides a simple and safe method for systematically changing the names of symbols within a program.
* SPAG allows you to specify how upper and lower case should be used to distinguish different types of symbol. For example, local variables may be lower case, PARAMETERs upper case, dummy arguments capitalised etc. (e.g. local , PARAM , Dummyarg, COMmonvar).
* SPAG generates symbol table files which are used by GXCHK, and may be used by user-written applications. For example it would be a simple matter to write a program to check conformance to local variable naming conventions. A detailed description of the symbol table format is supplied.

There are over 100 configuration options which allow you to customise SPAG output to local conventions and requirements.


Global Global Static Analysis

GXCHK is the plusFORT global cross check tool. GXCHK views data usage from a global perspective, and detects errors and anomalies that compilers and other tools miss. Examples are:

* Subprogram argument mismatch or misuse (e.g. constant actual argument is illegally modified by subprogram).
* COMMON variables assigned a value but never used, or used but never assigned a value.
* Globally unused COMMON variables, COMMON blocks, PARAMETERs, & INCLUDE files.
* Inconsistent COMMON block definitions.
* COMMON variable name appears in other contexts (e.g. as a local variable, or in a different COMMON).

An unusual feature of GXCHK is its ability to analyse local and global data together. For example, if a local variable in subprogram A has the same name as a COMMON variable in subprogram B, it could be that the programmer has omitted the relevant COMMON statement from subprogram A. GXCHK, unlike other static analysers spots this problem. GXCHK also produces a call tree, and concise but comprehensive charts showing where and how each symbol is used. Handy aggregated reports are produced for COMMON blocks and INCLUDE files.

Interface specifications for every subprogram, showing calls in and out, dummy arguments, COMMON variables usage etc., can also be produced.

GXCHK operates in a "compile & link" style which allows reports to be updated with minimal source code analysis. AUTOMAKE can be used to automate the process.
Interactive Static Analysis

The GXCHK database can be queried interactively. This allows users instant access to information which is vital to program development and maintenance. For example, a programmer might set up a static analysis query window in a corner of the screen, and use it to find the consequences of a change to a COMMON block.

QMERGE - Version Selection

QMERGE is an unusual program, but it tackles a common problem - how to keep control of programs which exist in a number of different versions. A common application is programs which run on a variety of different machines, and require slight changes to the source code for each one. For example, there may be different file naming conventions, word length, or different ways of accessing the system.

QMERGE allows the user to keep all the code variants within the master version of the source code. It comments and un-comments sections of code, depending on the setting of user-defined logical flags. Unlike a macro pre-processor or a conditional compilation tool, QMERGE does not require that you deviate from ANSI standard FORTRAN, or that you pre-process code before compiling it - the master version is legal FORTRAN and can be compiled directly. QMERGE is needed only when you switch from one version to another.