(j3.2006) Pointer component after nonzero rank component

Van Snyder Van.Snyder
Thu Feb 9 19:54:50 EST 2012

I have a need to compute a sum:

 rowSum = 0.0
 do inst = 1, size(fCols)
   rowSum = rowSum + &
     & FwmJacobian%block(jRow,fCols(inst))%values(cz,surf)
 end do ! inst

It would be clearer, and therefore desirable, to do

  rowSum = sum(FwmJacobian%block(jRow,fCols(:))%values(cz,surf))

but the values component has the pointer attribute.

If I do

  rowSum = sum([(FwmJacobian%block(jRow,fCols(inst))%values(cz,surf), &
         &       inst=1,size(fCols))])

should I usually expect the processor to create an array temp, or just
unroll the sum intrinsic into what I did in the first place?

The problems caused by having a pointer component after a nonzero rank
component aren't much different from the problems caused by a vector
subscript.  It seems that the only time the second sentence of C618:

C618 (R611) There shall not be more than one part-ref with nonzero rank.
A part-name to the right of a part-ref with nonzero rank shall not have
the ALLOCATABLE or POINTER attribute.

is useful is in the places where prohibits vector subscripts.
Would it cause trouble to repeat the prohibitions in, mutatis
mutandis, in place of the second sentence of c618, and add the essence
of that second sentence to c724 and c901?

More information about the J3 mailing list