NOTICE: This version of the NSF Unidata web site (archive.unidata.ucar.edu) is no longer being updated.
Current content can be found at unidata.ucar.edu.
To learn about what's going on, see About the Archive Site.
Okay, I've narrowed down the problem even further. The code fails with a different NcBadId error message if I simply declare an empty NcFile: NcFile foo; without the followup assignment. I get the same exception, but thrown from ncFile.cpp line 15. Curiously, the exception happens later if I immediately follow it up with the assignment shown in the previous email. On Fri, Apr 24, 2015 at 1:47 PM, Jack Stalnaker <jack.stalnaker@xxxxxxxxx> wrote: > I should add that the code works just fine if the NcFile variable is > initialized immediately. That is, replace: > > NcFile foo; > foo = NcFile("blah.nc", NcFile::replace); > > with just > > NcFile foo("blah.nc", NcFile::replace); > > and it works perfectly well. > > > On Fri, Apr 24, 2015 at 1:33 PM, Jack Stalnaker <jack.stalnaker@xxxxxxxxx> > wrote: > >> Not too far back I noticed that I could not use an NcFile object as a >> class member, which I asked about here: >> http://netcdf-group.1586084.n2.nabble.com/NcFile-as-class-member-td7575625.html#a7575628 >> >> I never resolved that issue, but I was playing around with it again >> today. I wrote a very simple bit of test code, and realized the problem is >> actually much more fundamental than the one I originally asked about. >> Assignment to an empty NcFile variable does not work anywhere. >> >> For example: >> >> #include <netcdf> >> >> int main(int argc, char *argv[]) >> { >> using namespace netCDF; >> using namespace netCDF::exceptions; >> >> NcFile foo; >> foo = NcFile("blah.nc", NcFile::replace); >> >> double baz = 1.0; >> foo.putAtt("bar", ncDouble, size_t(1), &baz); >> >> return 0; >> } >> >> fails at the putAtt line with the same netCDF::exceptions::NcBadId >> exception I saw in the older question. The exception points to ncGroup.cpp >> line 791, which is just the definition of putAtt. >> >> Anyone have any insight? Thanks. >> > >
netcdfgroup
archives: