ATOMIC_CAS intrinsic subroutine
Standard: F77 F90 F95 F2003 F2008 F2018 Example program
<Syntax>
CALL ATOMIC_CAS(ATOM, OLD, COMPARE, NEW [ , STAT ] )
ATOM : scalar Integer(atomic_int_kind), Intent(InOut), must be a coarray or a coindexed object;
OLD : scalar Integer(atomic_int_kind), Intent(Out);
COMPARE : scalar Integer(atomic_int_kind);
NEW : scalar Integer(atomic_int_kind);
STAT : scalar Integer, not a coindexed object, Intent(Out).
STAT must be able to represent the values −9999 to +9999 (i.e. 16 bits or larger).
<Semantics>
This is an atomic Compare-And-Swap operation: the variable ATOM is atomically compared to COMPARE and changed to the value NEW if equal; if unequal, ATOM is unchanged. The variable OLD is assigned the actual value that ATOM had at the time of comparison (this means that the swap occurred if and only if OLD==COMPARE afterwards).
If STAT is present, it is assigned a positive value if an error occurs, and zero otherwise. If an error occurs and STAT is not present, the program is terminated.
If ATOM is a coindexed variable that lies on a failed image, the error STAT_FAILED_IMAGE occurs.
<Related>
ATOMIC_ADD intrinsic subroutine, ATOMIC_AND intrinsic subroutine, ATOMIC_DEFINE intrinsic subroutine, ATOMIC_FETCH_ADD intrinsic subroutine, ATOMIC_FETCH_AND intrinsic subroutine, ATOMIC_FETCH_OR intrinsic subroutine, ATOMIC_FETCH_XOR intrinsic subroutine, ATOMIC_OR intrinsic subroutine, ATOMIC_REF intrinsic subroutine, ATOMIC_XOR intrinsic subroutine, CODIMENSION attribute, Image selectors