From d74c09f9c1703327272cc55276a81dc70869bbff Mon Sep 17 00:00:00 2001 From: Andy Stokely Date: Fri, 12 Dec 2025 14:18:07 -0700 Subject: [PATCH] Set default PnetCDF header alignment to 128 KiB Increase the default Parallel NetCDF header alignment to 128 KiB when creating new files with SMIOL. This size is sufficiently larger than the header of a typical MPAS restart file to reduce the likelihood of header reallocation during ncmpi_enddef, which can lead to I O hangs when overwriting string attributes or variables with larger values. This change addresses the hang reported in MPAS Workflow issue 384 and does not affect calculation results or I O performance in preliminary tests. The alignment hint may be overridden via the PNETCDF_HINTS environment variable. --- src/external/SMIOL/smiol.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/external/SMIOL/smiol.c b/src/external/SMIOL/smiol.c index 8a34ed23bb..3efe4b9b5f 100644 --- a/src/external/SMIOL/smiol.c +++ b/src/external/SMIOL/smiol.c @@ -12,6 +12,7 @@ #define PNETCDF_DEFINE_MODE 0 #define PNETCDF_DATA_MODE 1 #define MAX_REQS 256 +#define PNETCDF_HEADER_ALIGN_SIZE_STR "131072" #endif #define START_COUNT_READ 0 @@ -324,6 +325,7 @@ int SMIOL_open_file(struct SMIOL_context *context, const char *filename, /* * Convert fformat to a PNetCDF file creation mode */ + MPI_Info info = MPI_INFO_NULL; int filecmode; if (fformat == SMIOL_FORMAT_CDF2) { filecmode = NC_64BIT_OFFSET; @@ -336,11 +338,14 @@ int SMIOL_open_file(struct SMIOL_context *context, const char *filename, MPI_Comm_free(&io_group_comm); return SMIOL_INVALID_FORMAT; } - + MPI_Info_create(&info); + MPI_Info_set(info, "nc_header_align_size", + PNETCDF_HEADER_ALIGN_SIZE_STR); ierr = ncmpi_create(io_file_comm, filename, (filecmode | NC_CLOBBER), - MPI_INFO_NULL, + info, &((*file)->ncidp)); + MPI_Info_free(&info); } (*file)->state = PNETCDF_DEFINE_MODE; #endif