xarray icon indicating copy to clipboard operation
xarray copied to clipboard

Allow us to create space and later write to an existing NetCDF file object

Open leonfoks opened this issue 2 months ago • 1 comments

What is your issue?

I'm writing an MPI enabled Xarray accessor and one of the caveats with HDF5/NetCDF in parallel is that the metadata and space inside the file needs to be created up front and collectively by all ranks in the communicator. After creation those ranks can then do non-collective write operations to disk.

Does xarray have this capability somewhere already? i.e. something like the following.

f = netcdf_file_object # open the netcdf file

# x is a Dataarray or Dataset
x.create_netcdf(f)
x.write_netcdf(f)

Cheers!

leonfoks avatar Dec 12 '25 23:12 leonfoks

Unfortunately, I don't think we support this for netCDF yet. We do have such an API for Zarr files: https://docs.xarray.dev/en/stable/user-guide/io.html#distributed-writes

shoyer avatar Dec 15 '25 00:12 shoyer