Special Note for Users of FXDR version 1.x:

Version 2 of FXDR introduces a new, non-backwards-compatible interface to the XDR routines. I did this so that error handling could be included in a consistent way; with the version 1.x interface, error handling was difficult and inconsistent. The upshot is that if you already have code that uses the 1.x interface, DON'T upgrade to FXDR version 2 unless you are willing to change the old source code to the new interface. On the other hand, if you need (or want) error handling, you must upgrade to version 2.0 anyway. All new users should always use version 2.0.

Here is a link to the old FXDR code (version 1.4) in case you need it. If you are new to FXDR, don't use this old code! Here is a link to the old FXDR home page.

Here is what changed between versions 1.x and 2:


Old (1.x) style of initxdr:

        ixdrs = initxdr( filename, mode )

New (v2) style of initxdr:

        ixdrs = initxdr( filename, mode, return_on_error )

I.e., a new logical input parameter, return_on_error, has been added. If return_on_error is .FALSE., then the behavior of the XDR routines is exactly the same in version 2 as in version 1.x: an error will cause the routine to print an error message and halt (this is like Fortran). If return_on_error is .TRUE., then an error will cause ANY of the FXDR routines to return even if an error is encountered; in this event, the returned value of the FXDR routines will be less than zero. NOTE that previously the FXDR routines were subroutine calls, but in version 2 they are function calls so that an error code can be returned in this event.


In keeping with the returned error codes described above, all the FXDR routines are now integer function calls rather than subroutine calls. To reflect this, the names are changed -- there is now an 'i' in front of each routine's name to indicate that it returns an integer. If initxdr was called with the third parameter (return_on_error) equal to .FALSE., then the routines print an error message and halt if they encounter an error. If initxdr was called with the third parameter (return_on_error) equal to .TRUE., then the routines return no matter what, and the return value is less than zero if and only if an error was encountered. This lets the calling code handle errors, if you want to do things that way. A list of error codes is in file 'fxdr.inc'.

Changing old code to the new interface

Changing old code to the new interface is straightforward. Follow these steps:

  1. Add the new third parameter to 'initxdr' calls. Unless you want to do your own error handling, just make it .FALSE.
  2. Add an 'i' to the name of the XDR routine; i.e., 'xdrrmat' goes to 'ixdrrmat', 'xdrint' goes to 'ixdrint', etc.
  3. Change from subroutine calls to integer function calls. I.e., change from 'call ....()' to 'ierr = ....()'
  4. If you use 'implicit none', then include the new header file 'fxdr.inc' to provide the proper definitions of the FXDR routines (this step is optional).

That's it. Not too bad.