(j3.2006) contradiction in CO_REDUCE

Malcolm Cohen malcolm
Thu Jan 16 19:03:35 EST 2014

Bill suggested a "compromise":
>Is CO_REDUCE the only intrinsic that has a procedure dummy argument?   If so, 
>and we wanted to change the constraint, we could make it apply to only to calls 
>to non-intrinisc procedures, which reads better than calling out one particular 

One thousand times no.  That would make it impossible to CO_REDUCE by a 
procedure dummy argument or a procedure pointer, since they cannot be elemental. 
The elemental requirement is just wrong.

Look guys, it is trivial given a PURE procedure to apply it elementally.  Apart 
from FORALL, here is another simple example:

Module junk
  Type operation
    Procedure(negate),NoPass,Pointer :: proc => Null()
  End Type
  Elemental Subroutine apply(a,x)
    Type(operation),Intent(In) :: a
    Real,Intent(InOut) :: x
    If (Associated(a%proc)) Call a%proc(x)
  End Subroutine
  Pure Subroutine negate(z)
    Real,Intent(InOut) :: z
    z = -z
  End Subroutine
End Module
Program example
  Use junk
  Real a,b(10)
  a = 3
  b = [ (i,i=1,10) ]
  Call apply(operation(negate),a)
  Print *,a
  Call apply(operation(negate),b)
  Print *,b
End Program

This demonstrates conclusively the complete lack of justification for requiring 
the operation to be elemental.

................................Malcolm Cohen, Nihon NAG, Tokyo. 

More information about the J3 mailing list