cDEC$ IF cDEC$ IF DEFINED The IF and IF DEFINED directives specify a conditional compilation construct. IF tests whether a logical expression is .TRUE. or .FALSE.. IF DEFINED tests whether a symbol has been defined. The directive-initiated construct takes the following form: cDEC$ IF (expr) [or cDEC$ IF DEFINED (name)] block [cDEC$ ELSE IF (expr) block]... [cDEC$ ELSE block] cDEC$ ENDIF c Is one of the following: C (or c), !, or *. exp A logical expression that evaluates to .TRUE. or .FALSE.. name Is the name of a symbol to be tested for definition. block Are executable statements that are compiled (or not) depending on the value of logical expressions in the IF directive construct. The IF and IF DEFINED directive constructs end with an ENDIF directive and can contain one or more ELSEIF directives and at most one ELSE directive. If the logical condition within a directive evaluates to .TRUE. at compilation, and all preceding conditions in the IF construct evaluate to .FALSE., then the statements contained in the directive block are compiled. A "name" can be defined with a DEFINE directive, and can optionally be assigned an integer value. If the symbol has been defined, with or without being assigned a value, IF DEFINED (name) evaluates to .TRUE.; otherwise, it evaluates to .FALSE.. If the logical condition in the IF or IF DEFINED directive is .TRUE., statements within the IF or IF DEFINED block are compiled. If the condition is .FALSE., control transfers to the next ELSEIF or ELSE directive, if any. If the logical expression in an ELSEIF directive is .TRUE., statements within the ELSEIF block are compiled. If the expression is .FALSE., control transfers to the next ELSEIF or ELSE directive, if any. If control reaches an ELSE directive because all previous logical conditions in the IF construct evaluated to .FALSE., the statements in an ELSE block are compiled unconditionally. You can use any Fortran logical or relational operator or symbol in the logical expression of the directive. The logical expression can be as complex as you like, but the whole directive must fit on one line. For compatibility, each directive in the construct can begin with the prefix !MS$ instead of cDEC$. Examples: Consider the following: ! When the following code is compiled and run, ! the output depends on whether one of the expressions ! tests .TRUE.; or all test .FALSE. !DEC$ DEFINE flag=3 !DEC$ IF (flag .LT. 2) WRITE (*,*) "This is compiled if flag less than 2." !DEC$ ELSEIF (flag >= 8) WRITE (*,*) "Or this compiled if flag greater than & or equal to 8." !DEC$ ELSE WRITE (*,*) "Or this compiled if all preceding & conditions .FALSE." !DEC$ ENDIF END