11.2.2 ASSERT Directive (VAX only)

The ASSERT directive (also available in statement form) provides the compiler with information to improve optimization (particularly if vectorization or automatic decomposition for parallel processing is being performed). The directive can also be used to provide a form of error checking in user applications. ASSERT takes one of the following forms:

cDEC$ ASSERT (log-exp)
      ASSERT (log-exp)
c
Is the letter or character that introduces the directive tag (see Section 11.1).
log-exp
Is a logical expression.

The ASSERT directive tells the compiler that log-exp evaluates as .TRUE. at the location in the program unit where the ASSERT appears.

The compiler adds run-time code to verify the asserted expression if the compiler option CHECK_ASSERTIONS (or OPTIONS/CHECK=ASSERTIONS) is in effect. If the expression evaluates as .FALSE., a run-time error is signaled.

The following is an example of how to use the ASSERT directive for error checking (the program is compiled by using the compiler option CHECK_ASSERTIONS):

CDEC$ ASSERT (ICOUNT .NE. 0)
      IVAL = IVAL / ICOUNT      ! Avoid zero-divide exception

For More Information:


Previous Page Next Page Table of Contents