(j3.2006) CO_BROADCAST vs. CO_REDUCE
Bill Long
longb
Thu Sep 18 08:40:52 EDT 2014
Hi Tobias,
On Sep 18, 2014, at 1:35 AM, Tobias Burnus <burnus at net-b.de> wrote:
>
> Regarding CO_REDUCE's OPERATOR: Can one reduce the flexibility of that
> function a bit? For instance, the current wording permits that the
> arguments have either the VALUE attribute or not. It also seems to
> permit elemental arguments and ? possibly ? having an elemental
> function with an array for one argument and a scalar for the other
> argument, C binding seems to be also permitted. I have not thought about
> how exactly I would implement it in the compiler, but reducing the
> complexity of OPERATOR would surely help.
Evidently the TS needs clearer wording here. Considering that the OPERATOR function will be called from a library routine almost certainly written in C that has no visibility of the Fortran interface, it is not reasonable to allow dummy argument declarations that would require an interface. The name (normal or bind(c)) of the function is not an issue, since the CO_REDUCE routine will be getting access to the function through a dummy argument (normally a pointer to the entry point of the function). The arguments should be passed by the mechanism that would be used for scalar arguments with no attributes specified that would require a special passing mechanism (such as VALUE, ALLOCATABLE, POINTER, OPTIONAL, ?). Since we say the function is pure, if VALUE is not allowed, INTENT(IN) becomes required.
While we don?t specifically say, I don?t think we intend to disallow writing the OPERATOR function in C. It would save having to write a wrapper in the case that the algorithm in the function was not easily writable in Fortran. The function could, for example, be a C function that implemented a defined operator in the program, and the reduction is desired over that operator.
Note that one of the problems of allowing a polymorphic argument A to CO_REDUCE is the possible complexity of passing such an argument to OPERATOR from a C caller in the library.
Cheers,
Bill
Bill Long longb at cray.com
Fortran Technical Suport & 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