J3/15-119r1 To: J3 Members From: Steve Lionel Subject: UTI 008 and Editorial suggestions for C interop functions Date: 2015 February 25 Reference: 15-007, 15-011 The text and examples for some of the ISO_Fortran_binding.h functions have ambiguities or errors. This paper suggests corrections for these. This paper also suggests a remedy for UTI 008. General There is some inconsistency in this section regarding "parameters" and "arguments". In C, "parameters" are what Fortran calls "dummy arguments" and "arguments" are Fortran's "actual arguments". CFI_establish In paragraph 2, the description of the elem_len parameter has as the last sentence: "Otherwise, type will be ignored." I assume this meant to refer to elem_len and not type. The text leaves unstated how the elem_len member of the C descriptor is derived when the type is not struct, other or character. Paragraph 3 says "The remaining properties of the object are given by the other arguments.", but for objects not struct, other or character, no arguments specify the length. Discussion on the J3 mailing list agreed that for such objects, CFI_establish uses its own knowledge of the length of such objects to supply a value for elem_len. Furthermore, the text leaves unstated how additional processor-dependent derived type codes (see 458:15-17) relate to elem_len. The text also says (463:7-8) "If base_addr is the C address of a Fortran data object, the type and elem_len arguments shall be consistent with the type and type parameters of the Fortran data object." The part about elem_len is wrong for the cases where the elem_len argument is ignored. CFI_section The example for case(ii) uses "lower" as the descriptor member name but it should be lower_bound. CFI_select_part For the displacement parameter, the text says: "the sum of the displacement and the size in bytes of the array section shall be less than or equal to source->elem_len." I believe this should instead say "... the size in bytes [of an element of] the array section...", otherwise this would be rather useless. The intent is that an element of the newly selected array is not allowed to cross an element boundary of the source array. UTI 008 In UTI 008, the editor properly notes that the current text inadequately and inconsistently specifies requirements related to the type member of a C descriptor, in particular about possible processor-defined additional values. The intent is that the processor may want to support additional intrinsic types and specific noninteroperable derived types with nonnegative type codes not listed in table 15.4. It is not required that such additional codes exist. EDITS to 15-007: [453:31 15.3.7p4] Delete "from Table 15.4" [453:34-37 15.3.7p4] Replace the second bullet: "if the dynamic type of the effective argument is an intrinsic type with no corresponding type listed in Table 15.4, or a noninteroperable derived type that does not have type parameters, type-bound procedures, final subroutines, nor components that have the ALLOCATABLE or POINTER attributes, or correspond to CFI_type_other, one of the processor-dependent nonnegative type specifier values;" with the following two bullets: "otherwise, if the dynamic type of the effective argument is a Fortran intrinsic type for which a processor-dependent nonnegative type specifier macro exists, the corresponding type specifier value; otherwise, if the dynamic type of the effective argument is a noninteroperable derived type for which a processor-dependent nonnegative type specifier macro exists, and the type does not have type parameters, type-bound procedures, final subroutines, components that have the ALLOCATABLE or POINTER attributes, or components that correspond to CFI_type_other, the corresponding type specifier value;" [456:35 15.5.3p2] Replace: "The macros listed in Table 15.4 provide values that correspond to each specifier." with: "The macros listed in Table 15.4 provide values that correspond to specifiers, and the processor may provide macros for additional specifiers." [458:17+ 15.5.4] Delete UTI 008 if the issue is resolved [462:33 15.5.5.5p2] Replace: "shall be one of the type codes in Table 15.4." with: "shall be one of the type codes from Table 15.4 or one of the additional processor-dependent type codes defined in source file ISO_Fortran_binding.h, if any." [462:36 15.5.5.5p2] Replace the text: "If the type is equal to CFI_type_struct, CFI_type_other, or a Fortran character type code, elem_len shall be greater than zero and equal to the storage size in bytes of an element of the object. Otherwise, type will be ignored." with: "If \cf{type} is equal to CFI_type_struct, CFI_type_other, a Fortran character type code, or a processor-dependent type code corresponding to a noninteroperable Fortran derived type, \cf{elem_len} shall be greater than zero and equal to the storage size in bytes of an element of the object. Otherwise, \cf{elem_len} is ignored." [463:7-8 15.5.5.5p3] Replace the sentence: "If base_addr is the C address of a Fortran data object, the type and elem_len arguments shall be consistent with the type and type parameters of the Fortran data object." with: "If the \cf{type} argument is not equal to CFI_type_struct, CFI_type_other, a Fortran character type code, nor a processor-dependent type code corresponding to a noninteroperable Fortran derived type, the value of elem_len is supplied by the processor. If \cf{base_addr} is the of a Fortran data object, the \cf{type} argument shall be consistent with the type and type parameters of the Fortran data object." [465:18-28 15.5.5.7p4] Replace ".lower" with ".lower_bound" thrice, taking care not to change references to the variable named "lower". [465:44 15.5.5.8p2] Replace "the size in bytes of the array section" with "the size in bytes of an element of the array section" [466:4 15.5.5.8p2] Replace "otherwise, the value of this parameter is ignored" with "otherwise, \cf{elem_len} is ignored." [Annex A] Add to the list of processor dependencies: "the order of the members of the CFI_dim_t structure type defined in source file ISO_Fortran_binding.h (15.5.2)" "the order and set of the members of the CFI_cdesc_t structure type defined in source file ISO_Fortran_binding.h beyond the requirements specified in 15.5.3" "whether additional type specifier codes are defined beyond the set in Table 15.4 (15.5.4)" "the values of the macros defined in source file ISO_Fortran_binding.h (15.5.4)"