merge
- Date:
10-12-2011
NAME
MERGE - Chooses an alternative value according to the value of a mask
SYNOPSIS
MERGE ([TSOURCE=]tsource, [FSOURCE=]fsource, [MASK=]mask)
IMPLEMENTATION
Cray Linux Environment (CLE)
STANDARDS
Fortran
DESCRIPTION
The MERGE intrinsic function can be used for array construction. It chooses an alternative value according to the value of mask. This function accepts the following arguments:
- tsource
May be of any type
- fsource
Must be of the same type and type parameters as tsource
- mask
Must be of type logical
MERGE is an elemental function. The name of this intrinsic cannot be passed as an argument.
RETURN VALUES
The result has the same type and type parameters as tsource. The result is tsource if mask is true and fsource otherwise.
EXAMPLES
Example 1: Assume that TSOURCE, FSOURCE, and MASK are arrays. Array TSOURCE is as follows:
| 1 6 5 |
| 2 4 6 |
Array FSOURCE is as follows:
| 0 3 2 |
| 7 4 8 |
Array MASK is as follows:
| T F T |
| F F T |
Also assume that the letter T represents the value TRUE and the letter F represents the value FALSE. The statement MERGE(TSOURCE,FSOURCE,MASK) generates the following:
| 1 3 5 |
| 7 4 6 |
Example 2: MERGE(1.0, 0.0, K>0) yields [1.0] for K = 5.
Example 3: MERGE(1.0, 0.0, K>0) yields [0.0] for K = -2.