Here is an example of the use of inherited status within a simple subroutine:
SUBROUTINE ROUTN( VALUE, STATUS ) * Define the SAI__OK global constant. INCLUDE 'SAE_PAR' INTEGER STATUS ... * Check the inherited global status. IF ( STATUS .NE. SAI__OK ) RETURN <application code> END
If an error occurs within the ``application code'' of such a subroutine, then STATUS is set to a value which is not SAI__OK, an error is reported (see below) and the subroutine aborts.
Note that it is often useful to use a status argument and inherited status checking in subroutines which ``cannot fail''. This prevents them executing, possibly producing a run-time error, if their arguments contain rubbish after a previous error. Every piece of software that calls such a routine is then saved from making an extra status check. Furthermore, if the routine is later upgraded it may acquire the potential to fail, and so a status argument will subsequently be required. If a status argument is included initially, existing code which calls the routine will not need to be changed (see further discussion of this).
MERS (MSG and ERR) Message and Error Reporting Systems