The CASE construct is a replcement for the computed GOTO, but is better structured and does not require the use of statement labels:
SELECT CASE (number) ! NUMBER of type integer CASE (:-1) ! all values below 0 n_sign = -1 CASE (0) ! only 0 n_sign = 0 CASE (1:) ! all values above 0 n_sign = 1 END SELECTEach CASE selector list may contain a list and/or range of integers, character or logical constants, whose values may not overlap within or between selectors:
CASE (1, 2, 7, 10:17, 23)A default is available:
CASE DEFAULTThere is only one evaluation, and only one match.
A simplified but sufficient form of the DO construct is illustrated by
outer: DO inner: DO i = j, k, l ! only integers : IF (...) CYCLE : IF (...) EXIT outer END DO inner END DO outerwhere we note that loops may be named so that the EXIT and CYCLE statements may specify which loop is meant.
Many, but not all, simple loops can be replaced by array expressions and assignments, or by new intrinsic functions. For instance
tot = 0. DO i = m, n tot = tot + a(i) END DObecomes simply
tot = SUM( a(m:n) )