Stuart Maclean wrote:
I'm not at all sure if this is intended behavior of the Java netcdf
API for the NetcdfFileWriteable class, so I am not claiming this to be
a bug, it just seems strange to me. Using nc2.2, OS is Redhat
Enterprise Linux, JDK is Sun's 1.4.2_05...
I am using the NetcdfFileWriteable class as such
NetcdfFileWriteable ncw = new NetcdfFileWriteable( "foo.nc", b );
add dims, vars
ncw.create();
write data
ncw.flush();
ncw.close();
where boolean b = true or false, makes no difference to the following
observed behavior.
Now, I want my app to hose any existing file foo.nc, i.e. my app knows
what needs to be written to foo.nc, and any previous contents are
irrelevant. Depending on the config of my app, different amounts of
data are intended to be written to foo.nc. My app always writes all
of the data for all variables defined, so no 'fill' is required.
Now, the strange part is that if foo.nc exists and I run my app, the
contents of foo.nc will only change if the total size of the new
dataset in bytes is larger than the existing size of the file foo.nc.
If the app intends to write a smaller total number of bytes to foo.nc
than is currently on the disk, say to define fewer variables than a
previous run, then the new contents are not written.
Even more strangely, no matter if the file contents are or are not
updated, the timestamp (file modification time on Unix??) of the file
is updated unconditionally.
So, in short, my app will have to remove the file if it exists to be
sure of the correct final contents of the file??
As I said, maybe this is as it all should be. If so, are there docs
to show this? The javadoc comments for the class suggest to me that
what I want to happen, should happen, but it isn't happening ;)
Any clarifications appreciated
Stuart
Hi Stuart:
This is certainly not what should happen. Let me see if I can reproduce it.
Thanks,
John