(j3.2006) Specification part in every <block>, not just BLOCK?
Van Snyder
van.snyder
Thu Dec 21 18:10:14 EST 2006
I have a subroutine that has an optional argument. If the optional
argument is present, the calculation needs a work array having a
dimension that is the same size as the optional argument. Rather than
making the work array an allocatable or pointer, I'd like to make it an
automatic array. This means I have to put the part of the calculation
that is triggered by the presence of the argument into an internal
subroutine. In Fortran 2008, I'd put the stuff in a BLOCK:
if ( present(z_basis) ) then
block
real(rp) :: ETA_T2(size(vert_inds),size(z_basis))
...
end block
end if
It would be easier if I could write
if ( present(z_basis) ) then
real(rp) :: ETA_T2(size(vert_inds),size(z_basis))
...
end if
There doesn't seem to be a technical problem with creeping the feature
of construct-scoped variables to the <block> in each part of an IF or
SELECT construct. The words in the standard aren't very difficult
either: mostly (but not exclusively) changing BLOCK to <block> in a few
places.
If the feature were crept to the <block> in DO constructs there is some
question whether we should or should not allow the DO induction variable
to appear in a dimension or length expression. I suppose optimizers
could figure out which ones would need to be created and destroyed on
each iteration and which ones could be hoisted out.
Is allowing a <specification-part> before the <block> in each branch of
IF and SELECT constructs a bridge too far?
How about putting <specification-part> within <block>, so it's available
in every construct?
--
Van Snyder | What fraction of Americans believe
Van.Snyder at jpl.nasa.gov | Wrestling is real and NASA is fake?
Any alleged opinions are my own and have not been approved or
disapproved by JPL, CalTech, NASA, the President, or anybody else.
More information about the J3
mailing list