Re: [netcdf-java] isOpen method for NetcdfDataset

Hi John,
> > . Is there something like an 'isOpen' method somewhere that I'm just 
> > missing? If not can you add one?
> > 
> there are some complications that make isOpen() not completely 
> straightforward.
> 
> we've assumed that when the application closes a dataset, it releases the 
> object also.
> 
> is there some generic issue, or just some complex code you are dealing with?
I was trying to play nice with how Matlab handles variable scopes. I had the 
option of sharing a single netcdf java object among multiple Matlab classes 
(which is very efficient, as the data gets cached), but I was running into an 
issue where the shared netcdf java object would get closed. I was hoping to 
handle the closed file relatively gracefully, (i.e. if it's closed just open a 
new one) but, alas, there's no way to query the state of the netcdf object. 

Would something as simple as toggling a flag in the ucar.nc2.NetcdfFile class 
suffice? (Looking at the source it looks like you'd have to add the same code 
into NetcdfDataset too)

class Netcdf {

 private boolean open = true;

 public void close() {
 // do close code.
 open = false
 }

 public boolean isOpen() {
return open;
 }

}

As an alternative would it be possible to create multiple netcdf objects that 
share the same FileCache? Looking at the source code, I'm not clear on exactly 
what happens to the cache when a NetcdfFile that uses the cache is closed. Is 
the cache still usable? 

Cheers

-- 
Brian Schlining 



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