Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference

ID 767251
Date 7/13/2023
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

FAIL IMAGE

Statement: Causes the image that executes it to stop participating in program execution, without initiating termination.

FAIL IMAGE

This statement allows you to simulate image failure and to test and debug image failure recovery in a program, without requiring an actual image failure.

After execution of a FAIL IMAGE statement, no additional statements are executed by the image.

A FAIL IMAGE statement is not an image control statement.

The detection of a failed image may happen at different times in the execution of other images; for more information, see FAILED_IMAGES.

NOTE:

If you use a FAIL IMAGE statement to make an image fail, you should use a STAT= specifier or a STAT argument in all coarray operations that might encounter that failed image if the statement or operation permits, or you should specify either the assume failed_images or standard-semantics compiler option. If you do not use a STAT= specifier, a STAT argument, or specify one of the compiler options, those operations will not check for failed images. They may then try to coordinate with the failed image, waiting for a response from it. The response would never happen and so the application would hang.

Examples

The following example demonstrates using the STAT= specifier to prevent an application hang (see Note above):

SUBROUTINE FAIL_AND_SYNC ( THIS_ONE )
   INTEGER THIS_ONE
   INTEGER MY_STAT
   IF (THIS_IMAGE() .EQ. THIS_ONE) THEN
       FAIL IMAGE
   END IF
   SYNC ALL (STAT=MY_STAT)      ! Would hang without STAT=
END SUBROUTINE FAIL_AND_SYNC

If an image calls the following procedure at regular time intervals, it has a one in ten thousand chance of failure in each time step:

SUBROUTINE RANDOM_FAILURE ()
   REAL RANDOM
   CALL RANDOM_NUMBER (RANDOM)
   IF (RANDOM > 0.9999) FAIL IMAGE
   RETURN
END SUBROUTINE RANDOM_FAILURE

See Also