backport array dimension bugfix for NETCDF package in simplified form

This commit is contained in:
Axel Kohlmeyer
2022-01-03 19:55:23 -05:00
parent bc5d742623
commit 5ae496dcef
2 changed files with 17 additions and 9 deletions

View File

@ -65,6 +65,10 @@ static constexpr int THIS_IS_A_COMPUTE = -2;
static constexpr int THIS_IS_A_VARIABLE = -3;
static constexpr int THIS_IS_A_BIGINT = -4;
// to be used instead of NC_MAX_VAR_DIMS which was expected
// to be no larger than 1024 but that is not guaranteed anymore.
static constexpr int LMP_MAX_VAR_DIMS = 1024;
/* ---------------------------------------------------------------------- */
#define NCERR(x) ncerr(x, nullptr, __LINE__)
@ -339,8 +343,8 @@ void DumpNetCDF::openfile()
if (framei != 0 && !multifile)
error->all(FLERR,"at keyword requires use of 'append yes'");
int dims[NC_MAX_VAR_DIMS];
size_t index[NC_MAX_VAR_DIMS], count[NC_MAX_VAR_DIMS];
int dims[LMP_MAX_VAR_DIMS];
size_t index[LMP_MAX_VAR_DIMS], count[NC_MAX_VAR_DIMS];
double d[1];
if (singlefile_opened) return;
@ -735,8 +739,8 @@ void DumpNetCDF::write_header(bigint n)
void DumpNetCDF::write_data(int n, double *mybuf)
{
size_t start[NC_MAX_VAR_DIMS], count[NC_MAX_VAR_DIMS];
ptrdiff_t stride[NC_MAX_VAR_DIMS];
size_t start[LMP_MAX_VAR_DIMS], count[NC_MAX_VAR_DIMS];
ptrdiff_t stride[LMP_MAX_VAR_DIMS];
if (!int_buffer) {
n_buffer = n;

View File

@ -65,6 +65,10 @@ static constexpr int THIS_IS_A_COMPUTE = -2;
static constexpr int THIS_IS_A_VARIABLE = -3;
static constexpr int THIS_IS_A_BIGINT = -4;
// to be used instead of NC_MAX_VAR_DIMS which was expected
// to be no larger than 1024 but that is not guaranteed anymore.
static constexpr int LMP_MAX_VAR_DIMS = 1024;
/* ---------------------------------------------------------------------- */
#define NCERR(x) ncerr(x, nullptr, __LINE__)
@ -275,7 +279,7 @@ void DumpNetCDFMPIIO::openfile()
if (not utils::file_is_readable(filecurrent))
error->all(FLERR, "cannot append to non-existent file {}", filecurrent);
MPI_Offset index[NC_MAX_VAR_DIMS], count[NC_MAX_VAR_DIMS];
MPI_Offset index[LMP_MAX_VAR_DIMS], count[NC_MAX_VAR_DIMS];
double d[1];
if (singlefile_opened) return;
@ -340,8 +344,8 @@ void DumpNetCDFMPIIO::openfile()
if (framei != 0 && !multifile)
error->all(FLERR,"at keyword requires use of 'append yes'");
int dims[NC_MAX_VAR_DIMS];
MPI_Offset index[NC_MAX_VAR_DIMS], count[NC_MAX_VAR_DIMS];
int dims[LMP_MAX_VAR_DIMS];
MPI_Offset index[LMP_MAX_VAR_DIMS], count[NC_MAX_VAR_DIMS];
double d[1];
if (singlefile_opened) return;
@ -753,8 +757,8 @@ void DumpNetCDFMPIIO::write_time_and_cell()
void DumpNetCDFMPIIO::write_data(int n, double *mybuf)
{
MPI_Offset start[NC_MAX_VAR_DIMS], count[NC_MAX_VAR_DIMS];
MPI_Offset stride[NC_MAX_VAR_DIMS];
MPI_Offset start[LMP_MAX_VAR_DIMS], count[NC_MAX_VAR_DIMS];
MPI_Offset stride[LMP_MAX_VAR_DIMS];
if (!int_buffer) {
n_buffer = std::max(1, n);