Re: [netcdfgroup] NcFile close() member function?

Taylor,

> To finish up with my question, if I can not manually close a file, if I
> open a NEW file with the same handle 'ncfile' (imagine the small code
> snippet that I included earlier being inside a loop ), will this deallocate
> the memory used by the earlier instance? I'd like to open (and close)
> several files in sequence and would like to minimize memory usage.

Here's the response from Lynton Appel:

... The following will loop through a a set of files. At each pass
through the loop, the destructor functions for NcDim and NcFile are
called; in particular the NcFile destructor will issue a call to
nc_close. So, in my view the API is working correctly.

#include <string>
#include <iostream>
#include <netcdf>

using namespace std;
using namespace netCDF;


int main(int argc, char* argv[])
{
  char* fileName[] = {"efitOut.nc","efitOut2.nc"};
 int i;
  for(i=0;i<2;i++)
    {
      NcFile ncFile(fileName[i],NcFile::replace);
      NcDim timeDim(ncFile.addDim("time",2));
    }
  return 1;
}

--Russ



  • 2013 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdfgroup archives: