Skip to content

Commit d74c09f

Browse files
author
Andy Stokely
committed
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.
1 parent 9fa8cb2 commit d74c09f

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/external/SMIOL/smiol.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#define PNETCDF_DEFINE_MODE 0
1313
#define PNETCDF_DATA_MODE 1
1414
#define MAX_REQS 256
15+
#define PNETCDF_HEADER_ALIGN_SIZE_STR "131072"
1516
#endif
1617

1718
#define START_COUNT_READ 0
@@ -324,6 +325,7 @@ int SMIOL_open_file(struct SMIOL_context *context, const char *filename,
324325
/*
325326
* Convert fformat to a PNetCDF file creation mode
326327
*/
328+
MPI_Info info = MPI_INFO_NULL;
327329
int filecmode;
328330
if (fformat == SMIOL_FORMAT_CDF2) {
329331
filecmode = NC_64BIT_OFFSET;
@@ -336,11 +338,14 @@ int SMIOL_open_file(struct SMIOL_context *context, const char *filename,
336338
MPI_Comm_free(&io_group_comm);
337339
return SMIOL_INVALID_FORMAT;
338340
}
339-
341+
MPI_Info_create(&info);
342+
MPI_Info_set(info, "nc_header_align_size",
343+
PNETCDF_HEADER_ALIGN_SIZE_STR);
340344
ierr = ncmpi_create(io_file_comm, filename,
341345
(filecmode | NC_CLOBBER),
342-
MPI_INFO_NULL,
346+
info,
343347
&((*file)->ncidp));
348+
MPI_Info_free(&info);
344349
}
345350
(*file)->state = PNETCDF_DEFINE_MODE;
346351
#endif

0 commit comments

Comments
 (0)