Visible to Intel only — GUID: GUID-029A3B21-866F-49FE-8F3B-2B15BEF05BC1
Visible to Intel only — GUID: GUID-029A3B21-866F-49FE-8F3B-2B15BEF05BC1
CFI_select_part
C function prototype: Updates a C descriptor for an array section for which each element is a part of the corresponding element of an array.
Syntax
int CFI_select_part(CFI_cdesc_t *result, const CFI_cdesc_t *source, size_t displacement, size_t elem_len);
Formal Parameters:
result |
The address of a C descriptor; result->rank must have the same value as source->rank and result->attribute must have the value CFI_attribute_other or CFI_attribute_pointer. If the address specified by result is the value of a C formal parameter that corresponds to a Fortran actual argument or of a C actual argument that corresponds to a Fortran dummy argument, result->attribute must have the value CFI_attribute_pointer. The value of result->type specifies the type of the array section. |
source |
The address of a C descriptor for a nonallocatable nonpointer array, an allocated allocatable array, or an associated array pointer. |
displacement |
A value 0 ≤ displacement ≤ source->elem_len − 1, and the sum of the displacement and the size in bytes of an element of the array section must be less than or equal to source->elem_len. The address displacement bytes greater than the value of source->base_addr is the base of the array section and must be appropriately aligned for an object of the type of the array section. |
elem_len |
A value equal to the storage size in bytes of an element of the array section if result->type specifies a Fortran character type; otherwise, elem_len is ignored. |
Description
Successful execution of CFI_select_part updates the base_addr, dim, and elem_len members of the C descriptor with the address result for an array section for which each element is a part of the corresponding element of the array described by the C descriptor with the address source. The part must be a component of a structure, a substring, or the real or imaginary part of a complex value.
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 Fortran array A declared as follows:
TYPE, BIND(C) :: T
REAL(C_DOUBLE) :: X
COMPLEX(C_DOUBLE_COMPLEX) :: Y
END TYPE
TYPE(T) A(100)
then the following code fragment establishes a C descriptor for the array A%Y:
typedef struct {
double x; double _Complex y;
} t;
CFI_CDESC_T(1) component;
CFI_cdesc_t * comp_cdesc = (CFI_cdesc_t *)&component;
CFI_index_t extent[] = { 100 };
(void)CFI_establish(comp_cdesc, NULL, CFI_attribute_other,
CFI_type_double_Complex,
sizeof(double _Complex), 1, extent);
(void)CFI_select_part(comp_cdesc, source, offsetof(t,y), 0);