[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: f90 code to read netcdf file



Hi Ben,

> I was wondering if you could point me to a fortran 90 file that I
> could use to read a netcdf file.

Here's some examples of Fortran-90 code to write and read netCDF
files:

  http://www.unidata.ucar.edu/software/netcdf/examples/programs/

Just click on the .f90 links to see the Fortran-90 versions of these.

The documentation for the f90 interface is here:

  http://www.unidata.ucar.edu/software/netcdf/docs/netcdf-f90.html

and it has examples of code fragments (though no complete programs).

The Fortran-90 netCDF interface has some advantages over the C and
Fortran-77 interfaces, namely:

  + Overloaded functions and optional arguments: The Fortran-90
    interface is significantly simpler than either the C or Fortran-77
    interfaces because of its use of overloaded functions and optional
    arguments. For example the one nf90_put_var() function replaces 30
    nf_put_var() functions in the Fortran-77 interface and 40
    nc_put_var() functions in the C interface.

  + Fewer arguments to functions: string lengths need not be passed
    for attribute strings, and array lengths need not be passed for
    dimension arrays. There are fewer and simpler inquiry functions in
    the Fortran-90 interface with the use of optional arguments.

  + Arbitrary array sections supported: The language allows arbitrary
    array sections to be passed to any procedure, which may greatly
    simplify programming.

--Russ