concept ipaddr_port in category fortran
appears as: ipaddr_port

This is an excerpt from Manning's book Modern Fortran: Building efficient parallel applications.
Exercise 1: The Fortran interface to
ipaddr_portIt’s your turn now! We need to check that the port number is stored correctly when we call the
ipaddr_localfunction. We’ve already implemented the interface toipaddr_str, which returns the character string representation of the IP address. libdill also provides theipaddr_portfunction, which returns the integer value of the port number associated with theipaddrdata structure:
The C function
ipaddr_porttakes theipaddrstruct as an input argument and returns theportnumber as ac_int. The key to implementing the Fortran interface is to match the argument and the function result data types, as shown in the following listing.Listing 11.10. Fortran interface to
ipaddr_portlanguage="fortran" linenumbering="unnumbered">module mod_dill ... public :: ipaddr, ipaddr_local, & #1 ipaddr_port, ipaddr_str #1 ... interface ... integer(c_int) function ipaddr_port(addr) & #2 bind(c, name='dill_ipaddr_port') #3 import :: c_int, ipaddr #4 type(ipaddr), intent(in) :: addr #5 end function ipaddr_port ... end interface end module