The logical IF is the simplest form. It has the following form:
where one-statement is a executable statement which is not another IF, and logical-expression is a logical expression. The execution of this logical IF statement goes as follows:IF (logical-expression) one-statement
REAL :: X, Absolute_X X = ..... Absolute_X = X IF (X < 0.0) Absolute_X = -X WRITE(*,*) 'The absolute value of ', x, & ' is ', Absolute_X
INTEGER :: a, b, Smaller READ(*,*) a, b Smaller = a IF (a > b) Smaller = b Write(*,*) 'The smaller of ', a, ' and ', & b, ' is ', Smaller
INTEGER :: Counter IF (MOD(Counter, 10) == 0) WRITE(*,*)
INTEGER :: a, b, c IF (a < b) IF (b < c) WRITE(*,*) a, b, c