The END DO, END IF, END SELECT, and END WHERE statements terminate DO (or DO WHILE), IF, CASE, and WHERE constructs, respectively.
+---------------------------------Fortran 95---------------------------------+
The END FORALL statement terminates FORALL constructs.
+-----------------------------End of Fortran 95------------------------------+
Format
>>-+-END DO--+-------------------+--------------+-------------->< | '-DO_construct_name-' | | (1) | +-END FORALL--+-----------------------+------+ | '-FORALL_construct_name-' | +-END IF--+-------------------+--------------+ | '-IF_construct_name-' | +-END SELECT--+---------------------+--------+ | '-CASE_construct_name-' | | (2) | '-END WHERE--+----------------------+--------' '-where_construct_name-'
Notes:
|
+---------------------------------Fortran 95---------------------------------+
+-----------------------------End of Fortran 95------------------------------+
+---------------------------------Fortran 95---------------------------------+
+-----------------------------End of Fortran 95------------------------------+
Rules
If you label the END DO statement, you can use it as the terminal statement of a labeled or unlabeled DO or DO WHILE construct. An END DO statement terminates the innermost DO or DO WHILE construct only. If a DO or DO WHILE statement does not specify a statement label, the terminal statement of the DO or DO WHILE construct must be an END DO statement.
You can branch to an END DO, END IF, or END SELECT statement from within the DO (or DO WHILE), IF, or CASE construct, respectively. An END IF statement can also be branched to from outside of the IF construct.
+---------------------------------Fortran 95---------------------------------+
In Fortran 95, an END IF statement cannot be branched to from outside of the IF construct.
+-----------------------------End of Fortran 95------------------------------+
If you specify a construct name on the statement that begins the construct, the END statement that terminates the construct must have the same construct name. Conversely, if you do not specify a construct name on the statement that begins the construct, you must not specify a construct name on the END statement.
An END WHERE statement must not be a branch target statement.
Examples
INTEGER X(100,100) DECR: DO WHILE (I.GT.0)
·
·
·
IF (J.LT.K) THEN
·
·
·
END IF ! Cannot reference a construct name I=I-1 END DO DECR ! Reference to construct name DECR mandatory END
The following example shows an invalid use of the where_construct_name:
BW: WHERE (A /= 0) B = B + 1 END WHERE EW ! The where_construct_name on the END WHERE statement does not ! match the where_construct_name on the WHERE statement
Related Information