mirror of
https://github.com/Unidata/netcdf-cxx4.git
synced 2024-11-21 03:13:46 +08:00
Add missing NcFile::enddef() method, so can create files of all format types
This commit is contained in:
parent
e013ab35f0
commit
92ec0a9f40
@ -82,3 +82,8 @@ NcFile::NcFile(const string& filePath, const FileMode fMode, const FileFormat fF
|
||||
void NcFile::sync(){
|
||||
ncCheck(nc_sync(myId),__FILE__,__LINE__);
|
||||
}
|
||||
|
||||
// Leave define mode, used for classic model
|
||||
void NcFile::enddef() {
|
||||
ncCheck(nc_enddef(myId),__FILE__,__LINE__);
|
||||
}
|
||||
|
@ -65,6 +65,9 @@ namespace netCDF
|
||||
//! Synchronize an open netcdf dataset to disk
|
||||
void sync();
|
||||
|
||||
//! Leave define mode, used for classic model
|
||||
void enddef();
|
||||
|
||||
private:
|
||||
/* Do not allow definition of NcFile involving copying any NcFile or NcGroup.
|
||||
Because the destructor closes the file and releases al resources such
|
||||
|
@ -62,8 +62,8 @@ int create_file(string filename, NcFile::FileFormat format) {
|
||||
|
||||
// In the classic model, must explicitly leave define mode
|
||||
// before writing data. Need a method that calls nc_enddef().
|
||||
// if(format != NcFile::nc4)
|
||||
// dataFile.
|
||||
if(format != NcFile::nc4)
|
||||
dataFile.enddef();
|
||||
|
||||
// Write the data to the file. Although netCDF supports
|
||||
// reading and writing subsets of data, in this case we write all
|
||||
@ -90,20 +90,17 @@ int main()
|
||||
return ret;
|
||||
cout << "*** SUCCESS creating nc4 file" << endl;
|
||||
|
||||
// The following three tests don't work yet. Uncomment when can write
|
||||
// files of nc4classic, classic, and classic64 formats.
|
||||
if(ret = create_file("simple_xy_nc4classic.nc", NcFile::nc4classic))
|
||||
return ret;
|
||||
cout << "*** SUCCESS creating nc4classic file" << endl;
|
||||
|
||||
// if(ret = create_file("simple_xy_nc4classic.nc", NcFile::nc4classic))
|
||||
// return ret;
|
||||
// cout << "*** SUCCESS creating nc4classic file" << endl;
|
||||
if(ret = create_file("simple_xy_classic.nc", NcFile::classic))
|
||||
return ret;
|
||||
cout << "*** SUCCESS creating classic file" << endl;
|
||||
|
||||
// if(ret = create_file("simple_xy_classic.nc", NcFile::classic))
|
||||
// return ret;
|
||||
// cout << "*** SUCCESS creating classic file" << endl;
|
||||
|
||||
// if(ret = create_file("simple_xy_classic64.nc", NcFile::classic64))
|
||||
// return ret;
|
||||
// cout << "*** SUCCESS creating classic64 file" << endl;
|
||||
if(ret = create_file("simple_xy_classic64.nc", NcFile::classic64))
|
||||
return ret;
|
||||
cout << "*** SUCCESS creating classic64 file" << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user