]>
Commit | Line | Data |
---|---|---|
c63539ff ML |
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_DEFINE, Atomic subroutine, define | |
7 | ||
8 | .. _atomic_define: | |
9 | ||
10 | ATOMIC_DEFINE --- Setting a variable atomically | |
11 | *********************************************** | |
12 | ||
13 | .. function:: ATOMIC_DEFINE(ATOM, VALUE) | |
14 | ||
15 | ``ATOMIC_DEFINE(ATOM, VALUE)`` defines the variable :samp:`{ATOM}` with the value | |
16 | :samp:`{VALUE}` atomically. 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 either integer | |
25 | type with ``ATOMIC_INT_KIND`` kind or logical type with | |
26 | ``ATOMIC_LOGICAL_KIND`` kind. | |
27 | ||
28 | :param VALUE: | |
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}`. | |
31 | ||
32 | :param STAT: | |
33 | (optional) Scalar default-kind integer variable. | |
34 | ||
35 | Standard: | |
36 | Fortran 2008 and later; with :samp:`{STAT}`, TS 18508 or later | |
37 | ||
38 | Class: | |
39 | Atomic subroutine | |
40 | ||
41 | Syntax: | |
42 | .. code-block:: fortran | |
43 | ||
44 | CALL ATOMIC_DEFINE (ATOM, VALUE [, STAT]) | |
45 | ||
46 | Example: | |
47 | .. code-block:: fortran | |
48 | ||
49 | program atomic | |
50 | use iso_fortran_env | |
51 | integer(atomic_int_kind) :: atom[*] | |
52 | call atomic_define (atom[1], this_image()) | |
53 | end program atomic | |
54 | ||
55 | See also: | |
56 | :ref:`ATOMIC_REF`, | |
57 | :ref:`ATOMIC_CAS`, | |
58 | :ref:`ISO_FORTRAN_ENV`, | |
59 | :ref:`ATOMIC_ADD`, | |
60 | :ref:`ATOMIC_AND`, | |
61 | :ref:`ATOMIC_OR`, | |
3ed1b4ce | 62 | :ref:`ATOMIC_XOR` |