next up previous contents index
Next: Procedures Up: Control Statements Previous: Computed GO TO Statement

STOP Statement


The STOP statement simply terminates the execution of the program and returns control to the operating system. Its general form is:
STOP ' character constant '
The character constant (which must be a literal and not named constant) is optional: if present its value is ``made available" to the user; usually it the message appears on your terminal. For compatibility with Fortran66 it is possible to use a string of one to five decimal digits instead of the character constant.

Ideally a program should only return control to the operating system from one point, the end of the main program, where the END statement does all that is necessary. In practice, even in the best-planned programs, situations can arise which make it pointless to continue. If these are detected in the main program there is always the option of jumping to the END statement, but within procedures there may be no choice but to use a STOP statement.

Helen Rowlands