# CO_SUM

Collective Intrinsic Subroutine (Generic): Performs a sum reduction across images.

CALL CO_SUM (a [, result_image, stat, errmsg])

a | (Input; output) Must be of type real, integer, or complex, and have the same shape, type, and type parameter values in corresponding references. It may not be a coindexed object. If it is scalar, the computed value is the sum of the values of a in all corresponding references. If it as an array, each element of the computed value is equal to the sum of the values of the corresponding element of a in all corresponding references. If no error occurs, the computed value is assigned to a on all images of the current team if result_image is not present, or on the executing image if the executing image is the image identified by result_image. Otherwise, a becomes undefined.
result_image | (Input; optional) Must be a scalar integer. If present, it must be present with the same value in all corresponding references and be a valid image index in the current team. If result_image is not present, it may not be present in any corresponding reference.
stat | (Output; optional) Must be a non-coindexed integer scalar with a decimal exponent range of at least four (KIND=2 or greater). The value assigned to stat is specified in Overview of Collective Subroutines. If stat is not present and an error condition occurs, error termination is initiated.
errmsg | (Input; output; optional) Must be a non-coindexed default character scalar variable. The semantics of errmsg is described in Overview of Collective Subroutines.

## Example

Consider the following:

    CALL CO_SUM (R, 2)

If the number of images is two and if R is a four-element array defined with the value [5, 10, 20, 15] on image one and [10, 15, 20, 5] on image two when the procedure is referenced, R becomes defined with the value [15, 25, 40, 20] on image two and undefined on image one if no error occurs during the subroutine reference, and CALL CO_SUM ® causes R on both images to become defined with the value [15, 25, 40, 20].

Parent topic: C to D

## See Also

Overview of Collective Subroutines