transfer

Date:

06-19-2023

NAME

TRANSFER - Treats the first argument as if it is of the same type as the second argument

SYNOPSIS

TRANSFER ([SOURCE=]source, [MOLD=]mold [,[SIZE=]size])

STANDARDS

Fortran

DESCRIPTION

The TRANSFER intrinsic function returns a result with the physical representation identical to that of source but interpreted with the type and kind of mold. If mold is character, the result has the same character length declared for mold. It accepts the following arguments:

source

Can be of any type. It can be scalar or array valued.

mold

Can be of any type. It can be scalar or array valued. This intrinsic function should not be used if mold is a derived type with a pointer component; the result of this depends on your implementation.

size

Must be scalar and an integer.

TRANSFER is a transformational function. The name of this intrinsic cannot be passed as an argument.

RETURN VALUES

The result has the same type as mold.

If mold is scalar and size is not present, the result is a scalar.

If mold is array valued and size is not present, the result is an array of rank one. The size of the array is as small as possible such that its physical representation is not shorter than that of source.

If size is present, the result is an array of rank one with an extent of size.

If the physical representation of the function result is the same length as source, the result is the entire representation of source.

If the physical representation of the function result is longer than source, the result is the entire representation of source and the remainder of the result is undefined.

If the physical representation of the function result is shorter than source, the result is the leading part of source.

If source and mold are scalar entities and the size of mold is at least as long as source, the result must be the value of source. For example, if source is an array and mold is a rank one array, E is the value of the following:

TRANSFER(TRANSFER(E, D), E, SIZE(E))

EXAMPLES

Example 1: TRANSFER(‘abc’,’d’) yields a.

Example 2: Assume that A is the following real array: (/1.1,2.2,3.3/).

TRANSFER(A,(/(0.0,0.0)/)) yields a complex 1-dimensional array with one element: (1.1,2.2).

TRANSFER(A,(/(0.0,0.0)/),1) yields a complex rank one array with one element: (1.1,2.2).