Visible to Intel only — GUID: GUID-E0EAF44A-0BE1-4DB2-95A9-962BCE2F8DD2
Visible to Intel only — GUID: GUID-E0EAF44A-0BE1-4DB2-95A9-962BCE2F8DD2
STOP and ERROR STOP
Statements: The STOP statement initiates normal termination of an image before the execution of an END statement of the main program. The ERROR STOP statement initiates error termination.
STOP [stop-code] [, QUIET = scalar-logical-expr]
ERROR STOP [stop-code] [, QUIET = scalar-logical-expr]
stop-code |
(Optional) A message. It can be any of the following:
|
An ERROR STOP statement can appear in a PURE procedure, a STOP statement cannot appear.
If QUIET= is not specified, or if scalar-logical-expr is false, the STOP or ERROR STOP statement does the following:
If stop-code is specified, writes the specified message to the standard error device.
Writes one or more of the following messages to the standard error device indicating which IEEE floating-point exceptions are signaling if assume fpe-summary is specified:
IEEE_DIVIDE_BY_ZERO is signaling IEEE_INVALID is signaling IEEE_OVERFLOW is signaling IEEE_UNDERFLOW is signaling
STOP initiates normal termination on the image that executes it. ERROR STOP initiates error termination. If stop-code is a character expression, STOP returns a status of zero and ERROR STOP returns a status of non-zero. If stop-code is an integer, a status equal to stop-code is returned for both STOP and ERROR_STOP.
If stop-code is not specified, or if QUIET= is specified and scalar-logical-expr has the value .TRUE., the executing image initiates normal or error termination, and no message is printed; for STOP, a status of zero is returned; for ERROR STOP, a positive status value of 128 is returned
When a program is running on multiple images, a STOP statement on one image does not affect the other images; they can continue to reference and define the coarrays located on the stopped image. 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 macOS Systems
Operating system shells (such as bash, sh, csh, dash, etc.) work with a 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.
The following examples show valid STOP statements:
STOP 98
STOP 'END OF RUN', QUIET=(J.EQ.K)
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