The BLOCK construct defines an executable block that can contain declarations.
To terminate execution of a BLOCK construct, you can use an EXIT statement. To branch out of a BLOCK construct, you can use a GOTO (unconditional) statement.
A local variable of a BLOCK construct within a pure subprogram cannot have the SAVE attribute.
COMMON, EQUIVALENCE, IMPLICIT, INTENT, NAMELIST, OPTIONAL, statement function, and VALUE statements are not allowed in the specification part of the BLOCK construct.
A common block name cannot be specified in a saved entity list in the BLOCK construct.
You can transfer control within a BLOCK construct, or from inside to outside of a BLOCK construct. You can transfer control from outside to inside of a BLOCK construct only when the control is returned from a procedure call inside the BLOCK construct.
PROGRAM foo
INTEGER :: a
add1 : BLOCK
INTEGER :: res1
res1 = a + 1
! The BLOCK statement has no BLOCK_construct_name
BLOCK
INTEGER :: res2
res2 = res1 + 1
END BLOCK
! The END BLOCK statement must have the same BLOCK construct name 'add1'
END BLOCK add1
END PROGRAM foo
PROGRAM main
INTEGER :: a
a = 5
BLOCK
INTEGER :: b
b = a + 2
! Program control is returned from a procedure call inside the BLOCK construct
CALL Sub(b)
END BLOCK
END PROGRAM main
SUBROUTINE Sub(B)
INTEGER :: b
b = b * b
PRINT *, b
END SUBROUTINE Sub
PROGRAM foo
BLOCK
INTEGER :: i
i = 1
! Before the BLOCK construct is exited, local pointers are
! nullified, local allocatables are deallocated, and local
! finalizable objects are finalized.
GOTO 10
i = i + 1
END BLOCK
10 PRINT *, i
END PROGRAM foo