FTN - compile, load, ranedit, and/or run Fortran program.

Syntax:

ftn infile [infile]* [option]* [runtime-file]*
(+|-)BCd (-)             (+|-)Clear (-)
(+|-)FDeBug (-)          (+|-)Formatted (+)
(+|-)Go (+)              (+|-)Include (+)
(+|-)lineNumbers (-)     (+|-)ListIng (-)
(+|-)Load (+)            (+|-)LoadBstar (-)
(+|-)LstOu (-)           (+|-)Map (-)
(+|-)Optimize (-)        (+|-)Tables (+)
(+|-)Warning (+)         (+|-)Xref (-)
(+|-)Zdebug (-)
nn<[filename]            nn>[filename]
Hstar=filename (.h)      Library=filename
LoaderMemory=number (10) MeMory=number (32)
Name=name (object)       Object=filename
TEST=filename            Time=number
Update=filename

Examples:

ftn *
ftn srcpart1 srcpart2 01</myfile 02>02 10<
ftn /subra up=tlib +clear

Options:

infile
is a filename or set of filenames separated by blanks. Normally, an "infile" contains either Fortran source to be compiled or Fortran object decks to be passed to the loader. However, if there is only one "infile" and it is random, FTN assumes the file is a Fortran load module, and therefore executes the file.
+BCd
means the program is to run in the BCD environment. The default is ASCII.
+Clear
is used in conjunction with the Update= option to tell Ranedit to clear/initialize the random library.
+FDeBug
calls FDEBUG on program startup.
-Formatted
indicates that the source is in free format (batch NFORM option).
-Go
does not execute the program after compiling it.
Hstar=filename
writes the loaded program into the specified H* file. If you omit this option, FTN writes the loaded program into a file called ".h".
-Include
does not look for command options embedded in source files.
Library=filename
specifies the name of a random library to be searched for subroutines. FTN searches through this library before searching for the subroutines in the system library. Libraries are searched in the order that the Library= options are processed by the command scanner (first from the source file, then in the order specified on the command line).
+LoadBstar
loads from the "b*" object decks file, without having to recompile. This is primarily intended for the case where you omit a library name and consequently get loader errors. +LoadBstar lets you reload, specifying the library, without having to recompile the program.
LoaderMemory=number
specifies how many 1024 words blocks of memory to obtain for the TSS loader. The default is 10. You need to use this option if the loader memory faults when trying to load a subprogram or common block that is very large.
+lineNumbers
says that the input file has build mode line numbers, and the program is free format. If a line has no line number but does have a statement number, the statement number must be preceded by at least one blank (so it does not get taken as a line number).
+ListIng
turns on the LSTIN option to generate a source listing. This cannot be used with Update=.
+LstOu
turns on the LSTOU option to create a listing of the machine language code generated. This cannot be used with Update=.
+Map
tells the TSS loader to generate its rudimentary load map, which is directed to the terminal.
MeMory=number
sets the compiler memory size to "number" K words. The default is 32K words.
-Tables
does not generate special debug symbol tables.
-Load
does not make a load module. If you use this option, FTN doesn't call the loader.
Object=filename
writes the object files into "filename".
+Optimize
turns on the optimizer.
Name=name
specifies the name to be used for the SAVE option on the $OPTION card. The default name is OBJECT.
Update=filename
places the object deck into the named random library.
TEST=filename
indicates that the specified file contains a test version of the Fortran compiler. FTN calls this compiler instead of the usual Fortran compiler.
Time=number
sets processor time limit in seconds for execution. The default is no limit.
-Warning
does not generate warning messages.
+Xref
generates a cross-reference in the compiler's listing file. This cannot be used with Update=.
+Zdebug
leaves all files in the AFT.
runtime-files
take the form "nn>[filename]" or "nn<[filename]". For full details, see below.

Description:

FTN is normally used to compile and run Fortran programs. You can also use it to restart a program without having to recompile. Since FTN uses the DRL TASK interface, compilation takes place in batch but loading and execution take place in TSS. To rerun your program without recompiling it, specify the name of the load module rather than the source files on the command line.

By default, the load module is written to a file named ".h". You can specify a different output file with the Hstar= option.

The sections that follow discuss how to specify run-time files, how to include command options in a source file, and how to handle loader considerations.

Source Code Format:

The default compilation options assume that your source program is in fixed format, i.e. it follows the usual Fortran rules: statement number columns 1-5, continuation marker column 6, statements columns 7-72, ignore column 73 and on, and comments are indicated by a "c" in column 1.

There are two other formats accepted by the Fortran compiler:

  1. The -Formatted option indicates Unnumbered Free Format. In this mode, a Fortran statement can start anywhere between columns 1 and 72. A continuation is indicated with an ampersand ("&") as the first non-blank character on a line. A comment may be indicated by a "*" as the first non-blank character. The compiler still ignores everything after column 72.
  2. The +lineNumber option indicates Line-Number Free Format. This is similar to Unnumbered Free Format, except that each line must begin with a line number. This is useful for source files that were created with build mode. There is no restriction on the length of a line; as a result, column 72 is not significant. Fortran column 1 is taken to be the first position after the line number. You will need at least one space between the line number and any Fortran statement number.

