[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: 19990224: netCDF question
- Subject: Re: 19990224: netCDF question
- Date: Thu, 25 Feb 1999 12:58:46 -0700
>To: "'address@hidden'" <address@hidden>
>From: "Weiss, Michele" <address@hidden>
>Subject: netCDF question
>Organization: .
>Keywords: 199902241931.MAA11972
Hi Michele,
> I am running NetCDF using the C++ version 3.4 on HP-UX and I am coming
> up with an execution error. I am attaching the source code but
> essentially, I am successful in opening a NetCDF file using replace as
> the attribute, add attributes to it but when I try and create a
> dimension, either unlimited or with a size specified, I am getting an
> execution error that states:
>
> ncinquire: ncid 6: Not a netCDF id
>
> When I print out what the class of nc contains, I get the following
> values:
>
> {the_id = 6, in_define_mode = 1, dimensions = 0x40009788, variables =
> 0x40009920, globalv = 0x4000b868, _vptr$ = 0x400014f8 <NcFile virtual
> table>}
>
> I am new to NetCDF and really stuck and am totally out of ideas on
> things to try to get around this. Since I don't have the NetCDF source
> code, I can't step into it to see how the id of 6 is getting assigned
> and what is a valid netcdf id.
If you want to debug this further, you can certainly get the netCDF
source code, compile it with debugging, and step into it, by accessing
the sources from
ftp://ftp.unidata.ucar.edu/pub/netcdf/netcdf.tar.Z
I was able to compile the C++ code you provided, in an attempt to
diagnose the problem, but I was unable to duplicate the problem here,
because there was no main program. Also, there was not quite enough
information provided to determine where the program was when the error
message occurred.
Nevertheless, I saw one problem in the code and have a guess at what
might be another problem.
In "NetCDFFileIO.cpp":
strcpy (filename, "dummy.dat\n");
NcFile nc( filename, NcFile::Replace );
which tries to open or create the file "dummy.dat\n", where the "\n"
means the newline character will actually be included in the file
name. You probably intended instead to open the file "dummy.dat", but
it must have worked OK, because you didn't say you got an error
returned from the call to the NcFile constructor.
I note that the end of the NetCDFFileIO::WriteLevel1AImagingfunction
method in which nc is declared is
outputRate2->add_att("long_name", "Output_Rate_Data_2");
// now add data
}
with your comment indicating that more data is to be added. You
cannot use "nc" or "outfile" as a valid handle of a netCDF file after
this function exits, because these were local variables in that
method, so their destructors get called automatically when they go out
of scope, and the NcFile destructor closes the file. Hence if you had
saved a copy or a pointer to nc or outfile to try to use either of
them again, you will get a message similar to what you are seeing
ncinquire: ncid 6: Not a netCDF id
I didn't see this happening in your code, so this may be wrong, but I
hope this helps.
--Russ
_____________________________________________________________________
Russ Rew UCAR Unidata Program
address@hidden http://www.unidata.ucar.edu