Exception occurs in Fortran

This scenario describes the behavior of an application that contains a Fortran and a C++ routine. In this scenario, a C++ main routine invokes a Fortran subroutine. An exception occurs in the Fortran subroutine. Refer to Figure 1 throughout the following discussion.

Figure 1. Stack contents when the exception occurs in Fortran
Stack contents when the exception occurs in Fortran

The actions taken follow the three Language Environment condition handling steps: enablement, condition, and termination imminent.

  1. If an I/O error is detected on a Fortran I/O statement that contains an ERR or IOSTAT specifier, Fortran semantics take precedence. The exception is not signaled to the Language Environment condition handler.
  2. In the enablement step, Fortran treats all exceptions as conditions. Processing continues with the condition handling step.
  3. There is no user-written condition handler on the Fortran stack frame (because CEEHDLR cannot be called from a Fortran routine), and the condition is percolated.
  4. If a user-written condition handler has been registered for the condition (as specified in the C global error table) using CEEHDLR on the C++ stack frame, it is given control. If it issues a resume, with or without moving the resume cursor, the condition handling step ends. Processing continues in the routine to which the resume cursor points.

    In this example, no user-written condition handler is registered for the condition, so the condition is percolated.

  5. If a C signal handler has been registered for the condition, it is given control. If it moves the resume cursor or issues a call to longjmp(), the condition handling step ends. Processing resumes in the routine to which the resume cursor points.

    In this example, no C signal handler is registered for the condition, so the condition is percolated.

  6. If the condition is of severity 0 or 1, Language Environment default actions take place, as described in Table 1.
  7. If the condition is of severity 2 or above, Language Environment default action is to promote the condition to T_I_U (Termination Imminent due to an Unhandled condition) and redrive the stack. Condition handling now enters the termination imminent step.
  8. If on the second pass of the stack no condition handler moves the resume cursor and issues a resume, Language Environment terminates the thread.