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

Re: 960515: compatibility with previous release



>From: lombardi emanuele <address@hidden>
>Subject: compatibility with previus release
>Keywords: 199605151416.AA21682

Hi Emanuele,

> I'm using netcdf (2.4.2) from fortran and from pv-wave (of visual
> numeric inc.)
> 
> The problem is that pv-wave is able to read the netcdf files made by
> fortran, but it writes netcdf files which are not known by netcdf 2.4.2
> utilities. Infact ncdump complains 
> ncopen: Not a netcdf file

It is probably an HDF file rather than a netCDF file (see below).

> I copied the netcdf file produced by wave to a cray where there is a very 
> old release of netcdf (I don't know how old is it).
> There the file has been properly dumped by ncdump.

Perhaps this ncdump is the version that comes with the HDF software, so it
knows how to read HDF files.

> Probably the problem arise from the fact that the pv-wave netcdf
> interface is to version 2.3 (via hdf v3.3r5) while I use netcdf 2.4.2

No, there has been no change in the netCDF format since 1988.  The new
version of the interface software (2.4.2) still reads and produces the same
netCDF format version 1 files as all previous versions, including version
2.3.

However, HDF files are not netCDF files, even though HDF supports the
netCDF interface for accessing data.  The HDF software writes data in a
different format (the HDF format), even if they are produced using the
netCDF interface.  The HDF software can detect a netCDF format file and
read it, but it cannot write netCDF files, only HDF files.  The netCDF
software cannot read HDF files.

> Is it OK that a version 2.3 file cannot be properly read using version 2.4.2 
> while version 2.3 is able to read a version 2.4.2 file?

No, that would be unacceptable.  Any future netCDF format changes will be
supported with software that is able to read all previous versions of
netCDF data.  Backward compatibility is very important to netCDF users, so
we would not think of releasing a version that used a different format
unless it also could read the previous version of the format.

> Unfortunately I have no way to change the netcdf version used by pv-wave
> since its modules are already compiled and linked into pv-wave.

The documentation for PV-WAVE at
<URL:http://www.vni.com/pvwave.dir/dataio.html> claims that it supports
netCDF format data as well as HDF data, although perhaps older versions did
not provide netCDF support.  

You could verify whether the file in question is an HDF file (as I suspect)
or a netCDF file by looking at the first four bytes of the file, using a
binary editor or something like the unix "od" command.  See the new
appendix on the netCDF File Format in the 2.4.2 User's Guide, also
available at
<URL:http://www.unidata.ucar.edu/packages/netcdf/guide_15.html#SEC115> for
a complete description, but the first four bytes of a netCDF file are

 'C'  'D'  'F'  ^A

where the fourth byte (unprintable control-A or ASCII SOH) is just a binary
1, representing the format version.

The first four bytes of an HDF file are instead

 ^N ^C ^S ^A

all unprintable control characters (ASCII SO, ETX, DC3, SOH) that stand for
NCSA, the National Center for Supercomputing Applications where HDF was
invented.

> Is there any way to convert a netcdf 2.3 file to a netcdf 2.4.2 file?

 cp file_2.3.nc file_2.4.2.nc

(That's supposed to be a joke :-).  If the file is not too large, you could
convert it from an HDF file into a netCDF file by the following steps:

  1.  Use the HDF ncdump utility to get a CDL version of the file:

        /usr/local/hdf/bin/ncdump file.hdf > file.cdl

  2.  Use the 2.4.2 ncgen utility to convert the CDL file into a netCDF
      file:

        ncgen -b -o newfile.nc file.cdl

  3.  Check that the new netCDF file has the right data in it, using the
      2.4.2 ncdump utility:

        ncdump newfile.nc

> Thank you very much,

You're welcome.

______________________________________________________________________________

Russ Rew                                           UCAR Unidata Program
address@hidden                              http://www.unidata.ucar.edu