[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Problem with ncopen
- Subject: Re: Problem with ncopen
- Date: Mon, 14 Jul 1997 12:22:06 -0600
> From: Jessica Burkhart <address@hidden>
> To: address@hidden
> Subject: Problem with ncopen
> Organization: Oklahoma Climate Survey
Jessica,
> > > I am having a problem with ncopen repeatedly returning 0 as a valid
> > > file id. The other netCDF functions, ncclose and ncdimid, return
> > > bad id error codes with a netCDF file id of 0.
> > >
> > > I'd appreciate any suggestions.
> >
> > If you could tell me the version of netCDF you are using and the
> > platform (OS, hardware) on which you see the above error, we could be of
> > more help, but for now I can only suggest that you install the current
> > version of netCDF, available in source form from
> >
> We are using netCDF version 3.3.1 on a DEC Alpha machine with the LINUX
> Red Hat 4.0 OS.
>
> I was not specific enough about the problem. ncopen with NC_WRITE is
> returning a 0 which is causing ncclose and ncdimid to return error
> codes. However, when I force ncopen to return a positive value, then the
> file can be accessed.
>
> Thanks for your suggestion.
OK, apparently I misunderstood the problem.
In netCDF 3.3.1, the ncopen function is in the version 2 compatibility
interface (the corresponding netCDF-3 function is named "nc_open").
It should return 0 for the first netCDF file opened successfully, and -1
in case there is an error. In this case, ncclose and ncdimid should
work fine with the 0 netCDF id returned by ncopen. I've just tested
this with a tiny program that opens an existing file using ncopen with
NC_WRITE and then closes it successfully with ncclose, and it works
fine.
#include <netcdf.h>
#include <stdio.h>
int
main()
{
int ncid;
ncopts = NC_VERBOSE;
ncid = ncopen("x.nc", NC_WRITE);
printf("ncid = %d\n", ncid);
ncclose(ncid);
return 0;
}
This is invoked in a directory that has a writable netCDF file "x.nc",
and it prints "ncid = 0" and exits. If I rename x.nc, then it also
works correctly, with the following output:
ncopen: filename "x.nc": No such file or directory
ncid = -1
ncclose: -1 is not a valid cdfid
I'm not sure what you mean when you say "when I force ncopen to return a
positive value, then the file can be accessed", but if the above doesn't
work on our platform, we want to know because it's a bug. If the above
does work on your Alpha/Linux platform, can you provide a small example
that demonstrates the problem?
--Russ
_____________________________________________________________________
Russ Rew UCAR Unidata Program
address@hidden http://www.unidata.ucar.edu