!head('Running the program')
so far much has been said about compiling the program, but nothing about
running it after the compilation (and linkedit) have succeeded. the !fc
compile and linkedit produces a "load module" (or program) in the file 
"a.out". it may be run just by giving its name:
!i('a.out') in this case all inputs (outputs) requested by the program are from (to)
the terminal.
!p usually its desireable to call the program by some other name than
a.out so a command similar to: !i('mv a.out prog') is usually given 
to rename "a.out" to a more suitable name such as "prog". for now, however,
we will assume that the program is left in a.out at least until it has
been tested.
!head('using files with a program')
often it is not sufficient to just read and write on the terminal. in 
this case logical units may be assigned on the "a.out" command to whatever
files are required. note that output files are automatically created and
emptied as required.
!i('a.out 5=data 6=output') will run the program with its unit 5 input
from the file "data" and its unit 6 output to the file "output".
!p the simplest way of directing the output of a program to the line 
printer is:
!i('a.out ... ^ lpr') where "..." is any unit assignments required,
except for those units that should be directed to the line printer.
!p if the output to the line printer should have carriage control
(normally the case), then one could use:
!i('a.out ... ^ asa ^ lpr') where "asa" means that the standard 
fortran carriage control (1=page skip, 0=double space, +=overprint) is
to be used.
!p alternaltively, the logical unit that should have carriage control output
may be assigned to "+"; which automatically will invoke asa. for example:
!i('a.out 6=+ ^ lpr') will run time program and direct the output with 
carriage control to the line printer. this syntax is mainly for compatablity 
with the old FTN compiler. 
!head('assigning files within a program')
if a program uses a large number of files, most of which are unchanged
from run to run it is useful to assign files to logical units from 
within a program. the subroutine "setfil" is used to do this:
!i('CALL SETFIL(unit,''filename '')') where "unit" is an integer logical
unit number, and "filename" is a valid !un file name, terminated by 
a blank.
!head('logical units')
there are 20 logical units available, numbered from 0 to 19.
the compiler will complain if a logical unit number is outside this
range.
!p note that the UNIX system will only allow 15 files to be open at once,
and pre-allocates 3 leaving only 12 possible files that a Fortran program
may have simultaniously open.
!head('Use of Pipes and Filters')
Note: this section is not essential for novice Fortran or UNIX
programmers.
!p it is possible to assign Fortran logical units to pipes that connect
the program to other programs. essentially, any logical unit may be
connected to another command by using an exclamation mark (!51)
as the first character of the file name:
!i('a.out "6=!51asa^lpr"') will assign the output on unit 6 to be
sent to the command "asa^lpr". this command causes the output to be
first translated into ASCII carriage controls, and then sent to
the printer. note that if this assignment is set up via a call
to SETFIL that care must be taken to insure that there are no
blanks in the command (tabs, however, can be used), as this will terminate
the argument to SETFIL.
!head('Appending output to the end of a file')
Note: this section is not essential for novice Fortran or UNIX
programmers.
!p it is sometimes desireable that the output of a Fortran program not be
put into a file by itself, but rather appended onto the end of a file.
this may be done by prefixing the file name with ">". this is analogous
to the shell's redirection of output via ">>"
for example, to append the from unit 8 to the file "a" one would use:
!i('a.out "8=>a"') note that one )u must )u enclose the entire unit
assignment in quotes, or the shell will take the command as if
it were written "a.out 8=  >a" and create the file "a" and send all output
on standard output to "a".
!head('runtime errors')
if a program has an error at run-time a message will be printed of the
form:
!p
Runtime error 104 )l in routine rdata @ 10 )l called from main program @ 5 )l 104  ==> unexpected EOF on input file
!p this means that error number 104 (an unexpected End-Of-File), happened
at statement 10 in subroutine "rdata". it was called from statement 5 in
the main program.
if the "--SL" option was used then the statement numbers would actually 
be the line number in the source file of the statement.
it is recommended that the --SL option be used from terminals if a listing
is not produced. this is because if there are any error diagnostics produced
when the program is running the appropriate line in error can be easily
located by given the source line number to the editor.
 if the "--S" option 
was used then the "@ number" part of the message will be ommitted as no
line numbers will have been saved.
!p if the explanation of an error number is lost it may be obtained by
using the "ferr" command:
!i('FERR 104')
will print the explanation of error 104.
!i('FERR -L 104') will print out a longer explanation of the error 
than is normally given. if the cause of the error is still not clear
ask a data center staff member.
!p it is possible to force a runtime error via the subroutine error:
!i('call error(n)') will report error number "n" in the same format given above.
it is suggested that user program error diagnostics start at 1000.
