FORTRAN Reference Manual

Compiler Directives
FORTRAN Reference Manual528615-001
10-14
CONSULT Compiler Directive
If a consult-item names a procedure that is already defined or referenced as a
FORTRAN subprogram, the source programs description overrides the description
in the file named in the CONSULT directive. If a consult-item does not include
a list of procedure names, the compiler ignores the procedure without displaying a
message. If the procedure is named explicitly in the consult-directive, the
compiler issues an error message and ignores the procedure.
You can use CONSULT and GUARDIAN directives in the same compilation. The
compiler processes them in the order in which it reads them, and does not give
priority to one or the other.
If you want the FORTRAN compiler to consult files named in LIBRARY and
SEARCH directives for calling sequences, you must specify those files in
CONSULT directives, as well as in LIBRARY and SEARCH directives.
One way to create the proper CONSULT consult-item is to start with a TAL
source file that contains the EXTERNAL declarations of a set of procedures. Use
an editor to replace each EXTERNAL with BEGIN END, and compile the modified
source file with TAL. The resulting object file can be used with the CONSULT
directive and is minimal in size. You can also use an object file that contains the
actual procedures.
Calling a procedure whose description is obtained by a CONSULT directive is the
same as calling a procedure whose description is obtained by a GUARDIAN
directive. Write a CALL statement or a function reference in the standard way, but
with these differences:
°
If the procedure is typed (can be called as a function), it must be called as a
function in FORTRAN.
°
If the procedure is VARIABLE or EXTENSIBLE, you can omit parameters in the
same way as in TAL; that is, with successive commas, or by omitting unused
trailing parameters and their commas.
Two difficulties can arise when you use CONSULT directives along with SEARCH
directives:
°
The CONSULT directive does not guarantee that the procedures will be bound.
If you want a particular procedure bound in, you must have a SEARCH
directive that names an object file containing that procedure. If you don’t want
a procedure bound in, you must ensure that no file named in any SEARCH
directive has a procedure of that name.
°
When you want a procedure bound in, be sure the file names appear in the
same order in the SEARCH and CONSULT directives. Otherwise, the compiler
might obtain a procedure’s description from one file, but the Binder might get a
different procedure with the same name from another file.
These difficulties can occur because the SEARCH directive allows you to specify
file names but not individual procedures within those files. If you need more control
over the contents of the object file, use the Binder program after all of your
compilations have completed to arrange the object file exactly as desired.