Next: Tools, Previous: Storage Management, Up: Implementation
The following set of rules is designed to help keep CONGEN readable and modifiable.
Each Fortran subroutine should have the following structure:
SUBROUTINE DOTHIS(ARG1,ARG2,....
C
C A comment which describes the purpose of this subroutine.
C This comment is essential because it provides the only
C documentation for nearly all subroutines in CONGEN. The
C program, AUTODOC, can be used to get this comment from all
C subroutines.
C
<Declarations>
C
<Code>
The separation of the code from the declarations by a blank comment aids in reading the code. It becomes obvious where executed code begins.
Each C procedure should be written like this:
dothis(type par1, type par2,...)
/*
* A comment which describes the purpose of the routine. This
* comment must come here so that automatic documentation can
* be implemented (a program similar to AUTODOC is planned.)
*/
{
local declarations
code
}
makefile for CONGEN
for details of the mechanism. Note that not all files can be processed
correctly, such as functions which are declared with structures or
types that are machine dependent. All such functions should be
placed in the file, noproto.c.
F77_INTEGER, F77_REAL, and F77_DOUBLE macros
defined in config.h. Boolean variables should use the
BOOLEAN macro, and Fortran logical variables defined in Fortran
should use the F77_LOGICAL macro. The F77_INTEGER macro
should declare to a long int. If not, you must review calls to
the different scanf and printf functions to ensure correct
typing.
SIGN(1.0,P). If P is DOUBLE_DECL, you will have
a problem because DOUBLE_DECL can map to either REAL or
DOUBLE PRECISION depending on the machine. In such cases, it is
better to use a variable or parameter to store the constant.
DOUBLE PRECISION variables in Fortran must be declared
using
the DOUBLE_DECL macro. This allows CONGEN to switch double precision
variables to single precision on 64-bit computers.
POINTER_DECL macro. On 64 bit architectures,
this macro will expand to 64 bit integers. The equivalent type in C is
given by the F77_POINTER macro.
COORD.x.
HDR, ICNTRL, and TITLE in the first two
records. See any existing binary output subroutines
for the exact format.
ICNTRL array element to indicate
which version of CONGEN wrote the file. Such upward
compatibility must be maintained only across
production versions of CONGEN. In other words, a file
format for the developmental version may be freely
changed until a new version is generated, at which
point all future versions must be able to read it.
CALL DIE. The
subroutine, DIE, provides a traceback or core dump so the program
statements causing the error can be seen.
cgalloc and cgfree should be
used for all variable storage needs.
#include'd into
the program. The common blocks should have comments
describing each variable in the common block so that new
users will know what's there. No directory should be specified for
the #include'd files, so that the -I option to the C preprocessor
can be used to select the directory at will. If a common block is to be shared
between C and Fortran code, use the existing code in the *.h files
to implement the needed name equivalence.
EQUIVALENCE
and DATA statements in Fortran, since all storage referenced by these
statements is allocated statically on the Iris.
scanf functions in C, use only long int's or doubles
for your I/O, and then convert to your type. This avoids the need
to control for machine dependent variations in data lengths.