HINTS - useful facts about Fortran in TSS.

A Few Facts:

When Fortran source is submitted from TSS, the compiler expects each line to be preceded by a line number (one to seven digits) as is supplied when using "auto" in build mode. Your file need not have line numbers (see below), but if your program is "formatted fortran" (statement numbers in columns 1-5, continuation in column 6, etc.), you should use the "+Form" option in the FTN command.

Continuation is indicated by an "&" as the first non-blank character after the line number in a continued line. Comments are designated by a "*" as the first non-blank character after the line number.

FTN options can be placed on the first line of the file in the following format:

0010*! options
    or
*! ....

There may not be any space separating the line number and the "*". You must type this in yourself, instead of using auto. (You could use autox.)

The maximum allowable unit number for read/write is 43.

You can place two or more statements on a line if you separate them by semicolons.

FRED users note that you do not have to have line numbers in your file. You must make sure that all statement labels are indented at least one space or they will be taken as line numbers. If you use the "-lineNumber" (NLNO in batch) option, this is not a problem. Also, indent your CALL statements one space or they will be taken as comments.

Default Unit Numbers:

For read and write statements, unit 05 is defined for reading, unit 06 for printing, and unit 07 for punching. Under TSS all of these go to/from the terminal. The read without unit number uses unit 41, the print statement uses unit 42 and the punch statement uses unit 43.

Why Your Program Faults:

Fortran supplies no run-time range-checking of array references. It is quite easy for a program to die of "op code fault", "memory fault", etc. because your program scribbled data in the wrong place. Check your subscript usage carefully. If you get the message "fdebug called from wrapup", you will find yourself inside an interactive debugger named FDS. Hit carriage return once to get a traceback showing where your program was executing when it died. You can get out of FDS (the ? prompt) by typing DONE. It is well worth your time to learn how to use the FDS debugger. It is easy to use, and saves you hours of recompiling. See "explain FDS, and explain FORT LIB FDEBUG".

FORTRAN vs. WATFIV:

Integer and integer*2 are identical. Logical, logical*1, etc. are identical. Character variables differ. The default number of characters is one in WATFIV, but eight in FORTRAN. A character A*1(4) and B*4 cannot be equivalenced in FORTRAN as they can in WATFIV. We say more about character variables below.

Free field output in WATFIV looks like

write(06,*) list

but in FORTRAN it looks like

  write(06,8) list
8 format(V)

Core-to-core I/O in WATFIV and FORTRAN differ.

WATFIV:  write(cv,f) list
FORTRAN: encode(av,f) list

In the above, "cv" is a character variable, "av" a character scalar or any type array and "f" a format item. To do a core-to-core read in FORTRAN, use decode instead of encode.

FORTRAN Character Variables:

Character variables, including elements of character arrays, all start on word boundaries. A word is 36 bits; there are four ASCII or six BCD characters per word. It is important to keep these facts in mind when using equivalence statements, treating characters as integers, etc. The default length is eight (two words). In TSS, unless you specify the "+BCd" option of the FTN command, all characters are generated as ASCII.

The following examples show how character data is aligned in memory. A "\" is used to denote a word boundary. Assume the following declarations and assignments.

character a*1(4), b*4(4), c*2(4)
a(1) = 'w'; a(2) = 'x'; a(3) = 'y'; a(4) = 'z'
b(1) = 'wxyz'
c(1) = 'wx'; c(2) = 'yz'

Memory alignment appears as

a - \w   \x   \y   \z   \
b - \wxyz\    \    \    \
c - \wx  \yz  \    \    \

You can use the FLD function to manipulate character or bit data. The format of this built-in function is

i = fld( start, num, var)

where "start" is the starting bit position in variable "var" (the first bit is referenced as zero); "num" is the number of bits; and "var" is the variable name. The bits specified by start and num are transferred to the integer "i", right-aligned, with the remainder of "i" set to zeroes. "start" can range from 0 to 35. "num" may range from 1 to 36.

Copyright © 1996, Thinkage Ltd.