THE COSC1540 FORTRAN SUBSET


This course uses a carefully-chosen subset of the Fortran programming language. In Labs, Assignments, and tests, you may not use any construct or any syntactical form other than those contained in the subset.
= An assignment statement. Its left-hand-side must be a name of a variable, and its right-hand-side must be a value (constant, variable name, or an expression).
call sub(list) Invoke the subroutine sub and exchange with it the values of all parameters appearing in the list
character*n var Allocate n bytes in memory to hold the character (string) value of var. n is a literal constant and can be any positive integer. If this statement appears in a subprogram in which var is a parameter, you can replace n by (*) to indicate that its value is specified in the calling unit.
close (unit = u) Close this unit and de-associate it with its file
do, do while, end do An iteration structure
end Indicate that the preceding program unit (main, subroutine, or function) has ended.
exit Abort the surrounding loop
f format (list) Specify a format whose number is f and which contains the indicated list of values and / or edit descriptors
fun(list) Invoke the function fun sending to it the values of all parameters appearing in the list and receiving from it one value (being its name)
if, else if, else, end if A selection structure
implicit none Specify that all variables must be explicitly declared
integer*n var Allocate n bytes in memory to hold the integer value of var. n is a literal constant and can be 1, 2, or 4
logical*1 var Allocate one byte in memory to hold the logical value of var. This value can be either .true. or .false.
open (unit=u, file='f') Open the file f and associate it with unit number u (an integer)
parameter (var=val) Indicate that var (declared in a previous statement) is a symbolic constant, and that its value will always be val
print*, list Output the list of values on the screen w/o formatting
program prog Indicate the start of the main program whose name is prog
read(a,b) list Read the list of values from device a using the format statement b. If a is *, input is from the keyboard, and if b is *, input is unformatted.
read*, list Read the list of values from the keyboard w/o formatting
real*n var Allocate n bytes in memory to hold the real value of var. n is a literal constant and can be 4 or 8
rewind (unit = u) Reset the logical file pointer of this unit to the first record
subroutine sub(list) Indicate the start of a subroutine whose name is sub.
type function fun(list) Indicate the start of a function of the stated type and name fun
write(a,b) list Output the list of values on device a using the format statement b. If a is *, output is on the screen, and if b is *, output is unformatted.