Unidata - To provide the data services, tools, and cyberinfrastructure leadership that advance Earth system science, enhance educational opportunities, and broaden participation. Unidata
         
  advanced  
 

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

 
 
  Contact Us     Site Map     Search     Terms and Conditions     Privacy Policy     Participation Policy
 
National Science Foundation (NSF) UCAR Community Programs   Unidata is a member of the UCAR Community Programs, is managed by the University Corporation for Atmospheric Research, and is sponsored by the National Science Foundation.
P.O. Box 3000     Boulder, CO 80307-3000 USA     Tel: 303-497-8643     Fax: 303-497-8690