# 7.10 STOP Statement

The STOP statement terminates program execution before the end of the program unit. It takes the following form:

  STOP [stop-code]
  stop-code
  Is an optional message. It can be either of the following:
  - A scalar character constant of type default character.
  - A string of up to six digits; leading zeros are ignored. (Fortran 95/90 and FORTRAN 77 limit digits to five.)

Effect on OpenVMS Systems

If you specify stop-code, the STOP statement displays the specified message at your terminal, terminates program execution, and returns control to the operating system.

If you do not specify stop-code, no message is displayed.

Effect on Tru64 UNIX and Linux Systems

If you specify stop-code, the STOP statement writes the specified message to the standard error device and terminates program execution. The program returns a status of zero to the operating system.

If you do not specify stop-code, no message is output.

Effect on WNT and W9* Systems

If you specify stop-code, the effect differs depending on its form, as follows:

- If stop-code is specified as a character constant, the STOP statement writes the specified message to the standard error device and terminates program execution. The program returns a status of zero to the operating system.
- If stop-code is specified as a string of digits, the STOP statement writes the following to the standard error device and terminates program execution:

      Return code stop-code

  In QuickWin programs, the following is displayed in a message box:

      Program terminated with Exit Code stop-code

  In both cases, the program returns a status of stop-code to the operating system as an integer.

If you do not specify stop-code, the STOP statement writes the following default message to the standard error device and terminates program execution:

    Stop - Program terminated.

The program returns a status of zero to the operating system.

Examples

The following examples show valid STOP statements:

    STOP 98
    STOP 'END OF RUN'

    DO
      READ *, X, Y
      IF (X> Y) STOP 5555
    END DO

Previous Page Next Page Table of Contents