Clicky

Fortran Wiki
block

block

Introduced in Fortran 2008, a block creates its own name space. See the following example:

program blockTest
  implicit none
  real, parameter :: x=1.1
  print *, "before block: x=",x      ! yields: 1.1
  block
    integer, parameter :: x=2
    print *, "inside block: x=",x    ! yields: 2
  end block
  print *, "after block: x=",x       ! yields: 1.1
end program blockTest

One can also name each block for more clarity in larger programs:

program blockTest
  implicit none
  real, parameter :: x=1.1
  print *, "before block: x=",x      ! yields: 1.1
  someName: block
    integer, parameter :: x=2
    print *, "inside block: x=",x    ! yields: 2
  end block someName
  print *, "after block: x=",x       ! yields: 1.1
end program blockTest