The simplest Fortran programThe simplest Fortran program is what might be called a "do-nothing" program. It contains all of the required parts of a Fortran program. The program is as follows: PROGRAM MAIN STOP END The program simply starts and stops. It has a beginning (the PROGRAM instruction), and then tells the system to halt execution (STOP). Notice that there is both STOP and END. The distinction is that STOP tells the system to halt the execution of the program, while END identifies the end of your instructions - that is, END will always appear as the last line of a program. Complex programs may have more than one STOP instruction; for example, execution may be halted if an error occurs. A single instruction in Fortran is usually called a statement. Although seemingly trivial, writing and executing this program illustrates some of the basic rules of writing Fortran programs:
Assignment: Type the "do-nothing" program. It is important that it be hand-typed: do not use cut-and-paste. Save it as a file, compile it and run it. Here are some typical ways of compiling and running programs. |