(j3.2006) reduction routine
Bill Long
longb
Wed May 19 11:06:03 EDT 2010
Suppose you wanted to have an intrinsic that did a general reduction
operation, such as
call reduction (array, operation, result)
where there is an intrinsic or defined operation specified by the
'operation' argument that is visible in the caller scope.
How would you actually specify the operation to the routine? In the old
days, one would have just passed the name of the procedure that performs
the operation as the actual argument. In the new OOP world, all you
would know is a generic specifier or a symbolic operator name. You
could write
call reduction (X, ".my_oper.", ans)
where you expect the compiler to look up (or, for polymorphic variables,
generate code to look up) the function corresponding to the operator
.my-oper. that is defined for a variable of the dynamic type of X, and
then pass that on to the actual reduction routine. [Such a scheme would
only work for an intrinsic, so that the compiler 'knows' what to do.]
This is a bit clunky, but appears to work.
Is there a better method?
Cheers,
Bill
--
Bill Long longb at cray.com
Fortran Technical Support & voice: 651-605-9024
Bioinformatics Software Development fax: 651-605-9142
Cray Inc./Cray Plaza, Suite 210/380 Jackson St./St. Paul, MN 55101
More information about the J3
mailing list