Next: , Previous: Programming Environment, Up: Programming Environment

30.2.1 Use of Fortran and FLECS

The main reasons for using Fortran as a base language is its widespread usage among the molecular modeling community and its wide availability. Most hardware manufacturers concentrate their compiler optimization capabilities into Fortran. However, Fortran lacks good control constructs, data structures, and operating system interfaces, so steps have been taken to circumvent these limitations. The control constructs are provided by using FLECS, data structures are provided through either an elaborate storage management scheme (see Storage Management) or by using C, and the operating system interfaces are generally provided using C.

FLECS is a Fortran preprocessor that allows us to use a much more robust set of control constructs than normally provided in Fortran. This allows for much more readable and understandable code than could be obtained via Fortran alone. In addition, the use of FLECS allows the development of new programs much more quickly because much less time must be spent working out the flow of control. It is described in detail in FLECS.

Specifically, FLECS provides a block structured IFTHENELSE clause, a structured iteration clause, WHILE and REPEAT WHILE clause as well as their inverses, CONDITIONAL and SELECT clauses, and internal procedures. The internal procedures are especially valuable because they allow long subroutines to be broken into small pieces while leaving all variables accessible. In addition, one can give very long names to these procedures which makes their purpose far more clear. For example, INTERPRET-COMMAND-AND-BUILD-CLAUSES tells you a lot more than CALL INTCBC or GOTO 285 does.

FLECS operates by translating any FLECS constructs into Fortran. Any non-FLECS constructs are merely copied. The Fortran compiler must be then be invoked to compile the translated code into machine language.

To invoke FLECS, type FLECS file1 file2 .... Any number of files can be translated. The default file extension for FLECS programs is .flx. The Fortran translations will be produced in files whose extension is .f or .for depending on the machine FLECS is executed on. The FLECS listing files appear with extension, .fli.

Concerning the portability of FLECS, FLECS was written in itself. It was designed to be transported and has been modified to use the C preprocessor to encode machine dependencies.

Not all of CONGEN has been written using FLECS, as the preprocessor was not adopted until August 1979. All new code should be written using it, and old code in needed of major modification should use FLECS as well.

Two non-standard feature of most Fortran compilers is routinely used, variable name lengths and memory overlays. Variable names can be any length. There is a programming tool, makeshort which can be found in $CGP, which can be used to translate all long names into short names. (In this day, six character variable names is really quite an anachronism!)

The dynamic storage allocation schemes, see Storage Management, depend on mapping arrays of one type onto arrays of another type. It is necessary that REAL variables occupy the same amount of space as INTEGER variables. Numeric arrays are not mixed with character arrays, which avoids many alignment problems.