		Structured Programming and FLECS

1. Introduction

	It is desirable to reduce the time it takes to design, write,
debug, and modify computer programs. Most of us spend more time than we
like doing this. The purpose of this talk to show you how, within the
confines of Fortran, you can become better, more productive programmers.
However, if you want to gain anything from this talk, you must give
these ideas a fair try.

2. Structured Programming -- A small set of rules to follow when writing
			     programs.
 a. Be clear and simple. Make things obvious. (Following this rule is
    not easy. Fortran creates a bad mind set). Lots of examples to follow.
 b. Top down modular design -- starting with the main program, express your
    algorithm in terms of simpler tasks. Then repeat this until the
    task are trivial to program. Use many small modules. Example of
    CHARMM.
 c. Simplify and clarify the control flow -- avoid GOTO statements.
    Use statements in the language that embody control flow (control 
    constructs). Example of switching function in non-bonded interactions.
    
3. FLECS -- Fortran Language Extended Control Statements -- provides
   a number of control constructs beyond what Fortran provides.
 a. A program which accepts a FLECS program and converts it into an
    equivalent Fortran program. 
 b. A FLECS program consists of arbitrary Fortran statements and FLECS
    control statements. Anything which is not a FLECS control statement
    or a comment is merely copied during the translation process. The
    control constructs get converted into Fortran-66 statements.
 c. Two classes of control constructs -- 1) internal procedures
    2) structured statements. Internal procedures make top down
    design much more practical in Fortran. The structured statements
    clarify the control flow.
 d. Block structuring is supported in FLECS. Very simply, any place
    you can use one statement in FLECS, you can use block of any number
    of statements terminated by a FIN statement.
 e. Internal procedure statements:
    i.   An internal procedure name is a series of at least two symbols
         separated by a hyphen (minus sign).
    ii.  An internal procedure call is just the procedure name all by
         itself on the line.
    iii. An internal procedure is defined using a TO statement. 
         Internal procedure come at the end of a program unit.
 f. Structured Statements:
    i.   IF
    ii.  UNLESS
    iii. WHEN ELSE
    iv.  CONDITIONAL
    v.   SELECT
    vi.  DO
    vii. WHILE
    viii.UNTIL
    ix.  REPEAT WHILE
    x.   REPEAT UNTIL
 g. Caveats: 
    i.   Make sure there is a return, stop, exit, or goto statement before the
         first internal procedure declaration.
    ii.  FLECS statements have to be in upper case. (This may be changed.)
    iii. Some GOTO'S may need a IF (.TRUE.) GOTO ... to avoid a warning
         message from Fortran about no path to a statement.
 h. Example -- ECNTRL from CHARMM
 i. How to use FLECS on the VAX.
    i.   FLECS command, goes from .FLX to .FOR and .FLI. Compile and link
         the .FOR file in the usual manner.
    ii.  BRUCLIB:FLIFIX program to fix listing
    iii. @BRUCLIB:FLCLEAN to clean up.
 j. Portability of the translator -- It's easy, there are several versions
    available, our versions have run under an IBM 360, UNIX, and a CRAY.

References:
 Brian W. Kernighan and P. J. Plauger, The Elements of Programming Style,
McGraw-Hill Book Company, 1978. (available in the Coop)
 Terry Beyer, FLECS User's Manual. (get copies from Bob Bruccoleri)
