To: J3 11-122 From: John Reid Subject: Interop: Example re changing attributes Date: 2011 January 26 References: N1838, N1844, ISO/IEC 1539-1:2010 DISCUSSION The Fortran programmer might pass an array with one attribute, say allocatable, to an array with another, say assumed-shape. The Fortran system takes care of this. From C, the C programmer needs to do a bit of work. Edits are provided to show an example. EDITS to N1838: [21:17+] At the start of A.2 Clause 5 notes, add the subsection title "A.2.1 Dummy arguments of any type and rank" [22:33+] Add A.2.2 Changing the attributes of an array A C programmer might want to call more than one Fortran procedure and the attributes of an array involved might differ between the procedures. In this case, it is desirable to set up more than one C descriptor for the array. For example, this code fragment intializes two C descriptors, calls a procedure that allocates the array described by the first descriptor, copies the base_addr and dim pointers to the second descriptor, then calls a procedure that expects an assumed-shape array. cfi_cdest_t desc_alloc, desc_assum; int flag double d; flag = CFI_initialize_cdesc (desc_alloc *, sizeof(d), 2, CFI_type_double, CFI_attribute_allocatable); flag = CFI_initialize_cdesc (desc_assum *, sizeof(d), 2, CFI_type_double, CFI_attribute_assumed); Fortran_factor (desc_alloc *, ...) desc_assum.base_addr = desc_alloc.base_addr desc_assum.dim = desc_alloc.dim Fortran_solve (desc_assum *, ...)