(j3.2006) reduction routine
Robert W. Numrich
rwn
Wed May 19 15:32:03 EDT 2010
An intrinsic object (reduction?, team?) with associated procedures:
type(reduction) :: x
real :: a, b
a = x%sum(b)
On Wed, May 19, 2010 at 10:06:03AM -0500, Bill Long wrote:
> Date: Wed, 19 May 2010 10:06:03 -0500
> From: Bill Long <longb at cray.com>
> To: fortran standards email list for J3 <j3 at j3-fortran.org>
> Subject: (j3.2006) reduction routine
> Reply-To: longb at cray.com,
> fortran standards email list for J3 <j3 at j3-fortran.org>
>
>
> 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
>
>
> _______________________________________________
> J3 mailing list
> J3 at j3-fortran.org
> http://j3-fortran.org/mailman/listinfo/j3
--
-bob numrich
--
Robert W. Numrich, PhD
Senior Research Associate
Minnesota Supercomputing Institute
587 Walter Library
117 Pleasant Street SE
Minneapolis, MN 55455
Tel: 612-624-4341
More information about the J3
mailing list