]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/fortran/doc/gfortran/intrinsic-procedures/cobroadcast.rst
sphinx: add missing trailing newline
[thirdparty/gcc.git] / gcc / fortran / doc / gfortran / intrinsic-procedures / cobroadcast.rst
1 ..
2 Copyright 1988-2022 Free Software Foundation, Inc.
3 This is part of the GCC manual.
4 For copying conditions, see the copyright.rst file.
5
6 .. _co_broadcast:
7
8 CO_BROADCAST --- Copy a value to all images the current set of images
9 *********************************************************************
10
11 .. index:: CO_BROADCAST, Collectives, value broadcasting
12
13 .. function:: CO_BROADCAST(A, SOURCE_IMAGE, STAT, ERRMSG)
14
15 ``CO_BROADCAST`` copies the value of argument :samp:`{A}` on the image with
16 image index ``SOURCE_IMAGE`` to all images in the current team. :samp:`{A}`
17 becomes defined as if by intrinsic assignment. If the execution was
18 successful and :samp:`{STAT}` is present, it is assigned the value zero. If the
19 execution failed, :samp:`{STAT}` gets assigned a nonzero value and, if present,
20 :samp:`{ERRMSG}` gets assigned a value describing the occurred error.
21
22 :param A:
23 INTENT(INOUT) argument; shall have the same
24 dynamic type and type parameters on all images of the current team. If it
25 is an array, it shall have the same shape on all images.
26
27 :param SOURCE_IMAGE:
28 a scalar integer expression.
29 It shall have the same value on all images and refer to an
30 image of the current team.
31
32 :param STAT:
33 (optional) a scalar integer variable
34
35 :param ERRMSG:
36 (optional) a scalar character variable
37
38 Standard:
39 Technical Specification (TS) 18508 or later
40
41 Class:
42 Collective subroutine
43
44 Syntax:
45 .. code-block:: fortran
46
47 CALL CO_BROADCAST(A, SOURCE_IMAGE [, STAT, ERRMSG])
48
49 Example:
50 .. code-block:: fortran
51
52 program test
53 integer :: val(3)
54 if (this_image() == 1) then
55 val = [1, 5, 3]
56 end if
57 call co_broadcast (val, source_image=1)
58 print *, this_image, ":", val
59 end program test
60
61 See also:
62 :ref:`CO_MAX`,
63 :ref:`CO_MIN`,
64 :ref:`CO_SUM`,
65 :ref:`CO_REDUCE`