BLOCK (Fortran 2008)

Purpose

The BLOCK statement declares a named or an unnamed BLOCK construct. It is the first statement of the BLOCK construct.

Syntax

Read syntax diagramSkip visual syntax diagramBLOCK_construct_name:BLOCK
BLOCK_construct_name
is a name that identifies the BLOCK construct.

Rules

If you specify a BLOCK_construct_name in a BLOCK statement, you must specify the same name in the corresponding END BLOCK statement.

Example

In the following example, the BLOCK statement declares an unnamed BLOCK construct:

SUBROUTINE swap(i, j) 
  INTEGER :: i, j 
  
  IF (i < j) THEN
    ! The BLOCK statement has no BLOCK_construct_name. The corrsponding END BLOCK 
    ! statement cannot have a BLOCK_construct_name either.
    BLOCK                  
      INTEGER :: temp
      
      temp = i 
      i = j 
      j = temp 
    END BLOCK         
  END IF              
END SUBROUTINE swap

Related information