[UP]


Manual Reference Pages  - co_sum (3)

NAME

co_sum(3f) - [FORTRAN:INTRINSIC] Sum of values on the current set of images

CONTENTS

Syntax
Description
Arguments
Example
Standard
Class
See Also

SYNTAX

call co_sum(a [, result_image, stat, errmsg])

DESCRIPTION

co_sum sums up the values of each element of A on all images of the current team. If result_image is present, the summed-up values are returned in A on the specified image only and the value of A on the other images become undefined. If result_image is not present, the value is returned on all images. If the execution was successful and STAT is present, it is assigned the value zero. If the execution failed, STAT gets assigned a nonzero value and, if present, ERRMSG gets assigned a value describing the occurred error.

ARGUMENTS

A - shall be an integer, real or complex variable, which has the same type and type parameters on all images of the team.
result_image
  - (optional) a scalar integer expression; if present, it shall have the same the same value on all images and refer to an image of the current team.
STAT - (optional) a scalar integer variable
ERRMSG - (optional) a scalar character variable

EXAMPLE

Sample program:

   program demo_co_sum
     integer :: val
     val = this_image()
     call co_sum(val, result_image=1)
     if (this_image() == 1) then
       write(*,*) "The sum is ", val ! prints (n**2 + n)/2, with n = num_images()
     end if
   end program demo_co_sum

STANDARD

[[TS 18508]] or later

CLASS

[[Collective subroutine]]

SEE ALSO

[[co_max]], [[co_min]], [[co_reduce]], [[co_broadcast]]


co_sum (3) March 18, 2019
Generated by manServer 1.08 from 413ebce3-de81-49bf-8635-7c2191500d37 using man macros.