concept fortran interface in category fortran

This is an excerpt from Manning's book Modern Fortran: Building efficient parallel applications.
Our first step is to write a Fortran interface with the C struct
ipaddrin the libdill library. This is the first ingredient we need to get before implementing theipaddr_local(server) andipaddr_remote(client) functions. A struct in C is analogous to a derived type in Fortran (see chapter 8)--an arbitrary data structure with components of built-in or other data types. For the most part, they have a similar syntax and behavior.Although the functions
ipaddr_localandipaddr_remoteare described in the documentation, theipaddrstruct that they use as an argument isn’t. To understand how to write a Fortran interface with this struct, we need to look inside the libdill header file. If you installed libdill following the instructions in the previous subsection, you’ll find the file here: libdill-2.14/libdill.h. The relevant snippet that gives the definition of theipaddrstruct inlibdill.his
Listing 11.1. A Fortran interface with the
ipaddrstructlanguage="fortran" linenumbering="unnumbered">module mod_dill use iso_c_binding, only: c_char #1 implicit none private public :: ipaddr type, bind(c, name='dill_ipaddr') :: ipaddr #2 character(c_char) :: address(32) #3 end type ipaddr #4 end module mod_dill