AN ABRIDGED FORTRAN MANUAL

Introduction

To add remarks, comments, or other annotations, type the letter c or C in column 1, followed by the
annotation   Every line of your annotation must have a c in column 1.

All commands begin in column 7 and may not extend past column 72.

Statement numbers go in columuns 1-5.  You may give any command line a statement number, even
though this line is never addressed in the program by a command.  See Logic Statements below.

Anything in column 6 indicates a continuation from the preceding line.  For example: & or +.

It is suggested that you explain what the program is and the meaning of some of the variable names at
the beginning of the program or where appropriate in the program.

The first executable lines must be for defining storage space in memory for any matrices (indexed or sub-
scripted variables) if you are going to use them, or for changing the integer or real default status of your
variable names.

The last command of your program must be "end"

Real and Integer Variables

By default, all variable beginning with the letters a through h and o through z are real ( also called
floating point), that is, they may have decimal point values.

By default, all variable beginning with i through n are integer, that is, they can not have decimal values.

 EG.:  Integer adat,  Real index.

The variable "adat" is real by default, but the statement "integer adat" converts it to a integer variable.
The variable "index" is integer by default, but the statement "real index" converts it to a real or floating
point variable.

Case

You may use upper or lower case letters for commands and variables.
However, some compilers are case sensitive.  Therefore, for variables, be consistent.  Once you
introduce a variable, continue to write it exactly the same way everywhere in the program, or you
could run into serious problems.
 

Defining an array of memory spaces:

To set up an array of indexed variables such as x(i), use the Dimension
Statement as follows:

Dimension x(20), a(20), b(20),   etc.

The above statement allows you to assign 20 different values for x, a, or b, which must be
indexed in the program.  For example x must be written as x(i) in the program.  One could use
any integer variable for the index such as j, k, l, m, jj, etc.  One may use a specific value for x
by writing, for example,  y=3*x(8).

Operations:

Addition:           y = 4 +x
Subtraction      y= 4- x
Multiplication:  y = 4 * x
Division:           y = 4 / x
Exponentiation    y = 4 ** x    ( x can be negative or a fraction:  y = 4 ** 0.5)
Natural exponentiation  y = exp(x)
Trig :   y = sin(x) etc.,  but x must be in radians
arctan of x:  atan(x)  x in radians
ln x :  alog(x)
sqaure root of x : sqrt(x)
log base 10 of x: alog10(x)

Logic Statements

You could read in 20 values of x from a file by using a "do loop," where x is indexed.  For example:

   Do  100,  i = 1, 20
         read (1,*) x(i)
100  continue

The above would read 20 different values of x into memory from an unformatted (*)  file labeled as 1.
See below how to label a file .   The values of x must be a single column in the file.

Warning:
The statement number 100 is written in columns 3, 4, and 5.   If you wrote 100 in coumns 1, 2, and 3,
it would be read as 10000.

To read values of x from a row in the file, use the command:   read (1,*) x(i), (i=1, 20)

An alternative to a do loop is "do while":

PHI=0.0
DO WHILE (PHI.LT.360.0)
    x=r*cos(PHI/57.3)
    *
    *
    *
    PHI=PHI+5
END DO

Or and "if" statement:

IF (PHI.LT.360)  then
    x=r*cos(PHI/57.3)
    *
    *
    *
   PHI=PHI+5
ELSE
   continue ( or other command lines go here)
ENDIF

The following is an "If" loigic for 2 conditions.  It works for FORTRAN 77 or 90
but not for FORCE 2.2.

IF (Phi.gt.X.or.Phi.eq.X)  then

The possible logics are:

LT
EQ
GT
OR
 

Notes on formatting output or input:

First declare an output/input file which can be imported into WORD or PICO for editing and printing
or read into the program.

open (2, file=' output.dat')

To read the data in the file:

read (2,*) x, y, z

The asterisk means to read the file as is and not according to some specified format.  If you want to
format the data in the file in some specific way then use:

read (2,121) x,y,z

In the above 121 identifies the format statement such as the one given below as 101.  Also see below
for how to format data and set up a format statement.

To write a row of column headings into an output file, such as,

    Index      Var1    Var2    X    DELX   OUTPUT,

Put the following command on a line somewhere before you write the actual numbers to the file,
This needs to be done before a do loop in which the actual data printing is done:

        write (2,101)
  101 format ( 10x,' Index', 8x,'Var1',8x, 'Var2',12x, 'X', 12x,'DELX', 8x,'OUTPUT', / )

