The Fortran (F77) interface is provided, but certain features have necessarily been omitted (awaiting Fortran 90). The syntax is different since there are no pointers in F77. There are no user-defined types provided in the Fortran interface as Fortran does not provide structures. Once Fortran 90 has been adopted, user-defined types will likely appear in the Fortran interface.
Since Fortran does not allow variable argument functions, the construction of invoices differs from that of the C interface. An invoice is built up over several function calls, each one specifying the next field in the invoice.
C Example 1F integer mailer integer letter ... integer invoice integer i, length double double_array(20) call ZIP_INV_NEW(invoice) call ZIP_INV_ADD_INT(invoice, i, 1, 1, .false, .false.) call ZIP_INV_ADD_DBLE(invoice, double_array, 10, 2, .false., .false.) C use the invoice CALL ZIP_SIZEOF_INVOICE(mailer, invoice, length) CALL YMALLOC(mailer, length, letter) CALL ZIP_PACK(mailer, invoice, ZIP_LETTER, letter, ZIP_IGNORE, length) if(length .eq. -1) then C an error occurred ...The above example packs the same invoice that Example 1 does in C. The last two arguments to ZIP_INV_ADD_INT() and ZIP_INV_ADD_DBLE() are the ``ignore-space'' and ``deferred-sizing'' logicals, respectively, to be explained via examples below. They also appear in the C syntax, but as part of the argument string via special characters.
C Example 2F integer invoice integer i, len, stride DOUBLE double_array(20) i = 20 len = 10 stride = 2 call ZIP_INV_NEW(invoice) call ZIP_INV_ADD_INT(invoice, i, 1, 1, .false., .false.) C C The .true. argument invokes deferred sizing of the data: call ZIP_INV_ADD_DBLE(invoice, double_array, len, stride, .false., .true.) C pack or unpack call is made... len = 5 stride = 1 C pack or unpack call is made...This example performs the same work the C Example 2 did. To ignore space in a pack or unpack call, the ignore-space logical is set true. For instance:
call ZIP_INV_ADD_INT(invoice, 1, 1, .true., .false.)To ignore space and use deferred-sizing evaluation, both flags are set true:
call ZIP_INV_ADD_INT(invoice, len, stride, .true., .true.)Other Zipcode calls are very similar in Fortran to the C versions. A preprocessor is used to create some definitions for use by the Fortran programmer.
The following conventions are followed in the Fortran interface.