georust / netcdf

High-level netCDF bindings for Rust
Apache License 2.0
81 stars 28 forks source link

Flushing file #135

Closed kiranshila closed 4 months ago

kiranshila commented 4 months ago

Hello again! Another quick issue/question -

Is there an equivalent to nc_sync / flushing to disk in this rust implementation? I'm getting some errors occasionally that look like

HDF5.API.H5Error: Error reading dataset /voltages
libhdf5 Stacktrace:
  [1] H5FD_read: Invalid arguments to routine/Address overflowed
      addr overflow, addr = 16803176, size = 3656, eoa = 16803176

when trying to read from other programs. Looking around this seems to be the result of an incomplete write.

mulimoen commented 4 months ago

We should expose nc_sync to allow the user to sync the file. In the mean time you could use open_with with the SHARE flag.

lnicola commented 4 months ago

Can you get the native handle to call nc_sync on it? I couldn't spot it in the docs.

mulimoen commented 4 months ago

No, the native handle is kept private

mulimoen commented 4 months ago

It should be mentioned that reading a file whilst writing to it is not supported by hdf5 unless SWMR mode is set. There is a PR implementing this in netcdf-c here: https://github.com/Unidata/netcdf-c/pull/2653

mulimoen commented 4 months ago

@kiranshila This is published in 0.9.1 and can be called as FileMut::sync.

kiranshila commented 3 months ago

Fantastic, beat me to the PR. Thank you so much!