The conditional vector merge functions (CVMGM, CVMGN, CVMGP, CVMGT, and CVMGZ) enable you to port existing code that contains these functions.
MERGE ( TSOURCE, FSOURCE, arith_expr .op. 0 )
or
MERGE ( TSOURCE, FSOURCE, logical_expr .op. .TRUE. )
Because
the MERGE intrinsic is part of the Fortran 90 language,
we recommend that you use it instead of these functions for any new
programs.Elemental function
If only one of TSOURCE and FSOURCE is typeless, the typeless argument acquires the type of the other argument. If both TSOURCE and FSOURCE are typeless, both arguments acquire the type of MASK. If MASK is also typeless, both TSOURCE and FSOURCE are treated as default integers. If MASK is typeless, it is treated as a default logical for the CVMGT function and as a default integer for the other CVMGx functions.
Same as TSOURCE and FSOURCE.
The function result is the value of either the first argument or second argument, depending on the result of the test performed on the third argument. If the arguments are arrays, the test is performed for each element of the MASK array, and the result may contain some elements from TSOURCE and some elements from FSOURCE.
Explanation | Function Return Value | Generic Name |
---|---|---|
Test for positive or zero | TSOURCE if MASK≥0 FSOURCE if MASK<0 | CVMGP |
Test for negative | TSOURCE if MASK<0 FSOURCE if MASK≥0 | CVMGM |
Test for zero | TSOURCE if MASK=0 FSOURCE if MASK≠0 | CVMGZ |
Test for nonzero | TSOURCE if MASK≠0 FSOURCE if MASK=0 | CVMGN |
Test for true | TSOURCE if MASK= .true. FSOURCE if MASK= .false. | CVMGT |