Invoking The Fortran Preprocessor [ ALLBASE/SQL FORTRAN Application Programming Guide ] MPE/iX 5.0 Documentation
ALLBASE/SQL FORTRAN Application Programming Guide
Invoking The Fortran Preprocessor
The FORTRAN preprocessor can be invoked in either
* Syntax checking mode, or
* Full preprocessing mode
This section describes how to invoke the preprocessor both interactively
and in the background.
Syntax Checking Mode
You use the following command to only check the syntax of the SQL
commands embedded in the source code file.
Syntax
:RUN PSQLFOR.PUB.SYS;INFO="(SYNTAX)"
1. The preprocessor does not access a DBEnvironment when it is run in
this mode.
2. When performing only syntax checking, the preprocessor does not
convert the SQL commands into FORTRAN constructs. Therefore the
modified source code file does not contain any preprocessor
generated calls to ALLBASE/SQL external procedures.
3. The include and installable module files are created, but
incomplete.
Authorization
You do not need ALLBASE/SQL authorization when you use the preprocessor
to only check SQL syntax.
Example
:FILE SQLIN = FOREX2
:RUN PSQLFOR.PUB.SYS; INFO= "(SYNTAX)"
MON, JUL 10, 1989, 4:48 PM
HP36216-02A.E1.16 FORTRAN Preprocessor/3000 ALLBASE/SQL
(C) COPYRIGHT HEWLETT-PACKARD CO. 1982,1983,1984,1985,1986,1987,1988,
1989,1990,1991. ALL RIGHTS RESERVED
Syntax checked.
1 ERRORS 0 WARNINGS
END OF PREPROCESSING.
PROGRAM TERMINATED IN AN ERROR STATE. (CIERR 976)
:EDITOR
HP32201A.07.20 EDIT/3000 TUE, JUN 21, 1991, 2:00 PM
(C) HEWLETT-PACKARD CO. 1990
/T SQLMSG; L ALL UNN
FILE UNNUMBERED
:
SQLIN = FOREX2.SOMEGROUP.SOMEACCT
SELCT PartNumber, PartName, SalesPrice INTO :PartNumber, :PartName,
:SalesPrice :SalesPriceInd FROM PurchDB.Parts WHERE PartNumber =
:PartNumber;
****** ALLBASE/SQL errors. (DBERR 10977)
****** in SQL statement ending in line 290
*** Syntax error. (DBERR 1001)
Syntax checked.
1 ERRORS 0 WARNINGS
END OF PREPROCESSING
The line 290 referenced in SQLMSG is the line in
the source file where the erroneous SQL command ends.
Full Preprocessing Mode
You use the following command to both check the embedded SQL command
syntax and create compilable output files that can be processed by the
FORTRAN compiler. This command also stores a module in the DBEnvironment
named and creates a file containing an installable version of the module.
Syntax
[ {MODULE(ModuleName)}]
[ {OWNER (OwnerName )}]
:RUN PSQLFOR.PUB.SYS; INFO="DBEnvironmentName [({{DROP {PRESERVE}} }]"
[ {{ {REVOKE }} }]
[ {{ } }]
[ {{NODROP |...|) } }]
Parameters
DBEnvironmentName identifies the DBEnvironment in which a module is
to be stored. You may use a backreference for a
file defined in a file for this parameter.
ModuleName Assigns a name to the stored module. Module names
must follow the rules governing ALLBASE/SQL basic
names as described in the ALLBASE/SQL Reference
Manual . If a module name is not specified, the
preprocessor uses the PROGRAM statement name as
the module name.
OwnerName Associates the stored module with a user's log-on
name, a class name, or a group name. You can
specify an owner name for the module if you have
DBA authority in the DBEnvironment where the
module is to be stored. You can also specify a
group as owner if you are a member of the group.
If not specified, the owner name is your log-on
name (USER@ACCOUNT). Any object names in the
source file not qualified with an owner name are
qualified with this OwnerName.
DROP Deletes any module currently stored in the
DBEnvironment by the ModuleName and OwnerName
specified in the command string. If not
specified, any module having these names is not
dropped, and existing RUN authorities for that
module are preserved.
PRESERVE Is specified when the program being preprocessed
already has a stored module and you want to
preserve existing RUN authorities for that module.
If not specified, PRESERVE is assumed. PRESERVE
cannot be specified unless DROP is also specified.
REVOKE Is specified when the program being preprocessed
already has a stored module and you want to revoke
existing RUN authorities for that module. REVOKE
cannot be specified unless DROP is also specified.
NODROP Terminates preprocessing if any module currently
exists in the DBEnvironment with the ModuleName
and OwnerName specified in the INFO string. If
not specified, NODROP is assumed.
Description
1. When the program being preprocessed already has a stored module,
be sure to use the DROP option, or else an error will result.
Also, be sure that no one is currently executing the module when
you invoke the preprocessor. To avoid conflicts, do your
preprocessing in single-user mode, during off hours.
2. The preprocessor starts a DBE session in the DBEnvironment
named in the preprocessor command by issuing a CONNECT TO
'DBEnvironmentName' command. If the autostart flag is OFF, the
DBE session can be initiated only after a START DBE command has
been processed.
3. If the DBEnvironment to be accessed is operating in single-user
mode, preprocessing can occur only when another DBE session for
the DBEnvironment does not exist.
4. When the preprocessor's DBE session begins, ALLBASE/SQL processes
a BEGIN WORK command. When preprocessing is completed, the
preprocessor submits a COMMIT WORK command, and any sections
created are committed to the system catalog. If the preprocessor
detects an error in the source file, it processes a ROLLBACK WORK
command before terminating, and no sections are stored in the
DBEnvironment. Preprocessor warnings do not prevent sections from
being stored.
5. During preprocessing, system catalog pages accessed for embedded
commands are locked. In multiuser mode, other DBE sessions
accessing the same objects must wait, and the potential for a
deadlock exists. Therefore minimize competing transactions when
preprocessing an application program. Refer to the ALLBASE/SQL
Database Administration Guide for information on operations that
lock system catalog pages.
6. For improved runtime performance, use ISQL to submit the UPDATE
STATISTICS command before preprocessing for each table accessed in
a data manipulation command when an index on that table has been
added or dropped and when data in the table is often changed.
7. If you specify an OwnerName or ModuleName in a language other than
NATIVE-3000 (ASCII), be sure that the language you are using is
also the language of the DBEnvironment in which the module will be
stored.
Authorization
To preprocess a program for the first time in this mode, you need CONNECT
or DBA authority in the DBEnvironment the program accesses. After a
stored module exists, you need module OWNER or DBA authority in the
DBEnvironment.
Example
:FILE SQLIN=FOREX2
:RUN PSQLFOR.PUB.SYS;INFO=&
"PartsDBE (MODULE(FOREX2) OWNER(OwnerP@SomeAcct) REVOKE DROP)"
MON, JUL 10, 1991, 4:48 PM
HP36216-02A.E1.16 FORTRAN Preprocessor/3000 ALLBASE/SQL
(C) COPYRIGHT HEWLETT-PACKARD CO. 1982,1983,1984,1985,1986,1987,1988,
1989,1990,1991. ALL RIGHTS RESERVED
0 ERRORS 1 WARNINGS
END OF PREPROCESSING.
END OF PROGRAM
:EDITOR
HP32201A.07.20 EDIT/3000 TUE, JUN 21, 1991, 2:00 PM
(C) HEWLETT-PACKARD CO. 1990
/T SQLMSG; L ALL UNN
FILE UNNUMBERED
MON, JUL 10, 1989, 5:00 PM
.
.
.
SQLIN = FOREX2.SOMEGROUP.SOMEACCT
DBEnvironment = PartsDBE
Module Name = FOREX2
****** SELECT PartNumber, PartName, SalesPrice INTO :PartNumber, :PartName,
:SalesPrice WHERE PartNumber = :PartNumber
****** ALLBASE/SQL warnings. (DBERR 10602) |
****** User SomeUser@SomeAcct does not have SELECT authority on PurchDB.Parts.
(DBERR 2301)
1 Sections stored in DBEnvironment.
0 ERRORS 1 WARNINGS
END OF PROCESSING
/
Using the Preprocessor UDC's
Two UDC's for invoking the FORTRAN preprocessor are provided with
ALLBASE/SQL in the HPSQLUDC.PUB.SYS file:
* PFOR, illustrated in Figure 2-12 , invokes the preprocessor in
full preprocessing mode. You specify the source file name, a
DBEnvironment name, and a name for SQLMSG (if you do not want
preprocessor messages to go to $STDLIST).
:PFOR SourceFileName,DBEnvironment
The PFOR UDC uses the following preprocessor INFO string
parameters:
ModuleName is the name of the source file.
OwnerName is the log-on User@Account.
PRESERVE and DROP are in effect.
* PPFOR, illustrated in Figure 2-13 , invokes the preprocessor in
full preprocessing mode, then invokes the FORTRAN compiler if
preprocessing is successful and the linker if compilation is
successful.
To use this UDC, you specify the source file name, a DBEnvironment
name, and an executable file name. You can specify a name for
SQLMSG if you do not want preprocessor messages to go to $STDLIST:
:PPFOR SourceFileName,DBEnvironment,ExecutableFileName
This UDC uses the following preprocessor INFO string parameters:
ModuleName is the source file name.
OwnerName is the log-on User@Account.
PRESERVE and DROP are in effect.
If you make your own version of the UDC's, do not modify the
record attributes for any of the preprocessor output files. Only
modify the file limit (disc=FileLimit) if required.
NOTE Because the UDC's purge the preprocessor message file, if messages
are sent to $STDLIST an error message appears when you use the
UDC's, but preprocessing continues.
________________________________________________________
| |
| PFOR srcfile,dbefile,msgfile=$stdlist |
| continue |
| setvar _savefence hpmsgfence |
| setvar hpmsgfence 2 |
| continue |
| purge !msgfile |
| purge sqlout |
| purge sqlmod |
| purge sqlvar |
| setvar hpmsgfence _savefence |
| deletevar _savefence |
| file sqlin = !srcfile |
| file sqlmsg = !msgfile; rec=-80,16,f,ascii |
| file sqlout; disc=10000,32; rec=-80,16,f,ascii|
| file sqlmod; disc=1023,10,1; rec=250,,f,binary |
| file sqlvar; disc=2048,32; rec=-80,16,f,ascii|
| continue |
| run psqlfor.pub.sys;info="!dbefile (drop)" |
| reset sqlin |
| reset sqlmsg |
| reset sqlout |
| reset sqlmod |
| reset sqlvar |
________________________________________________________
Figure 2-12. UDC for Preprocessing SQLIN
________________________________________________________
| |
| PPFOR srcfile,dbefile,pgmfile,msgfile=$stdlist |
| continue |
| setvar _savefence hpmsgfence |
| setvar hpmsgfence 2 |
| continue |
| purge !msgfile |
| purge sqlout |
| purge sqlmod |
| purge sqlvar |
| setvar hpmsgfence _savefence |
| deletevar _savefence |
| file sqlin = !srcfile |
| file sqlmsg = !msgfile; rec=-80,16,f,ascii |
| file sqlout; disc=10000,32; rec=-80,16,f,ascii|
| file sqlmod; disc=1023,10,1; rec=250,,f,binary |
| file sqlvar; disc=2048,32; rec=-80,16,f,ascii|
| continue |
| run psqlfor.pub.sys;info="!dbefile (drop)" |
| if jcw <= warn then |
| continue |
| ftnxllk sqlout,!pgmfile,$null |
| endif |
| reset sqlin |
| reset sqlmsg |
| reset sqlout |
| reset sqlmod |
| reset sqlvar |
________________________________________________________
Figure 2-13. UDC for Preprocessing, Compiling, and Preparing SQLIN
The example in Figure 2-14 illustrates the use of PPFOR on an SQLIN
that could be successfully preprocessed, compiled, and linked.
_____________________________________________________________________________
| |
| :PPFOR FOREX2,PARTSDBE,FOREX2R |
| |
| MON, JUL 10, 1989, 3:43 |
| HP36216-02A.03.01 FORTRAN Preprocessor/3000 ALLBASE/SQL|
| (C) COPYRIGHT HEWLETT-PACKARD CO., 1982,1983,1984,1985,1986,1987,1988,|
| 1989,1990,1991. ALL RIGHTS RESERVED |
| |
| SQLIN = FOREX2.SOMEGRP.SOMEACCT |
| DBEnvironment = partsdbe |
| |
| Module Name = FOREX2 |
| 1 Sections stored in DBEnvironment. |
| |
| 0 ERRORS 0 WARNINGS |
| END OF PREPROCESSING. |
| |
| END OF PROGRAM |
| |
| : |
| |
| END OF COMPILE |
| |
| HP Link Editor/XL (HP30315A.04.04) Copyright Hewlett-Packard Co 1986 |
| |
| LinkEd> LINK FROM=$OLDPASS;TO=FOREX2R |
| |
| END OF PROGRAM |
| : |
| |
_____________________________________________________________________________
Figure 2-14. Sample UDC Invocation
If there are compiler errors or warnings, the line number referenced in
the compiler output messages is the FORTRAN statement number in the
compiler output listing. Remember that PPFOR UDC sends the compiler
output listing to $null. Thus to identify the line in error, you must
reinvoke the compiler, sending the compiler listing to an output file:
:BUILD FORLIST;DISC=10000,32;REC=-80,16,F,ASCII
:FTNXL SQLOUT,$OLDPASS,FORLIST
Running the Preprocessor in Job Mode
You can preprocess FORTRAN programs in job mode. Figure 2-15
illustrates a job file that uses the PPFOR UDC to preprocess several
sample programs.
_______________________________________________________________
| |
| !JOB JOANN,MGR.HPDB,FORTRAN;OUTCLASS=,1 |
| !ppfor forp01,PartsDBE,forp01r |
| !ppfor forp01a,PartsDBE,forp01ar |
| !ppfor forp02,PartsDBE,forp02r |
| . |
| . |
| !ppfor for50,PartsDBE,for50r |
| !TELL JOANN,MGR.HPDB; FORTRAN Preprocessing is complete!|
| !EOJ |
| |
_______________________________________________________________
Figure 2-15. Sample Preprocessing Job File
MPE/iX 5.0 Documentation