co_max

Date:

02-10-2023

NAME

CO_MAX, CO_MIN - Determine maxiumum or minimum value of elements on all images of the current team in a Coarray Fortran application

SYNOPSIS

CO_MAX (SOURCE [, RESULT_IMAGE, STAT, ERRMSG])
CO_MIN (SOURCE [, RESULT_IMAGE, STAT, ERRMSG])

IMPLEMENTATION

Cray Linux Environment (CLE)

DESCRIPTION

CO_MAX and CO_MIN are intrinsic collective subroutines that determine the maximum or minimum value of elements on all images of the current team in a Coarray Fortran application.

For example, if SOURCE is the coarray of values [2, 3, 7] on one image and SOURCE is the coarray of values [4, 1, 8] on all other images of the current team, the values in coarray SOURCE, after executing the statement CALL CO_MAX(SOURCE) are [4, 3, 8].

Support for non-contiguous SOURCE arrays is deferred.

These subroutines accept the following options:

SOURCE

Can be a scalar or an array of type integer, real, or character. If scalar, the computation result is equal to the maximum/minimum value of SOURCE on all images. If SOURCE is an array, the computation result is equal to the maximum/minimum value of all the corresponding elements of SOURCE on the all the images of the current team. It is an INTENT(INOUT) argument.

RESULT_IMAGE

If RESULT_IMAGE is present, the result of the computation is assigned to SOURCE on image RESULT_IMAGE and SOURCE on all other images of the current team becomes undefined. If RESULT_IMAGE is not present, the result is assigned on all images of the current team. Must be an integer in the range 1 … NUM_IMAGES(). It is an INTENT(IN) argument.

STAT

If STAT is present and an error condition occurs, it is assigned a positive value. If it is present and no error condition occurs, it is assigned the value zero. If it is not present and an error condition occurs, error termination is initiated. Must be an integer scalar. It is an INTENT(OUT) argument.

ERRMSG

If ERRMSG is present and an error condition occurs, it is assigned an explanatory message. If it is present an no error condition occurs, it is left unchanged. Must be a character scalar. It is an INTENT(INOUT) argument.

Example

program test
 integer :: image
 integer :: ssrc[*]
 integer :: source(3)[*]
 image=this_image()
 if (image .eq. 2) then
 ssrc[image] = 200
 source(1:3)[image]=(/2,3,7/)
 else
 ssrc[image]=5
 source(1:3)[image]=(/4,1,8/)
 endif
 call co_max(ssrc)
 call co_max(source)
 print *, "image =",image,"  ssrc =", ssrc,"  source =",source
end

SEE ALSO

co_bcast(3), co_sum(3)