In both free format modes, beware of starting a "call", "character", or "common" statement in column 1, since the compiler sees a "c" in column 1 and treats the statement as a comment. This also applies to assignment statements whose variables begin with "c".

Run-Time Files:

FTN lets you associate an I/O unit in your program with an actual file. You do this using a run-time file specifier of the form

nn<[filename]
    or
nn>[filename]

Each specifier may be used for one of three purposes:

A specifier containing a "<" character is for reading only. A specifier containing a ">" character is for reading or writing.

When a program contains a statement like

read(1,100)a,b

Fortran I/O attempts to read from file "01" in the AFT. The file associated with the unit must be in the AFT with an aftname that is the same as the file code, expressed as two digits. If it is not there, the I/O package calls ACCESS so you can access it. FTN lets you do this ahead of time.

Suppose you wanted unit 01 to read from your file "data1". You would do this by including

01</data1

on the command line. In response to this, FTN accesses the file "/data1" under the alternate name of "01". As long as you do not remove "01" from the AFT during the session, you do not have to specify this again, because FTN does not remove run-time files from the AFT. Thus, a basic run-time file specifier consists of a two digit unit number (in the range 01 to 44), a "<" or ">" character, and a file name.

As already noted you must use ">" rather than "<" if your program needs to write on the file at any time. In this case, if the file does not already exist it is be created as either temporary or permanent, according to the usual conventions for implicit file creation.

For example, suppose you wish the output generated by unit 02 of your program to be directed to a temporary file called "02". You would specify

02>02

on the command line. Again, as long as you do not deaccess the file, you need only specify this once during the session.

In Fortran I/O, units 05, 06, 41, and 42 are associated with the terminal by default, while all other units are associated with a disk file. Unit 41 is used by a READ statement which has no unit number. Unit 42 is used by the PRINT statement.

To make a terminal-oriented unit read from a file, you must use a specifier in your FTN command. For instance, to send output on unit 06 to a file, you would say

06>/out1

which would first create "/out1" if necessary, then access "out1" under the alternate name of "06", then modify the load module so that Fortran run-time initialization is aware of the deviation from the default. IMPORTANT NOTE: If you redirect 06 into a permanent file, you will not be able to look at the file until you issue the TSS command

remo 06

The reason is that the file is incorrectly positioned for reading as long as it stays in the AFT, so you have to remove it from the AFT before you can read it.

For Fortran I/O to read from the terminal instead of a disk file, you just omit the file name altogether, as in

10<

This specifies that unit 10 is associated with the terminal instead of a disk file. When associating a unit with the terminal, you may use either ">" or "<".

There is one nasty glitch in all this. If the file name you specify is that of a temporary file, the name must be the same as the unit with which the file is to be associated. If it is not, FTN tells you that you must use the RENAME command yourself to change the name of the file. This is necessary because you cannot have an alternate name for a temporary file.

Listings:

The listing produced by the +ListIng option is left in your AFT with the name "fc*p*". This listing is in Media3 format, fixed length BCD. If you wish to list this on the printer, simply use SLIST, as in

slist fc*p*

If you read "fc*p*" into FRED, you find that each line ends with the cryptic notation "!10000". This arises because FRED is not fully at home with Media3 files. To eliminate this odd glitch, you might use the L command to list "fc*p*" into another file (thereby performing BCD to ASCII conversion) and then read this converted file into FRED, as in

l fc*p* >temp
fred r temp

Command Options in Source Files:

A source file may specify additional FTN command options on a line that begins with "*!". The "*" causes the line to be taken as a comment by the compiler, while the "!" causes the line to be scanned by FTN. Such a line may of course have a line number, but the "!" must always be followed by at least one blank. There may be more than one such special comment line, but all the lines must appear at the very beginning of the file, as in

*! +form +optz
*! -linenum
      print,"hi there"
      stop
      end

If FTN discovers a source file line of this form, FTN displays the line on the terminal. You can tell FTN not to scan for such lines by using the -Include option on the FTN command line.

Options found in source files are processed in the order they are displayed on the terminal. Options on the command line (other than source or object file names) are processed last, so that you may use the command line to override options from the source files. For instance, if a numeric or string-valued option like Object=filename is given more than once, FTN uses the last argument processed.

Loader Considerations:

Normally when you compile a program, FTN assumes that you want the program loaded and executed. However, if you ask for an object deck or a Ranedit into a random library, FTN only calls the loader if you also specify an option like Hstar= that applies directly to the loader. We recommend that you do not specify loader options with the Update= option; in future releases, this may be regarded as an error.

There may be times when a compilation works fine but you find you must recompile, perhaps because you omitted a library name in the option list or because you omitted some loader option. You can avoid recompiling the program again by using the +LoadBstar option instead of the source file specification in your FTN command. This reperforms the load step using the object decks generated by the most recent compilation.

Files Used:

b*, j*, c*, l*, *l

fc*r*, fc*sc, fc*i*, fc*p*, fc*s*, fc**1

cmdlib/etc/qstar cmdlib/etc/nullgeload

.h

See Also:

expl ranedit command

expl rename

Copyright © 1996, Thinkage Ltd.