This document is divided into two sections:
Overview of Essential Lahey Fortran 90. This section
summarizes the Essential Lahey Fortran 90 philosophy and lists the coding practices enforced
by and redundant features kept out of Essential Lahey Fortran 90.
Developing with Essential Lahey Fortran 90.
This section describes the Essential Lahey Fortran 90 development process and how to build applications
using the Essential Lahey Fortran 90 driver.
This document doesn't teach Fortran. You'll need to know Fortran to
use Essential Lahey Fortran 90.
Overview of Essential Lahey Fortran 90
Philosophy of Essential Lahey Fortran 90 - A More Disciplined Fortran
Enforce structured, Fortran-90-standard coding. Remove redundant features.
Keep all the power of the Fortran language.
Stuctured Coding Practice Enforced by Essential Lahey Fortran 90
(what you have to do)
- Fortran 90 free source form required.
- IMPLICIT NONE required.
- INTENT required for all subprogram dummy arguments.
- INTENT(IN) must be specified for function dummy arguments.
- Explicit interfaces required for all procedures.
- PROGRAM statement required.
- If a statement is labeled it must be referenced.
- RESULT clause required on RECURSIVE FUNCTION statement.
- Type declaration statements all use double colon syntax.
- Program unit type and name required on END program unit statement.
- Type name required on END TYPE statement.
- POSITION must be specified in OPEN statement for sequential files.
- CASE DEFAULT must be first or last case when present.
- STOP statement required to end program.
- RETURN statement required to return from subprogram.
- Assumed shape required for array dummy arguments.
Unstructured or Redundant Fortran Features Kept Out of Essential Lahey Fortran 90
(what you can't use)
- ALLOCATABLE, INTENT, POINTER, SAVE, DIMENSION, PARAMETER, and TARGET
statements. Specify these attributes in the type declaration statement
instead.
- INTRINSIC and EXTERNAL statements. Use explicit interfaces instead.
- ASSIGN, Assigned GO TO, Alternate RETURN, CONTINUE, ENTRY, and Computed
GO TO statements. Use structured programming constructs instead.
- INCLUDE files. Use modules instead.
- DATA and BLOCK DATA. Initialize in type declaration statement or assignment
statement instead.
- COMMON blocks. Use modules as global data facility instead.
- EQUIVALENCE. A source of many hard-to-find programming errors.
- DOUBLE PRECISION statement. Declare double-precision REALs with the
REAL statement.
- Statement function statement. Use internal procedures instead.
- PAUSE statement.
- PRINT and READ * statements. Use WRITE and READ (*,*) instead.
- Specific intrinsic functions. Use generics instead.
- Assumed-size arrays. Use assumed-shape arrays.
- DO label. Use DO-END DO.
- Non-INTEGER DO variables and expressions.
- Multiple statements on a line.
- LOGICAL case expression.
- Branch to END IF from outside IF block.
- WHERE Statement. Use WHERE Construct.
- BLANK specifier on OPEN or INQUIRE statement.
- BN, BZ, D, H, P, S, and X edit descriptors. D exponent accepted on
input at runtime.
Return to top of page.
Developing with Essential Lahey Fortran 90
The driver controls compilation, the creation of module libraries, linking,
and the production of 32-bit, protected-mode programs.
In creating 32-bit protected-mode programs, Essential Lahey Fortran 90 makes use of and binds
your programs to the Phar Lap TNT DOS-Extender. The DOS-Extender functions
as a layer between DOS and your application providing access to the extended
memory on your computer.
Running Essential Lahey Fortran 90
To run the driver, type elf90 followed by a list of one or
more file names and optional command-line switches:
elf90 filenames [switches]
As needed, the driver searches for the four tools (ELF90_1.EXE,
386LIB.EXE, 386LINK.EXE, and REBINDB.EXE) first
in the directory the driver is located and then, if not found, on the DOS
path.
Filenames
Depending on the extension(s) of the filename(s) specified, the driver
will invoke the compiler or linker or both. The extension .OBJ
causes the linker to be invoked without first running the compiler.
Note: the extension .MOD is reserved for compiler-generated module
files.
Source Filenames
One or more source filenames may be specified, either by name or using
the DOS wildcards * and ?. Filenames must be separated
by a space.
Example
elf90 *.f90
If the files ONE.F90 and TWO.F90 were in the current
directory, ONE.F90 and TWO.F90 would be compiled and
linked together, and the stub-bound executable file, ONE.EXE,
would be created because the driver found ONE.F90 before TWO.F90
in the current directory.
Source filenames are specified as a complete file name or can be given
without an extension, in which case Essential Lahey Fortran 90 supplies the default extension
.F90.
Object Filenames
The default name for an object file is the same as the source file name.
If a path is specified for the source filename, the same path will be used
for the object file name. If no path is specified, the current directory
will be used.
Output Filenames
The default name for the executable file produced by the driver is based
on the first source or object name encountered on the command line. This
may be overridden by specifying the -EXE switch with a new name.
The default extension for executable files is .EXE.
Switches
The driver and tools recognize one or more letters preceded by a hyphen
(-) as command-line switches. You may not combine switches: for
example, -x and -y may not be entered as -xy.
Case is not significant in switches or their arguments.
Driver Configuration File (ELF90.FIG)
In addition to specifying switches on the command line, you may specify
a default set of compiler and linker switches in the ELF90.FIG
file. When the driver is invoked, the switches in the ELF90.FIG
file are processed before those on the command-line. Command-line switches
override those in the ELF90.FIG file. The driver searches for
ELF90.FIG first in the current directory and then, if not found,
in the directory in which the driver is located.
Command Files
If you have too many switches and files to fit on the command line,
your can place them in a command file. Enter Essential Lahey Fortran 90 command line arguments
in a command file exactly the same manner as on the command line. Command
files may have as many lines as needed. Lines beginning with # are comments.
To process a command file, preface the name of the file with an @ character.
When Essential Lahey Fortran 90 encounters a command line parameter that begins with @, it opens
the file and processes the commands in it.
Example
elf90 @mycmds
In this example, Essential Lahey Fortran 90 reads its commands from the file mycmds.
Command files may be used both with other command-line switches and
other command files. Multiple command files are processed left to right
in the order they are encountered.
Controlling Compilation
During the compilation phase, the driver submits specified source files
to the compiler for compilation. If the -c, compile only, switch is specified,
processing will stop after the compiler runs and modules are created (if
necessary). Otherwise, processing continues with linking and binding.
Errors in Compilation
If the compiler encounters errors, you may receive any of three types
of error messages.
- Abort messages indicate it is not practical to continue compilation.
- Fatal messages indicate the compilation will continue, but no
object file will be generated.
- Warning messages indicate probable programming errors that are
not serious enough to prevent execution.
If no fatal or abort errors are detected by the compiler, the DOS ERRORLEVEL
is set to zero. Fatal errors detected by the compiler (improper syntax,
for example) terminate the compilation process. An object file is not created.
Compiler Switches
You can control compilation by using any of the following option switches.
Compiler switches are not case sensitive.
-[n]c
Suppress Linking
Default: -nc
Specify -c to create object (.OBJ), module (.MOD),
module name-map, or module library files without creating an executable.
-[n]lst
Listing
Default: -nlst
Specify -lst to generate a listing file that contains the source
program, compiler options, date and time of compilation, and any compiler
diagnostics. The compiler outputs one listing file for each source file
specified. By default, listing file names consist of the root of the source
file name plus the extension .lst.
Syntax
-[n]lst [(spec=sval[, spec = sval]
... )]
Where:
spec is w for page width, l for page length,
or f for the listing file name.
For w=sval, the page width specifier, sval is an unsigned integer.
The minimum page width is 60. If not specified, the page width is 128.
For l=sval, the page length specifier, sval is an unsigned integer.
The minimum page length is 20. If not specified, the page length is 57.
The page length specifies the maximum number of lines that will print on
a page. A page length of 0 specifies that all information is appended to
the same listing page with no breaks and no subsequent headers.
For f=sval, the listing file name, sval specifies the listing file
name to use instead of the default. If a file with this name already exists,
it is overwritten. If the file can't be overwritten, the compiler aborts.
The compiler outputs one listing file for each source file specified. If
the user specifies a listing file name and more than one source file (possibly
using wild cards) then the driver diagnoses the error and aborts.
Example
elf90 myprog -lst (w=80, l=57)
creates the listing file myprog.lst, formats it for a width of 80 columns
and a length of 57.
-[n]syn
Syntax Check
Default: -nsyn
Specify -syn to stop processing source files after they have
been parsed for language errors. This switch gives you a way to check quickly
whether your program is syntactically and semantically correct. Any errors
are displayed and written to the listing or cross-reference file(s) if
specified.
-[n]xref
Cross-Reference Listing
Default: -nxref
Specify -xref to generate cross-reference information in the
listing file. If -xref is specified but not -lst, the
listings option, then the cross reference information is output to the
same .lst file but the source is not. By default, cross reference file
names consist of the root of the source file name plus the extension .lst.
Syntax
-[n]xref [(spec=sval[, spec=sval]
... )]
Where:
spec is w for page width, l for page length, or f
for the listing file name.
For w=sval, the page width specifier, sval is an unsigned integer.
The minimum page width is 60. If not specified, the page width is 128.
For l=sval, the page length specifier, sval is an unsigned integer.
The minimum page length is 20. If not specified, the page length is 57.
The page length specifies the maximum number of lines that will print on
a page. A page length of 0 specifies that all information is appended to
the same cross reference page with no breaks and no subsequent headers.
For f=sval, the cross reference listing file name, sval specifies
the cross reference listing file name to use instead of the default. If
a file with this name already exists, it is overwritten. If the file can't
be overwritten, the compiler aborts. The compiler outputs one cross reference
file for each source file specified. If the user specifies a cross reference
file name and more than one source file (possibly using wild cards) then
the driver diagnoses the error and aborts.
When -xref is specified, the listing file contains two additional
blocks of information, the Symbol Cross Reference and the Label Cross Reference.
The symbol block contains a sorted list of variable and procedure names,
the type, the class (array, scalar, function) and context. The label block
lists the occurrences of all labels and states the reference's context.
The symbol and label context is defined by the line number of the reference
and a character representing the following contexts:
d - DO index
= - Assignment
i - input
o - output
p - pointer context (pointer assign, [de]allocate, nullify)
r - procedure argument
s - specification statement
u - usage context
Labels use the following:
Example
elf90 myprog -lst -xref (w=80, l=57, i=y)
creates the cross reference file myprog.lst, formats it for a width
of 80 columns and a length of 57, and output cross reference information
for the source file.
Controlling Module Library Creation
The Phar Lap librarian, 386lib.exe, is only invoked if the
compiler encounters Fortran modules in the source code. For each successfully
compiled module, a module file of the form filename.mod
is created and, if the module contains executable code or variables, modname.obj
is temporarily created. From this filename.obj file, the
driver invokes the librarian to create a filename.lib file
and an object file library containing the compiled module code. In addition,
the file modtable.txt is created or appended and contains the
name of the module. The name of this module library is then passed to the
linker.
Controlling Linking
During this phase, the driver submits object files, object file libraries,
and module libraries to the linker for creation of the stub-bound executable.
Environment Variable
Linker switches optionally can be placed in an environment variable
named 386link.
Example
set 386link=-lib graph90 -nomap
elf90 demo.obj sub.obj
In this example, the linker reads two switches, -lib and -nomap,
from the environment variable, 386link.
Default Filename Extensions
Whether on the command line or in command files, file names are specified
as a complete file name (filename.ext) or can be given without an extension,
in which case the linker supplies a default extension. The table below
lists the default filename extensions:
Default Extensions
File Extension File Type
.obj object file
.lib library file
.map map file
.exe executable file
A complete or partial path may be specified with the file name. The
file path must follow the standard MS-DOS syntax. If no path is specified,
the current default device and the directory are assumed.
Searching Rules
The linker reads individual object files and object module libraries,
resolves references to external symbols, and writes out a single executable
file. The linker also creates a map file containing information about the
segments and public symbols in the program. If an object module or library
was specified on the command line and contains path information, then it
must reside at the location specified. If the path was not specified, Essential Lahey Fortran 90
looks for the files according to the following algorithm:
1. in the current working directory
2. in any directories specified with the -LIBPath switch (note
that -LIBPath searches for library files only, not object modules),
or
3. in any directories specified by the -LIBPath switch included
in the 386LINK environment variable.
Object File Searching Rules
Object modules specified as individual object files are processed in
the order in which they appear on the command line.
Library Searching Rules
The order in which object modules from libraries are processed is not
always obvious. Essential Lahey Fortran 90 applies the following rules when searching object
libraries:
1. Any libraries specified using the -Lib switch are searched
in the order in which they appear in the Essential Lahey Fortran 90 command string before the
default libraries, elf90.lib and dosx.lib. The compiler
writes the Essential Lahey Fortran 90 default library names, elf90.lib and dosx.lib,
into each object file it generates.
2. Each library is searched until all possible external references, including
backward references within the library, are resolved.
3. If necessary, Essential Lahey Fortran 90 recursively scans the list of libraries until all
external references are resolved.
This algorithm is particularly important when two different object modules
in two different libraries each have a public symbol with the same name.
If both object modules are linked, Essential Lahey Fortran 90 signals a duplicate symbol error
because they both have public symbols which are referenced elsewhere in
the program. However, if the only symbol referenced in both object modules
is the duplicate symbol, then only the first object module encountered
is linked and no error message is generated. In this latter case, the object
module which actually gets linked is determined by applying the rules listed
above.
Linker Switches
You can control linking by using any of the switches documented below.
Note that linker switches may be abbreviated as indicated by the uppercase
characters in the switch name. For example, the -LIBPath switch
can be specified as either -libpath or -libp.
Some switches require a number as an argument. By default, all numbers
are assumed to be decimal numbers. A different radix can be specified by
appending a radix specifier to the number. The following table lists the
bases and their radix specifiers:
Base Radix Specifier Example of 32 in base 10
2 B or b 10000b
8 Q or q 40q
10 none 32
16 H or h 20h
The underscore character ("_") can be used in numbers
to make them more readable: 80000000h is the same as 8000_0000h.
-[NO]BANNER
-BANNER displays a 386|LINK copyright message with the 386|LINK
version and serial number. This is the default operation. -NOBANNER
suppresses the 386|LINK copyright message.
Syntax
-Exe
The default output file name is the name of the first object file, with
the .exe extension appended to it. The output file is not automatically
placed in the current directory. By default it is placed in the same directory
as the first object file listed on the command line.
This switch takes a single argument, which is the path and name of the
output file. If no extension is specified, .exe is assumed. If no path
information is specified with the file name, then the output file is placed
in the current directory.
Syntax
filename is the name of the output file (including path if other
than the current directory).
Example
-Lib
The -Lib switch specifies one or more library files. The names
of the library files immediately follow the switch, separated by either
spaces or commas. If no filename extension is specified for a library file,
the linker assumes the extension, .lib.
The -Lib switch may be used multiple times in a single linker
command string. the linker builds a list of the library files and processes
them in the order they were specified on the command line.
Syntax
lib1 and lib2 are one or more library files.
Example
If a library file is specified as an object input file (i.e., the -Lib
switch is not used), the linker includes all of the object modules in the
library rather than only those referenced by other parts of the program.
-LIBPath
The -LIBPath switch allows specification of one or more directories
to be searched for libraries.
Syntax
dir1 and dir2 are one or more directories to be searched.
Example
elf90 main.obj -libpath d:\mylibs -pack
elf90 main.obj -libp d:\mylibs,e:\yourlibs -maxreal ffffh
Directory names specified for -LIBPath must not end with a
"\" or "/" delimiter. The linker will affix the directory
delimiter to the file name being searched for.
-[NO]Map
The linker map file is a text file describing the output load image.
The map file contains the following information:
- command switches specified when the program was linked,
- names of the input object files,
- a list of the segments comprising the program, and
- a list of the public symbols in the program.
By default, the linker produces a map file each time a program is linked.
The default name of the map file is the name of the executable file, with
its extension changed to .map. Any path information specifying
a directory where the executable file is to be placed also applies to the
map file.
The -Map switch renames or relocates the map file. The switch
takes a single argument, which is the path and name of the map file to
be produced. If no file name extension is specified, then a default of
.map is assumed. If no path information is specified in the map
file name, then it is placed in the current directory.
The linker can be prevented from producing a map file with the -NOMap
switch. The switch takes no arguments. The -NOMap switch is useful
to make the linker run faster, since no time is spent writing the map file.
The switch is also a good way to save disk space, because map files can
become quite large.
Syntax
Example
-MAPNames
The -MAPNames switch controls the length of global symbol names
displayed in the map file. By default, segment, group, class, module, and
public symbol names are truncated to 12 characters in the map file. The
switch takes a numeric constant argument which increases the length of
global symbols in the map file to the specified number of characters.
Increasing the symbol name length may cause the default maximum line
width of 80 characters to be exceeded. If this occurs, the linker prints
less information about segments and public symbols. This loss of information
can be prevented by using the -MAPWidth switch.
Syntax
nchars is the length of global symbols in the map file, expressed
as number of characters.
Example
-MAPWidth
The -MAPWidth switch controls the maximum line width in the
program map file. The switch takes a numeric constant argument which is
the new maximum width for lines in the map file.
Syntax
nchars is the maximum line width in the map file, expressed as
number of characters (default = 80).
Example
-MAXReal and -MINReal
-MAXReal specifies the maximum amount of conventional memory
to leave free. -MINReal specifies the minimum. TNT DOS-Extender guarantees
that at least the MINReal memory is left free, and that as much as possible,
up to the MAXReal memory, is left free.
Syntax
nparagraphs is the maximum or minimum number of 16-byte paragraphs
of real-mode memory to leave free.
Example
-PUBList
The -PUBList switch controls the ordering of the list of public
symbols. It has options to control the ordering of public symbols. They
are:
- BYNAME - Sort the list of public symbols which make up the program
alphabetically. This is the default operation of the linker.
- BYVALUE - Sort the list of public symbols in the program by
value. This option is useful when using the map file to find out what routine
or variable resides at a particular memory location.
- BOTH - Produce two listings of the public symbols: one sorted
alphabetically and one sorted by value.
- NONE - Cause the linker not to list the public symbols which
make up the program at all. This option is useful for reducing the size
of the map file.
Syntax
Example
-Stack
The -Stack switch specifies the size of the stack area for
a program. The switch must be followed by a numeric constant that specifies
the number of bytes to be allocated to the stack.
If a stack segment is already present in the program, then the -Stack
switch changes the size of the existing segment. The linker, however, will
only increase the size of the existing stack area. If an attempt is made
to decrease the size of the stack area, the linker issues an error.
If your program runs out of stack at runtime, increase the stack size
with -Stack. Note that some recursive procedures can use very
large amounts of stack.
Syntax
Example
-TwoCase and -OneCase
By default, the linker ignores the case of public symbols that make
up the program being linked. For example, the symbols abc, ABC,
and aBc are equivalent in the linker. The -TwoCase switch
enables case-sensitive processing of user-defined symbols. When this switch
is used, upper- and lower-case versions of the same symbol are considered
to be different.
-OneCase enforces default behavior.
Example
-[NO]WARN and -FULLWARN
The linker detects some conditions that can potentially cause run-time
problems but are not necessarily errors. Warning messages for these conditions
can optionally be generated on the display and in the map file. The linker
supports three warning levels: -WARN, -FULLWARN, and
-NOWARN.
The -WARN switch is the default warning level of the linker.
It enables warning messages for the following conditions:
- There is no initial stack segment in the program.
- A TNT DOS-Extender switch was specified, but the output file is not
an executable file.
-FULLWARN enables additional warning messages for the following
conditions:
- Pieces of a single segment from different object modules having different
segment attributes.
- Inconsistent segment grouping in different object modules. -NOWARN
disables all warning messages.
Example
-[NO]ZUnInit
By default, the linker automatically initializes all data areas that
are not initialized by your Essential Lahey Fortran 90 code to zero when creating the executable
image.
If you do not care if your uninitialized data areas are initialized
to zero, use the -NOZUI switch to make your link time up to 50% shorter.
Controlling Binding
During this last phase, the stub-bound executable is bound to the DOS-Extender
creating a stand-alone, 32-bit protected-mode executable program.
By default, the linker automatically stub-binds your program. When you
run your program from the DOS command line, this stub-loader first starts
the DOS-Extender, which in turn starts your program.
Note: in order to distribute executable files created with Essential Lahey Fortran 90, you
must buy the complete Essential Lahey Fortran 90 product.
Binder Switches
-[N]BIND
Default: -nbind
Specify -bind to instruct the driver to invoke rebindb.exe.
rebindb.exe will make a copy of the DOS-Extender that is bound
into rebindb.exe itself and bind that copy to your program.
Example
In the example, the driver invokes rebindb.exe to create demo.exe,
a fully bound executable program.
Return to top of page.
Return to Lahey home page
|