The different values of nx (here 10x)  is the number of spaces to skip between headers and this
is determined by trial and error.  The slash skips a line.

A  format statement, like the one above,  describes how the data are or will be formated
or arranged in an input or output file.

To write the data to this file correctly aligned in the columns, use the following output
command in a Do loop after all variables are computed but before any variables are
incremented in the loop:

         write (2,102)  I, Var1, Var2, X, DELX, OUTPUT
  102  format (5x, I5, 2(f10.4,5x), f8.3, 5x, f6.3, 6x, f10.4)

You need to determine the values of nx by trial and error so that all decimal places
are in the same column for each field of data.

"I5" formats the variable I as an integer number (no decimal point) that is less than
5 spaces long.  This allows I to be a value between 1 and 9999.

If more than 1 variable is of the same format, you may lump together the size of the
fields, e.g. f10.4, and the spaces between them, nx, as was done above for Var1 and Var2,
viz., 2(f10.4, 5x).  In the term "f10.4",  f means floating point or a number with decimals,
10 is the size of the field in spaces, and 4 is the number of decimal places in that field.
For example,  when f10.4 is used for the number 502.3245,  the decimal point is always
counted as one of the 10 spaces in the field.  So the total field taken up by the above
number is 8 spaces.  The 2 other unused spaces in the f10 field are before the 5 not after
the last decimal place.   You need to take this into account when deciding what the
values are for nx to align the columns of data under the header of the table.

There is also a format for numbers with exponents.  For example  e10.4 would write the number
502.325 as .5023e+3.  You must count the e+3 as part of the 10 space field as well as a
negarive sign if the number is negative.  E formatting will not put a zero or any other single
digit before the decimal point, which is inconvenient for printing out tables.  for that purpose
it is best to use F formatting except when the numbers are very large or very small.

All results from your program must be professionally formatted in tables as explained
above.

If a table is longer than 1 page, the headers must be placed on each page.

You can control this by setting up a counter and when the value exceeds
a certain number of lines, you skip a page with the command

write (2, 103)
103 format (2x, ////) ,

where the number of slashes is the remaining lines to be skipped at
the bottom of the page + lines to be skipped at top of next page.  This is found by trial
and error.

Setting up a counter within a do loop and use what is called an "If - Else -End" logic
sequence as shown below:

   J=0
   Do 500 i =1, N
        .
        .
        .
       etc.
      write output to file command goes here, followed by:
         J=J+1
         If (J.eq.50) then
            write (2,103)
103 format (2x, ////,  'Table 2 Continued',/)
( the following commands reset s the counter  for the next  page and set s up the printing of the
column headings again )
            J=0
            write (2,104)
104  format
         Else
            continue
         Endif
          .
          .
          etc.

When writing to a file, each time a WRITE command is encountered during execution,
such as in a DO loop, values are written in the file as a new row, in successive order.
Only when you close a file  and then reopen it, or rerun the program, will you begin
writing into the file at row 1.

Writing to the Monitor Screen (symbol *)

Write (*,*)  x,y

The first asterisk means the screen and the 2nd asterisk means write values of x and y
in unformatted mode.  The computer decides which way to best write the numbers

Write (*, 2) x,y
This writes to the screen values of  x and y as specified by format statement no.  2.

The following writes a formated output to the monitor screen for a variable and its name.

Print "('  Var=',f10.3)",Var

This would print on the screen for Var = 40.12345, the following:
  Var=    40.123
Notice that the field is 10 spaces wide and there are only 3 decimal places.

ENDING THE PROGRAM

At the end of a program, you should close each file that you have opened by the following
statement:

Close (2)

This closes file 2.

The last command of your program must be "end"

Library of Math Functions:

ex :  exp(x)

ln x:  alog(x)

sqare root of x:  sqrt(x)

yx:  y**x

log10 x:  alog10(x)

cos x :  cos(x)

sin x : sin(x),    etc. for other trig functions.

arctan x : atan(x)  (the angle x must be in radians, not degrees)

Very large numbers may be entered thusly:   y= 2.567E22, which is the equivalent of  2.567 x 1022.
Or try : y= 2.567 * 1000*1000*1000*1000  and then on the next line write y=y*1000* 1000, etc.