nextsimhub / nextsimdg

neXtSIM_DG : next generation sea-ice model with DG
https://nextsim-dg.readthedocs.io/en/latest/?badge=latest
Apache License 2.0
10 stars 13 forks source link

Parallel NetCDF: file mode creation/opening needs the parallel library choice bit. #689

Open andreapiacentini opened 2 months ago

andreapiacentini commented 2 months ago

In core/src/ParallelNetcdfFile.cpp the open_par function calls NetCDF nc_open_par: if parallelism is enabled in NetCDF, the mode has to specify if the NC_MPIIO or NC_PNETCDF mode is chosen, otherwise an Invalid argument exception is raised.
Adding | MPIIO in the calls inside the switch (fMode) section fixed the problems, but it can be tailored as a choice.
Cf, from XIOS, src/io/onetcdf4.cpp.

I also noticed that the MPI_Info info argument is passed uninitialized to NetCDF. It should be set to MPI_INFO_NULL if no hint is passed to NetCDF. This is done in XIOS (same file), but could be let open to optimization (probably a bit too much geeky, though).
There a choice from removing the info argument from the API of open_par and set it to MPI_INFO_NULL inside or to propagate the initialization to the callers.

andreapiacentini commented 2 months ago

This behavior appears to be related to the version of NetCDF-C. Updating to 4.9.2 on my PC solved the issue. Notice that 4.6.1, 4.6.2 and 4.7.1 are still widely used (more recent version have proven hard to tune on lustre filesystems)