Statement Purpose

The program statement is used to specify which program unit is the main program, so that the computer knows were to transfer control to when a program execution begins.

Examples and Rules of Use

This is an optional way to designate the starting point (main routine) for a Fortran program. The other method to designate a main routine is to skip the PROGRAM statement altogether and start directly with your USE or IMPLICIT NONE statement. The fact that the PROGRAM statement is optional, can cause you problems. If you forget or accidentally delete a FUNCTION or SUBROUTINE statement, the compiler will interpreted that program unit as a main routine, and you will probably get complaints from the linker about having more than one main routine. Only a single PROGRAM statement can appear in all of the various program units that you might assemble to comprise your program. Wherever the program statement is specified, a name that will identify the main program unit must be typed directly after it. The name you give to a program can be almost anything except the name of a common block, module, subroutine, function, FORTRAN statement or the name of a variable that appears in the main program unit. If the program shares a name with any one of these, the compiler (or linker) will return an error statement if you are lucky or the program's structure will run in some messed up fashion if you are unlucky. With these things in mind, the program statement will appear in a very similar manner in any program you write to the following examples.
		program deflection
		program newton_1

For additional information and examples see

examples: array1.f

Up one level / Home

Written by Jason Wehr: and Maintained by John Mahaffy :