netcdf_f90.inc: a f90 friendly include file for the NetCDF Fortran 77 API

Hi,

I attach "netcdf_f90.inc" which is similar to the standard "netcdf.inc" but
with Fortran interface blocks. It can be used with free- and fixed- format
source code.

For instance, in "netcdf.inc", distributed as part as the NetCDF library,
we have:
     integer         nf_create
!                         (character*(*)       path,
!                          integer             cmode,
!                          integer             ncid)
     external        nf_create

The corresponding block in netcdf_f90.inc is:

     interface
        integer function nf_create                                     &
    &                   (path,                                         &
    &                    cmode,                                        &
    &                    ncid)
                        character*(*)       path
                        integer             cmode
                        integer             ncid
        end function
     end interface

The only catch is NF_INT1_T and NF_INT2_T which, if netcdf_f90.inc
was included in the netcdf library, should be expanded to the right types
using probably m4 during the build process of netcdf.

So far, I used netcdf_f90.inc as below:
module my_netcdf
#if defined(HAVE_F90_NETCDF_INC)
# define NF_INT1_T integer(kind=1)
# define NF_INT2_T integer(kind=2)
# include 'netcdf_f90.inc'
#else
 include "netcdf.inc"
#endif
end module my_netcdf

and uses "my_netcdf" to provide explicit interfaces to the Fortran 77
NetCDF API.

With the availability of free Fortran 95 compilers such as GNU gfortran,
interface blocks for the NetCDF Fortran 77 interface makes it possible
to benefit cheaply of interface checks in an existing code.
I hope it can be useful to somebody. It certainly helped me to find a few
bugs in my own codes.

Regards,

Attachment: netcdf_f90.inc
Description: Binary data

  • 2005 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdfgroup archives: