Babel Fortran 2003 Binding for Structured Data Types Page: 8 of 11
This article is part of the collection entitled: Office of Scientific & Technical Information Technical Reports and was provided to Digital Library by the UNT Libraries Government Documents Department.
The following text was automatically extracted from the image on this page using optical character recognition software:
6 Stefan Muszala et al.
ing the SIDL array type. We provide two types of r-arrays, static and dy-
namic. Static r-array support requires a pre-defined size to be declared in a
SIDL definition of an r-array (rarray<int, 1> rarrayStructMember (5) ; ). Since
all array or matrix sizes are know at compile time, the C/C++ declaration
would be double rarrayStructMember ; while the Fortran 2003 declaration
is real(c_double): :rarrayStructMember(5).
Implementing dynamic SIDL r-arrays that allow a user to malloc, new or
allocate their data and then pass that data across the language boundary re-
quires a few additional steps. Like the SIDL array type, the r-array is represented
as a pointer in the Babel IOR files and the cptr bind(c) kind is once more used
in Fortran. At this point the r-array implementation diverges from that of the
Instead of using Chasm as the casting mechanism for the array cptr the
rarray cptr is converted to a native Fortran array using the cf_pointer rou-
tine that is defined by the Fortran 2003 standard . The difference is that the
SIDL array type is itself represented in Babel as a structured data type and we
need Chasm to set those structured data type members equal to the individual
components of the Fortran array descriptors in order for the accessor functions to
work. Given the SIDL definition of rarray<int, 1> structRaw(iY) ; the conver-
sion in Fortran occurs as shown in Figure 5 and includes an additional required
local type declaration.
real (c-double ) dimension (:) , pointer structMemberfptr
call CFPOINTER (CPTRstruct%structMember, &
FPTRzstructMember_fptr , &
! The above is auto-generated by Babel
! and from this point below, the user can
! manipulate the rarray data directly.
structMemberfptr ( i)=structMemberfptr ( i )+5.0
Fig. 5: Calls required to convert a pointer to a usable Fortran r-array type. DIM
is declared in a module and in this case we define N as a struct member as well.
Here’s what’s next.
This article can be searched. Note: Results may vary based on the legibility of text within the document.
Tools / Downloads
Get a copy of this page or view the extracted text.
Citing and Sharing
Basic information for referencing this web page. We also provide extended guidance on usage rights, references, copying or embedding.
Reference the current page of this Article.
Muszala, S; Epperly, T & Wang, N. Babel Fortran 2003 Binding for Structured Data Types, article, May 2, 2008; Livermore, California. (https://digital.library.unt.edu/ark:/67531/metadc897976/m1/8/: accessed May 21, 2019), University of North Texas Libraries, Digital Library, https://digital.library.unt.edu; crediting UNT Libraries Government Documents Department.