# Overview of Collective Subroutines

Collective subroutines are impure intrinsic subroutines that perform a calculation on a team of images, assigning the result to one of the images or all of the images on the current team. Synchronization is not required. When the collective subroutine is invoked, it is invoked by the same statement on all active images of the current team. Corresponding references to the subroutine participate in the same collective operation.

The sequence of invocations of collective subroutines must be the same across all active images of the current team. A collective subroutine cannot be invoked anywhere an image control statement is not permitted. For example, a pure procedure or a critical construct cannot contain a reference to a collective subroutine.

If argument a in an invocation of a collective subroutine is a coarray, it must ultimately be the same coarray on each active image of the current team.

If argument stat is present in the reference to a collective subroutine on one image, it must be present in corresponding references on all images of the current team.

Successful execution of a collective subroutine causes the value of stat, if present, to become defined with the value 0.

If an error condition occurs during the reference to the collective subroutine and stat is present, stat is assigned a positive value and argument a becomes undefined. If stat is present and the current team contains a stopped image, an error condition occurs and stat becomes defined with the value STAT_STOPPED_IMAGE defined in the intrinsic module ISO_FORTRAN_ENV. Otherwise, if the current team contains a failed image, an error condition occurs and stat becomes defined with the value STAT_FAILED_IMAGE from ISO_FORTRAN_ENV. If any other error condition occurs, stat becomes defined with a positive integer value other than STAT_STOPPED_IMAGE or STAT_FAILED_IMAGE.

If stat is not present in a reference to a collective subroutine and an error condition occurs during the reference, error termination is initiated.

If argument errmsg is present when an error condition occurs, it becomes defined with an explanatory message, padded with blanks or truncated as necessary. If no error condition occurs, the value and definition status of errmsg is not changed.

Internal synchronization occurs during a reference to a collective subroutine, but a statement containing a reference to a collective subroutine is not an image control statement.

For a list of all collective intrinsic subroutines, including links to the subroutine's full description, see Collective Intrinsic Subroutines.

Parent topic: Intrinsic Procedures