CSMG(3I) Last changed: 2-5-98
NAMECSMG - Performs a conditional scalar merge
SYNOPSISCSMG ([I=]i, [J=]j, [K=]k)
IMPLEMENTATION
UNICOS, UNICOS/mk, and IRIX systems
STANDARDS
CF90 and MIPSpro 7 Fortran 90 compiler extension to Fortran 90
DESCRIPTION
The CSMG intrinsic function merges i and j, controlled by the bit mask
in k. When a 1 bit appears in k, the corresponding bit of i becomes
the corresponding bit of the result. When a 0 bit appears in k, the
corresponding bit of j is taken. Therefore, CSMG(i, j, k) equals the
following specification:
(i .AND. k) .OR. (j .AND. .NOT. k)
The CSMG function accepts the following arguments:
i First item to be merged. Can be of Boolean, integer, real, or
Cray pointer type.
If i is of type integer or real, it must be of KIND=8 on UNICOS
and UNICOS/mk systems. On IRIX systems, i can be of KIND=4 or
KIND=8, but it must be the same length as j and k.
j Second item to be merged. Can be of Boolean, integer, real, or
Cray pointer type.
If j is of type integer or real, it must be of KIND=8 on UNICOS
and UNICOS/mk systems. On IRIX systems, j can be of KIND=4 or
KIND=8, but it must be the same length as i and k.
k Bit mask. Can be of Boolean, integer, real, or Cray pointer
type.
If k is of type integer or real, it must be of KIND=8 on UNICOS
and UNICOS/mk systems. On IRIX systems, k can be of KIND=4 or
KIND=8, but it must be the same length as i and j.
CSMG is an elemental function. The name of this intrinsic cannot be
passed as an argument.
NOTES
The CSMG intrinsic function is outmoded. Refer to the Fortran
Language Reference Manual, Volume 3, publication SR-3905, for
information on outmoded features and their preferred standard
alternatives.
RETURN VALUES
The return value is of Boolean type.
EXAMPLES
Example 1: Specifying CSMG(i,j,MASK(64) or CSMG(i,j,-1) returns i.
Example 2: CSMG(i,j,0) returns j.
Example 3: Specifying the conditional scalar merge CSMG( 'ABCDEFGH'H,
'12345678'H, X'0000FFFFFF0000FF' ) generates '12CDE67H'H as the
result.
Example 4: This example applies only to UNICOS systems.
INTEGER EXPONENT,EXPMASK
PARAMETER( EXPMASK = X'7FFF000000000000' )
C Statement function:
EXPONENT(X) = SHIFTR(X .AND. EXPMASK, 48)
C Statement function:
DIVBY2(X) =
& CSMG( SHIFTL(EXPONENT(X)-1,48),
& X,
& EXPMASK )
According to this example, a call to DIVBY2(-28.0) yields -14.0.
SEE ALSO
Intrinsic Procedures Reference Manual, publication SR-2138, for the
printed version of this man page.