ALLBASE/SQL FORTRAN application programs have the same stages of
development as any application program. They originate as
FORTRAN source code files that are subsequently compiled with
the FORTRAN compiler and linked by the system linker to create
an executable program file. The development of ALLBASE/SQL
programs, however, requires that you preprocess those
portions of the program that contain SQL commands before
compilation.
In the case illustrated in Figure 2-1 “Developing a FORTRAN Program”, the ALLBASE/SQL
FORTRAN program consists of one source file and one user include
file. The preprocessor merges any user include file into the
source program, and preprocesses it. The result is a modified
source code file and a preprocessor generated include file. This
preprocessor include file contains all of the definitions of
variables used by any FORTRAN statements in the modified source
code file. These two files are then compiled to produce an
object code module, and linked to produce an executable program
file, in the same manner as any other FORTRAN program.
In other cases, the ALLBASE/SQL application program might
consist of a main program unit and one or more subprogram units
in separate files. In these cases, only source files containing
embedded SQL code need to be preprocessed, as illustrated in
Figure 2-2 “Developing a FORTRAN Program with Subprograms”. However, each program unit which contains SQL
commands must be preprocessed and compiled before the next
program unit is preprocessed. Separately preprocessed program
units that are not immediately compiled will write over each
other's preprocessor created include file and consequently
create an error when compiled. You invoke the FORTRAN
preprocessor and compiler as many times as necessary to create
the desired number of object code modules. The files output by the FORTRAN preprocessor are treated just as
any other compiler input files at compile time.
During preprocessing, the FORTRAN preprocessor actually accesses
the same DBEnvironment to be used by your main program or
subprogram unit at runtime. The preprocessor stores a module in
the DBEnvironment which is executed at runtime. The module is
used at runtime to optimize and validate DBEnvironment
operations.
During any invocation, the FORTRAN preprocessor can access only
one DBEnvironment. Therefore programs that access multiple
DBEnvironments must be divided into multiple subprogram units,
each of which accesses only one DBEnvironment. Program units
that access the same DBEnvironment may be preprocessed and
compiled separately or jointly. The preprocessor stores a
module in each DBEnvironment accessed for each preprocessor
invocation.
You can also create separate subprogram units that all access
the same DBEnvironment. Each subprogram stores multiple modules
in one DBEnvironment. Each module consists of sections with
each section representing one SQL command.
The criteria governing the division of an application program
into subprogram units is very application-dependent. As in the
development of any application program, factors such as program
size, program complexity, expected recompilation frequency, and
number of programmers affect how a program is subdivided. In
the case of ALLBASE/SQL FORTRAN application programs, the only
additional factors are:
All code containing embedded SQL commands must be preprocessed.
The preprocessor can access only one DBEnvironment at a time.
Each separately preprocessed program or subprogram unit that accesses
the same DBEnvironment must have a unique OwnerName.ModuleName. The module name defaults to the program statement or subroutine name
if the user does not provide one. The owner name defaults to the user's login if the user does not provide one.
The preprocessor can process only one file per invocation, although
the file being preprocessed may be comprised of more than one program unit.
Each preprocessed program unit must be compiled before the next
program unit is preprocessed.
User include files cannot contain duplicate host variable type
declarations sections.