Statement Purpose

The stop statement terminates the execution of a program

Examples and Rules of Use

The function of the STOP statement is pretty basic. It just tells the computer to stop execution of the program and return control to the operating system. For beginning programmers, the statement itself should appear as the next to last statement in any program you write. It is not mandatory that the stop statement appear at this point in the program. For instance, often times bigger programs may have stop statements located inside of an if test that tests for an error condition. That way execution can be stopped if a major error is detected. However, it is unlikely that you will need to write a program in this class that requires a stop statement to be located anywhere else in the program but at the end. When appearing at the end of a main program, the only statement you should place after the stop statement is an end statement. Finally, the stop statement will normally appear by itself on a line like the following.
Like the return statement, STOP is not manditory. If the END statement in the main program is reached, it will execute a STOP.

For additional examples see

plot1.f and roof.f

Up one level / Home

Written by Jason Wehr : and Maintained by John Mahaffy :