The IF-THEN-END IF form is a simplification of the general IF-THEN-ELSE-END IF form with the ELSE part omitted:
where statements is a sequence of executable statements, and logical-expression is a logical expression. The execution of this IF-THEN-ELSE-END IF statement goes as follows:IF (logical-expression) THEN statements END IF
REAL :: X, Absolute_X X = ..... Absolute_X = X IF (X < 0.0) THEN Absolute_X = -X END IF WRITE(*,*) 'The absolute value of ', x, & ' is ', Absolute_X
INTEGER :: a, b, Smaller READ(*,*) a, b Smaller = a IF (a > b) THEN Smaller = b END IF Write(*,*) 'The smaller of ', a, ' and ', & b, ' is ', Smaller
INTEGER :: Counter IF (MOD(Counter, 10) == 0) THEN WRITE(*,*) END IF
logical-expression | what you want to do when the logical expression is .TRUE. |
nothing is here!!! |