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.
6 .. index:: ATOMIC_FETCH_AND, Atomic subroutine, AND with fetch
10 ATOMIC_FETCH_AND --- Atomic bitwise AND operation with prior fetch
11 ******************************************************************
13 .. function:: ATOMIC_FETCH_AND (ATOM, VALUE, OLD , STAT)
15 ``ATOMIC_AND(ATOM, VALUE)`` atomically stores the value of :samp:`{ATOM}` in
16 :samp:`{OLD}` and defines :samp:`{ATOM}` with the bitwise AND between the values of
17 :samp:`{ATOM}` and :samp:`{VALUE}`. When :samp:`{STAT}` is present and the invocation was
18 successful, it is assigned the value 0. If it is present and the invocation has
19 failed, it is assigned a positive value; in particular, for a coindexed
20 :samp:`{ATOM}`, if the remote image has stopped, it is assigned the value of
21 ``ISO_FORTRAN_ENV`` 's ``STAT_STOPPED_IMAGE`` and if the remote image has
22 failed, the value ``STAT_FAILED_IMAGE``.
25 Scalar coarray or coindexed variable of integer
26 type with ``ATOMIC_INT_KIND`` kind.
29 Scalar of the same type as :samp:`{ATOM}`. If the kind
30 is different, the value is converted to the kind of :samp:`{ATOM}`.
33 Scalar of the same type and kind as :samp:`{ATOM}`.
36 (optional) Scalar default-kind integer variable.
45 .. code-block:: fortran
47 CALL ATOMIC_FETCH_AND (ATOM, VALUE, OLD [, STAT])
50 .. code-block:: fortran
54 integer(atomic_int_kind) :: atom[*], old
55 call atomic_fetch_and (atom[1], int(b'10100011101'), old)
61 :ref:`ISO_FORTRAN_ENV`,
62 :ref:`ATOMIC_FETCH_ADD`,
63 :ref:`ATOMIC_FETCH_OR`,
64 :ref:`ATOMIC_FETCH_XOR`