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

ID 767251
Date 3/22/2024
Public

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

Document Table of Contents

CFI_section

C function prototype: Updates a C descriptor for an array section for which each element is an element of a given array.

int CFI_section(CFI_cdesc_t *result, const CFI_cdesc_t *source,
                          const CFI_index_t lower_bounds[],
                          const CFI_index_t upper_bounds[], 
                          const CFI_index_t strides[]);

Formal Parameters:

result

The address of a C descriptor with rank equal to the rank of source minus the number of zero strides. The attribute member must have the value CFI_attribute_other or CFI_attribute_pointer. If the value of result is the same as either a C formal parameter that corresponds to a Fortran actual argument or a C actual argument that corresponds to a Fortran dummy argument, the attribute member must have the value CFI_attribute_pointer.

Successful execution of CFI_section updates the base_addr and dim members of the C descriptor with the address result to describe the array section determined by source, lower_bounds, upper_bounds, and strides, as follows:

  • The array section is equivalent to the Fortran array section SOURCE(sectsub1, sectsub2, ... sectsubn), where SOURCE is the array described by source, n is the rank of that array, and sectsubi is the subscript loweri if stridesi is zero, and the section subscript loweri : upperi : stridei otherwise.

  • The value of loweri is the lower bound of dimension i of SOURCE if lower_bounds is a null pointer and lower_bounds[i] otherwise.

  • The value of upperi is the upper bound of dimension i of SOURCE if upper_bounds is a null pointer and upper_bounds[i] otherwise.

  • The value of stridei is 1 if strides is a null pointer and strides[i] otherwise. If stridei has the value zero, loweri must have the same value as upperi.

source

The address of a C descriptor that describes a nonallocatable nonpointer array, an allocated allocatable array, or an associated array pointer. The elem_len and type members of source must have the same values as the corresponding members of result.

lower_bounds

A null pointer or the address of an array with at least source->rank elements. If it is not a null pointer, and stridei is zero or (upperi −lower_bounds[i] + stridei)/stridei > 0, the value of lower_bounds[i] must be within the bounds of dimension i of SOURCE.

upper_bounds

A null pointer or the address of an array with at least source->rank elements. If source describes an assumed-size array, upper_bounds must not be a null pointer. If it is not a null pointer and stridei is zero or (upper_bounds[i] − loweri + stridei)/stridei > 0, the value of upper_bounds[i] must be within the bounds of dimension i of SOURCE.

strides

A null pointer or the address of an array with at least source->rank elements.

If an error is detected, the C descriptor with the address result is not modified.

Result Value

The result is an error indicator.

Example

If source is already the address of a C descriptor for the rank-one Fortran array A, the lower bounds of A are equal to 1, and the lower bounds in the C descriptor are equal to 0, the following code fragment establishes a new C descriptor section and updates it to describe the array section A(3::5):


CFI_index_t lower[1], strides[1];
CFI_CDESC_T(1) section;
int ind;
lower[0] = 2;
strides[0] = 5;
ind = CFI_establish((CFI_cdesc_t *)&section, NULL, 
CFI_attribute_other,
CFI_type_float, 0, 1, NULL);
ind = CFI_section((CFI_cdesc_t *)&section, source, 
lower, NULL, strides);

If source is already the address of a C descriptor for a rank-two Fortran assumed-shape array A with lower bounds equal to 1, the following code fragment establishes a C descriptor and updates it to describe the rank-one array section A(:, 42):


CFI_index_t lower[2], upper[2], strides[2];
CFI_CDESC_T(1) section;
int ind;
lower[0] = source->dim[0].lower_bound;
upper[0] = source->dim[0].lower_bound + source->dim[0].extent - 1;
strides[0] = 1;
lower[1] = upper[1] = source->dim[1].lower_bound + 41;
strides[1] = 0;
ind = CFI_establish((CFI_cdesc_t *)&section, NULL, 
CFI_attribute_other,
CFI_type_float, 0, 1, NULL);
ind = CFI_section((CFI_cdesc_t *)&section, source, 
lower, upper, strides);