Manual Reference Pages  - BLOCK (7)

NAME

BLOCK(7f) - [FORTRAN:EXECUTION CONTROL] construct (LICENSE:PD)

SYNOPSIS

  [ block-construct-name : ] BLOCK
  [ specification-part ]
  END[ ]BLOCK [ block-construct-name ]

DESCRIPTION

The BLOCK construct is an executable construct which may contain
declarations, and may be exited using the EXIT statement.

The specification-part of a BLOCK construct shall not contain a COMMON,
EQUIVALENCE, IMPLICIT, INTENT, NAMELIST, or OPTIONAL statement.

A SAVE statement in a BLOCK construct shall not contain a
common-block-name.

Except for the ASYNCHRONOUS and VOLATILE statements, specifications
in a BLOCK construct declare construct entities whose scope is that
of the BLOCK construct.

EXAMPLES

Sample programs:

   program demo_block
   implicit none
   integer,parameter :: arr1(*)=[1,2,3,4,5,6,7]
   integer,parameter :: arr2(*)=[0,1,2,3,4,5,6,7]

call showme(arr1) call showme(arr2)

contains

subroutine showme(a) integer,intent(in) :: a(:) integer :: i=-100

TESTFORZERO: block integer :: I ! local block variable do i=1,size(a) if(a(i).eq.0) EXIT TESTFORZERO enddo write(*,*)’Never found a zero, tried ’,i-1,’ times’ return endblock TESTFORZERO

! note the variable I in the block is local to the block write(*,*)’found a zero’, ’ I=’,i end subroutine showme

end program demo_block

Results:

Never found a zero, tried 7 times found a zero I= -100


Fortran BLOCK (7) January 2017
Generated by manServer 1.08 from block.7fortran.txt using man macros.