]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/fortran/doc/gfortran/intrinsic-procedures/atomicadd.rst
sphinx: add missing trailing newline
[thirdparty/gcc.git] / gcc / fortran / doc / gfortran / intrinsic-procedures / atomicadd.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 .. index:: ATOMIC_ADD, Atomic subroutine, add
7
8 .. _atomic_add:
9
10 ATOMIC_ADD --- Atomic ADD operation
11 ***********************************
12
13 .. function:: ATOMIC_ADD(ATOM, VALUE)
14
15 ``ATOMIC_ADD(ATOM, VALUE)`` atomically adds the value of :samp:`{VALUE}` to the
16 variable :samp:`{ATOM}`. When :samp:`{STAT}` is present and the invocation was
17 successful, it is assigned the value 0. If it is present and the invocation
18 has failed, it is assigned a positive value; in particular, for a coindexed
19 :samp:`{ATOM}`, if the remote image has stopped, it is assigned the value of
20 ``ISO_FORTRAN_ENV`` 's ``STAT_STOPPED_IMAGE`` and if the remote image has
21 failed, the value ``STAT_FAILED_IMAGE``.
22
23 :param ATOM:
24 Scalar coarray or coindexed variable of integer
25 type with ``ATOMIC_INT_KIND`` kind.
26
27 :param VALUE:
28 Scalar of the same type as :samp:`{ATOM}`. If the kind
29 is different, the value is converted to the kind of :samp:`{ATOM}`.
30
31 :param STAT:
32 (optional) Scalar default-kind integer variable.
33
34 Standard:
35 TS 18508 or later
36
37 Class:
38 Atomic subroutine
39
40 Syntax:
41 .. code-block:: fortran
42
43 CALL ATOMIC_ADD (ATOM, VALUE [, STAT])
44
45 Example:
46 .. code-block:: fortran
47
48 program atomic
49 use iso_fortran_env
50 integer(atomic_int_kind) :: atom[*]
51 call atomic_add (atom[1], this_image())
52 end program atomic
53
54 See also:
55 :ref:`ATOMIC_DEFINE`,
56 :ref:`ATOMIC_FETCH_ADD`,
57 :ref:`ISO_FORTRAN_ENV`,
58 :ref:`ATOMIC_AND`,
59 :ref:`ATOMIC_OR`,
60 :ref:`ATOMIC_XOR`