_gfortran_caf_co_reduce (The GNU Fortran Compiler)

#### 7.2.37 `_gfortran_caf_co_reduce` — Generic collective reduction ¶

Synopsis:

  `void _gfortran_caf_co_reduce (gfc_descriptor_t *a, void * (*opr) (void *, void *), int opr_flags, int result_image, int *stat, char *errmsg, int a_len, size_t errmsg_len)`

Description:

  Calculates for each array element of the variable a the reduction value for that element in the current team; if result_image has the value 0, the result shall be stored on all images, otherwise, only on the specified image. The opr is a pure function doing a mathematically commutative and associative operation.

  The opr_flags denote the following; the values are bitwise ored. `GFC_CAF_BYREF` (1) if the result should be returned by reference; `GFC_CAF_HIDDENLEN` (2) whether the result and argument string lengths shall be specified as hidden arguments; `GFC_CAF_ARG_VALUE` (4) whether the arguments shall be passed by value, `GFC_CAF_ARG_DESC` (8) whether the arguments shall be passed by descriptor.

Arguments:

  a | intent(inout) An array descriptor with the data to be processed. On the destination image(s) the result overwrites the old content.
  opr | intent(in) Function pointer to the reduction function
  opr_flags | intent(in) Flags regarding the reduction function
  result_image | intent(in) The ID of the image to which the reduced value should be copied to; if zero, it has to be copied to all images.
  stat | intent(out) Stores the status STAT= and may be NULL.
  errmsg | intent(out) When an error occurs, this is set to an error message; may be NULL.
  a_len | intent(in) the string length of argument a
  errmsg_len | intent(in) the buffer size of errmsg

Notes:

  If result_image is nonzero, the data in the array descriptor a on all images except of the specified one become undefined; hence, the library may make use of this.

  For character arguments, the result is passed as first argument, followed by the result string length, next come the two string arguments, followed by the two hidden string length arguments. With C binding, there are no hidden arguments and by-reference passing and either only a single character is passed or an array descriptor.