IF (block)

Purpose

The block IF statement is the first statement in an IF construct.

Syntax

Read syntax diagramSkip visual syntax diagram
>>-+----------------------+------------------------------------->
   '-IF_construct_name--:-'   

>--IF--(--scalar_logical_expr--)--THEN-------------------------><

IF_construct_name
Is a name that identifies the IF construct.

Rules

The block IF statement evaluates a logical expression and executes at most one of the blocks contained within the IF construct.

If the IF_construct_name is specified, it must appear on the END IF statement, and optionally on any ELSE IF or ELSE statements in the IF construct.

Examples

WHICHC: IF (CMD .EQ. 'RETRY') THEN
     IF (LIMIT .GT. FIVE) THEN          ! Nested IF constructs
         ...
         CALL STOP
     ELSE
         CALL RETRY
     END IF
ELSE IF (CMD .EQ. 'STOP') THEN WHICHC
     CALL STOP
ELSE IF (CMD .EQ. 'ABORT') THEN
     CALL ABORT
ELSE WHICHC
     GO TO 100
END IF WHICHC

Related information



Voice your opinion on getting help information Ask IBM compiler experts a technical question in the IBM XL compilers forum Reach out to us