Intel® Fortran Compiler 17.0 Developer Guide and Reference

STOP and ERROR STOP

Statements: The STOP statement terminates program execution before the end of the program unit. The ERROR STOP statement initiates error termination of execution.

STOP [stop-code]

ERROR STOP [stop-code]

stop-code

(Optional) A message. It can be any of the following:

  • A scalar character constant expression of type default character

  • A non-negative integer constant less than or equal to 2147483647; leading zeros are ignored.

  • A scalar integer constant expression

If stop-code is specified, the STOP or ERROR STOP statement does the following:

If stop-code is not specified, the program is terminated, no message is printed, and a status of zero is returned.

When a program is running on multiple images, a STOP statement on one image does not affect the other images. An ERROR STOP initiates execution termination on all images, which may include flushing of I/O buffers, closing of I/O files, and reporting error status on one or more images.

Effect on Windows* Systems

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

  Program terminated with Exit Code stop-code

If the application has no console window, the stop-code is displayed in a message box.

Effect on Linux* and OS X* Systems

Operating system shells (such as bash, sh, csh, dash, etc.) work with one byte exit status. So, when stop-code is an integer, only the lowest byte is significant. For example, consider the following statement:

  STOP 99999

In this case, the program returns a status equal to 159 because integer 99999 = Z'1869F', and the lowest byte is equal to Z'9F', which equals 159.

Example

The following examples show valid STOP statements:

STOP 98
STOP 'END OF RUN'

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

The following shows another example:

      OPEN(1,FILE='file1.dat', status='OLD', ERR=100)
      . . .
 100  STOP 'ERROR DETECTED!'
      END

See Also