Returns a result with a physical representation identical to that of SOURCE but interpreted with the type and type parameters of MOLD.
It performs a low-level conversion between types without any sign extension, rounding, blank padding, or other alteration that may occur using other methods of conversion.
Class
Transformational function
Result Type and Attributes
The same type and type parameters as MOLD.
If MOLD is a scalar and SIZE is absent, the result is a scalar.
If MOLD is array valued and SIZE is absent, the result is array valued and of rank one, with the smallest size that is physically large enough to hold SOURCE.
If SIZE is present, the result is array valued of rank one and size SIZE.
Result Value
The physical representation of the result is the same as SOURCE, truncated if the result is smaller or with an undefined trailing portion if the result is larger.
Because the physical representation is unchanged, it is possible to undo the results of TRANSFER as long as the result is not truncated:
REAL(4) X = 3.141
DOUBLE PRECISION I, J(6) = (/1,2,3,4,5,6/)
! Because x is transferred to a larger representation
! and then back, its value is unchanged.
X = TRANSFER( TRANSFER( X, I ), X )
! j is transferred into a real(4) array large enough to
! hold all its elements, then back into an array of
! its original size, so its value is unchanged too.
J = TRANSFER( TRANSFER( J, X ), J, SIZE=SIZE(J) )
Examples
TRANSFER (1082130432, 0.0) is 4.0.
TRANSFER ((/1.1,2.2,3.3/), (/(0.0,0.0)/)) is a complex rank-one array of length two whose first element has the value (1.1, 2.2) and whose second element has a real part with the value 3.3. The imaginary part of the second element is undefined.
TRANSFER ((/1.1,2.2,3.3/), (/(0.0,0.0)/), 1) has the value (/(1.1,2.2)/).