Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference

ID 767251
Date 9/08/2022
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

TRANSFER

Transformational Intrinsic Function (Generic): Converts the bit pattern of the first argument according to the type and kind parameters of the second argument.

result = TRANSFER (source,mold[,size])

source

(Input) Must be a scalar or array (of any data type).

mold

(Input) Must be a scalar or array (of any data type). It provides the type characteristics (not a value) for the result.

size

(Input; optional) Must be scalar and of type integer. It provides the number of elements for the output result.

Results

The result has the same type and type parameters as mold.

If mold is a scalar and size is omitted, the result is a scalar.

If mold is an array and size is omitted, the result is a rank-one array. Its size is the smallest that is possible to hold all of source.

If size is present, the result is a rank-one array of size size.

When the size of source is greater than zero, mold must not be an array with elements of size zero.

If the internal representation of the result occupies m bits, and the internal representation of source occupies n bits, then if m > n, the right-most src bits of result contain the bit pattern contained in source, and the m minus n left-most bits of result are undefined. If m < n, then result contains the bit pattern of the right-most m bits of source, and the left-most n minus m bits of source are ignored. Otherwise, the result contains the bit pattern contained in source.

Example

TRANSFER (1082130432, 0.0) has the value 4.0 (on processors that represent the values 4.0 and 1082130432 as the string of binary digits 0100 0000 1000 0000 0000 0000 0000 0000).

TRANSFER ((/2.2, 3.3, 4.4/), ((0.0, 0.0))) results in a scalar whose value is (2.2, 3.3).

TRANSFER ((/2.2, 3.3, 4.4/), (/(0.0, 0.0)/)) results in a complex rank-one array of length 2. Its first element is (2.2,3.3) and its second element has a real part with the value 4.4 and an undefined imaginary part.

TRANSFER ((/2.2, 3.3, 4.4/), (/(0.0, 0.0)/), 1) results in a complex rank-one array having one element with the value (2.2, 3.3).

The following shows another example:

 COMPLEX CVECTOR(2), CX(1)
 !  The next statement sets CVECTOR to
 !  [ 1.1 + 2.2i, 3.3 + 0.0i ]
 CVECTOR = TRANSFER((/1.1, 2.2, 3.3, 0.0/), &
                    (/(0.0, 0.0)/))
 !  The next statement sets CX to [ 1.1 + 2.2i ]
 CX = TRANSFER((/1.1, 2.2, 3.3/) , (/(0.0, 0.0)/), &
               SIZE= 1)
 WRITE(*,*) CVECTOR
 WRITE(*,*) CX
 END

The following example shows an error because the source size is greater than zero but mold is an array whose elements have zero size:

CHARACTER(0),PARAMETER :: nothing1(100) = '' 
PRINT *,SIZE(TRANSFER(111014,nothing1))         ! error
...