S E S P

plusFORT - Polyhedron Software Ltd

The Software
Engineering Group

Computational Science & Engineering
CLRC Rutherford Appleton Laboratory


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.

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.

URL: http://www.polyhedron.co.uk/pf/spag.html


Tool Descriptions:
Online Documentation:


SESP Homepage

SEG Homepage