port changes from dump netcdf to dump netcdf/mpiio

This commit is contained in:
Axel Kohlmeyer
2021-07-18 19:04:08 -04:00
parent 1f9e0adfe9
commit 76ec9b8616

View File

@ -18,53 +18,52 @@
#if defined(LMP_HAS_PNETCDF) #if defined(LMP_HAS_PNETCDF)
#include <cstring>
#include <pnetcdf.h>
#include "dump_netcdf_mpiio.h" #include "dump_netcdf_mpiio.h"
#include "atom.h" #include "atom.h"
#include "comm.h" #include "comm.h"
#include "compute.h" #include "compute.h"
#include "domain.h" #include "domain.h"
#include "error.h" #include "error.h"
#include "fix.h" #include "fix.h"
#include "force.h"
#include "group.h" #include "group.h"
#include "input.h" #include "input.h"
#include "math_const.h" #include "math_const.h"
#include "memory.h" #include "memory.h"
#include "modify.h" #include "modify.h"
#include "update.h"
#include "universe.h"
#include "variable.h"
#include "force.h"
#include "output.h" #include "output.h"
#include "thermo.h" #include "thermo.h"
#include "universe.h"
#include "update.h"
#include "variable.h"
#include <cstring>
#include <pnetcdf.h>
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace MathConst; using namespace MathConst;
enum{THERMO_INT,THERMO_FLOAT,THERMO_BIGINT}; // same as in thermo.cpp static const char NC_FRAME_STR[] = "frame";
enum{DUMP_INT,DUMP_DOUBLE,DUMP_STRING,DUMP_BIGINT}; // same as in DumpCFG static const char NC_SPATIAL_STR[] = "spatial";
static const char NC_VOIGT_STR[] = "Voigt";
static const char NC_ATOM_STR[] = "atom";
static const char NC_CELL_SPATIAL_STR[] = "cell_spatial";
static const char NC_CELL_ANGULAR_STR[] = "cell_angular";
static const char NC_LABEL_STR[] = "label";
const char NC_FRAME_STR[] = "frame"; static const char NC_TIME_STR[] = "time";
const char NC_SPATIAL_STR[] = "spatial"; static const char NC_CELL_ORIGIN_STR[] = "cell_origin";
const char NC_VOIGT_STR[] = "Voigt"; static const char NC_CELL_LENGTHS_STR[] = "cell_lengths";
const char NC_ATOM_STR[] = "atom"; static const char NC_CELL_ANGLES_STR[] = "cell_angles";
const char NC_CELL_SPATIAL_STR[] = "cell_spatial";
const char NC_CELL_ANGULAR_STR[] = "cell_angular";
const char NC_LABEL_STR[] = "label";
const char NC_TIME_STR[] = "time"; static const char NC_UNITS_STR[] = "units";
const char NC_CELL_ORIGIN_STR[] = "cell_origin"; static const char NC_SCALE_FACTOR_STR[] = "scale_factor";
const char NC_CELL_LENGTHS_STR[] = "cell_lengths";
const char NC_CELL_ANGLES_STR[] = "cell_angles";
const char NC_UNITS_STR[] = "units"; static constexpr int THIS_IS_A_FIX = -1;
const char NC_SCALE_FACTOR_STR[] = "scale_factor"; static constexpr int THIS_IS_A_COMPUTE = -2;
static constexpr int THIS_IS_A_VARIABLE = -3;
const int THIS_IS_A_FIX = -1; static constexpr int THIS_IS_A_BIGINT = -4;
const int THIS_IS_A_COMPUTE = -2;
const int THIS_IS_A_VARIABLE = -3;
const int THIS_IS_A_BIGINT = -4;
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -98,77 +97,65 @@ DumpNetCDFMPIIO::DumpNetCDFMPIIO(LAMMPS *lmp, int narg, char **arg) :
} }
n_perat = 0; n_perat = 0;
for (int iarg = 5; iarg < narg; iarg++) { for (int i = 0; i < nfield; i++) {
int i = iarg-5;
int idim = 0; int idim = 0;
int ndims = 1; int ndims = 1;
char mangled[1024]; std::string mangled = earg[i];
bool constant = false;
strcpy(mangled, arg[iarg]);
// name mangling // name mangling
// in the AMBER specification // in the AMBER specification
if (!strcmp(mangled, "x") || !strcmp(mangled, "y") || if ((mangled == "x") || (mangled == "y") || (mangled == "z")) {
!strcmp(mangled, "z")) {
idim = mangled[0] - 'x'; idim = mangled[0] - 'x';
ndims = 3; ndims = 3;
strcpy(mangled, "coordinates"); mangled = "coordinates";
} } else if ((mangled == "vx") || (mangled == "vy") || (mangled == "vz")) {
else if (!strcmp(mangled, "vx") || !strcmp(mangled, "vy") ||
!strcmp(mangled, "vz")) {
idim = mangled[1] - 'x'; idim = mangled[1] - 'x';
ndims = 3; ndims = 3;
strcpy(mangled, "velocities"); mangled = "velocities";
} } else if ((mangled == "xs") || (mangled == "ys") || (mangled == "zs")) {
else if (!strcmp(mangled, "xs") || !strcmp(mangled, "ys") ||
!strcmp(mangled, "zs")) {
idim = mangled[0] - 'x'; idim = mangled[0] - 'x';
ndims = 3; ndims = 3;
strcpy(mangled, "scaled_coordinates"); mangled = "scaled_coordinates";
} } else if ((mangled == "xu") || (mangled == "yu") || (mangled == "zu")) {
else if (!strcmp(mangled, "xu") || !strcmp(mangled, "yu") ||
!strcmp(mangled, "zu")) {
idim = mangled[0] - 'x'; idim = mangled[0] - 'x';
ndims = 3; ndims = 3;
strcpy(mangled, "unwrapped_coordinates"); mangled = "unwrapped_coordinates";
} } else if ((mangled == "fx") || (mangled == "fy") || (mangled == "fz")) {
else if (!strcmp(mangled, "fx") || !strcmp(mangled, "fy") ||
!strcmp(mangled, "fz")) {
idim = mangled[1] - 'x'; idim = mangled[1] - 'x';
ndims = 3; ndims = 3;
strcpy(mangled, "forces"); mangled = "forces";
} } else if ((mangled == "mux") || (mangled == "muy") || (mangled == "muz")) {
else if (!strcmp(mangled, "mux") || !strcmp(mangled, "muy") ||
!strcmp(mangled, "muz")) {
idim = mangled[2] - 'x'; idim = mangled[2] - 'x';
ndims = 3; ndims = 3;
strcpy(mangled, "mu"); mangled = "mu";
} } else if (utils::strmatch(mangled, "^c_")) {
else if (!strncmp(mangled, "c_", 2)) { std::size_t found = mangled.find('[');
char *ptr = strchr(mangled, '['); if (found != std::string::npos) {
if (ptr) { if (mangled.find(']',found) == std::string::npos)
if (mangled[strlen(mangled)-1] != ']')
error->all(FLERR,"Missing ']' in dump command"); error->all(FLERR,"Missing ']' in dump command");
*ptr = '\0'; idim = mangled[found+1] - '1';
idim = ptr[1] - '1'; mangled = mangled.substr(0,found);
ndims = THIS_IS_A_COMPUTE; ndims = THIS_IS_A_COMPUTE;
} }
} } else if (utils::strmatch(mangled, "^f_")) {
else if (!strncmp(mangled, "f_", 2)) { std::size_t found = mangled.find('[');
char *ptr = strchr(mangled, '['); if (found != std::string::npos) {
if (ptr) { if (mangled.find(']',found) == std::string::npos)
if (mangled[strlen(mangled)-1] != ']')
error->all(FLERR,"Missing ']' in dump command"); error->all(FLERR,"Missing ']' in dump command");
*ptr = '\0'; idim = mangled[found+1] - '1';
idim = ptr[1] - '1'; mangled = mangled.substr(0,found);
ndims = THIS_IS_A_FIX; ndims = THIS_IS_A_FIX;
} }
} else if (utils::strmatch(mangled, "^v_")) {
idim = 0;
ndims = THIS_IS_A_VARIABLE;
} }
// find mangled name // find mangled name
int inc = -1; int inc = -1;
for (int j = 0; j < n_perat && inc < 0; j++) { for (int j = 0; j < n_perat && inc < 0; j++) {
if (!strcmp(perat[j].name, mangled)) { if (mangled == perat[j].name) {
inc = j; inc = j;
} }
} }
@ -181,7 +168,7 @@ DumpNetCDFMPIIO::DumpNetCDFMPIIO(LAMMPS *lmp, int narg, char **arg) :
for (int j = 0; j < DUMP_NC_MPIIO_MAX_DIMS; j++) { for (int j = 0; j < DUMP_NC_MPIIO_MAX_DIMS; j++) {
perat[inc].field[j] = -1; perat[inc].field[j] = -1;
} }
strcpy(perat[inc].name, mangled); strncpy(perat[inc].name, mangled.c_str(), NC_MPIIO_FIELD_NAME_MAX);
n_perat++; n_perat++;
} }
@ -206,8 +193,8 @@ DumpNetCDFMPIIO::~DumpNetCDFMPIIO()
{ {
closefile(); closefile();
delete [] perat; delete[] perat;
if (thermovar) delete [] thermovar; if (thermovar) delete[] thermovar;
if (int_buffer) memory->sfree(int_buffer); if (int_buffer) memory->sfree(int_buffer);
if (double_buffer) memory->sfree(double_buffer); if (double_buffer) memory->sfree(double_buffer);
@ -236,7 +223,7 @@ void DumpNetCDFMPIIO::openfile()
} }
if (thermo && !singlefile_opened) { if (thermo && !singlefile_opened) {
if (thermovar) delete [] thermovar; if (thermovar) delete[] thermovar;
thermovar = new int[output->thermo->nfield]; thermovar = new int[output->thermo->nfield];
} }
@ -257,8 +244,7 @@ void DumpNetCDFMPIIO::openfile()
perat[i].dims = compute[j]->size_peratom_cols; perat[i].dims = compute[j]->size_peratom_cols;
if (perat[i].dims > DUMP_NC_MPIIO_MAX_DIMS) if (perat[i].dims > DUMP_NC_MPIIO_MAX_DIMS)
error->all(FLERR,"perat[i].dims > DUMP_NC_MPIIO_MAX_DIMS"); error->all(FLERR,"perat[i].dims > DUMP_NC_MPIIO_MAX_DIMS");
} } else if (perat[i].dims == THIS_IS_A_FIX) {
else if (perat[i].dims == THIS_IS_A_FIX) {
int j = -1; int j = -1;
for (int k = 0; k < DUMP_NC_MPIIO_MAX_DIMS; k++) { for (int k = 0; k < DUMP_NC_MPIIO_MAX_DIMS; k++) {
if (perat[i].field[k] >= 0) { if (perat[i].field[k] >= 0) {
@ -272,6 +258,8 @@ void DumpNetCDFMPIIO::openfile()
perat[i].dims = fix[j]->size_peratom_cols; perat[i].dims = fix[j]->size_peratom_cols;
if (perat[i].dims > DUMP_NC_MPIIO_MAX_DIMS) if (perat[i].dims > DUMP_NC_MPIIO_MAX_DIMS)
error->all(FLERR,"perat[i].dims > DUMP_NC_MPIIO_MAX_DIMS"); error->all(FLERR,"perat[i].dims > DUMP_NC_MPIIO_MAX_DIMS");
} else if (perat[i].dims == THIS_IS_A_VARIABLE) {
error->all(FLERR,"Dump netcdf/mpiio currently does not support dumping variables");
} }
} }
@ -285,8 +273,7 @@ void DumpNetCDFMPIIO::openfile()
// Fixme! Perform checks if dimensions and variables conform with // Fixme! Perform checks if dimensions and variables conform with
// data structure standard. // data structure standard.
if (not utils::file_is_readable(filecurrent)) if (not utils::file_is_readable(filecurrent))
error->all(FLERR, "cannot append to non-existent file {}", error->all(FLERR, "cannot append to non-existent file {}", filecurrent);
filecurrent);
MPI_Offset index[NC_MAX_VAR_DIMS], count[NC_MAX_VAR_DIMS]; MPI_Offset index[NC_MAX_VAR_DIMS], count[NC_MAX_VAR_DIMS];
double d[1]; double d[1];
@ -294,16 +281,13 @@ void DumpNetCDFMPIIO::openfile()
if (singlefile_opened) return; if (singlefile_opened) return;
singlefile_opened = 1; singlefile_opened = 1;
NCERRX( ncmpi_open(world, filecurrent, NC_WRITE, MPI_INFO_NULL, NCERRX( ncmpi_open(world, filecurrent, NC_WRITE, MPI_INFO_NULL, &ncid), filecurrent );
&ncid), filecurrent );
// dimensions // dimensions
NCERRX( ncmpi_inq_dimid(ncid, NC_FRAME_STR, &frame_dim), NC_FRAME_STR ); NCERRX( ncmpi_inq_dimid(ncid, NC_FRAME_STR, &frame_dim), NC_FRAME_STR );
NCERRX( ncmpi_inq_dimid(ncid, NC_ATOM_STR, &atom_dim), NC_ATOM_STR ); NCERRX( ncmpi_inq_dimid(ncid, NC_ATOM_STR, &atom_dim), NC_ATOM_STR );
NCERRX( ncmpi_inq_dimid(ncid, NC_CELL_SPATIAL_STR, &cell_spatial_dim), NCERRX( ncmpi_inq_dimid(ncid, NC_CELL_SPATIAL_STR, &cell_spatial_dim), NC_CELL_SPATIAL_STR );
NC_CELL_SPATIAL_STR ); NCERRX( ncmpi_inq_dimid(ncid, NC_CELL_ANGULAR_STR, &cell_angular_dim), NC_CELL_ANGULAR_STR );
NCERRX( ncmpi_inq_dimid(ncid, NC_CELL_ANGULAR_STR, &cell_angular_dim),
NC_CELL_ANGULAR_STR );
NCERRX( ncmpi_inq_dimid(ncid, NC_LABEL_STR, &label_dim), NC_LABEL_STR ); NCERRX( ncmpi_inq_dimid(ncid, NC_LABEL_STR, &label_dim), NC_LABEL_STR );
for (int i = 0; i < n_perat; i++) { for (int i = 0; i < n_perat; i++) {
@ -312,48 +296,37 @@ void DumpNetCDFMPIIO::openfile()
char dimstr[1024]; char dimstr[1024];
if (dims == 3) { if (dims == 3) {
strcpy(dimstr, NC_SPATIAL_STR); strcpy(dimstr, NC_SPATIAL_STR);
} } else if (dims == 6) {
else if (dims == 6) {
strcpy(dimstr, NC_VOIGT_STR); strcpy(dimstr, NC_VOIGT_STR);
} } else {
else {
sprintf(dimstr, "vec%i", dims); sprintf(dimstr, "vec%i", dims);
} }
if (dims != 1) { if (dims != 1) {
NCERRX( ncmpi_inq_dimid(ncid, dimstr, &vector_dim[dims]), NCERRX( ncmpi_inq_dimid(ncid, dimstr, &vector_dim[dims]), dimstr );
dimstr );
} }
} }
} }
// default variables // default variables
NCERRX( ncmpi_inq_varid(ncid, NC_SPATIAL_STR, &spatial_var), NCERRX( ncmpi_inq_varid(ncid, NC_SPATIAL_STR, &spatial_var), NC_SPATIAL_STR );
NC_SPATIAL_STR ); NCERRX( ncmpi_inq_varid(ncid, NC_CELL_SPATIAL_STR, &cell_spatial_var), NC_CELL_SPATIAL_STR);
NCERRX( ncmpi_inq_varid(ncid, NC_CELL_SPATIAL_STR, &cell_spatial_var), NCERRX( ncmpi_inq_varid(ncid, NC_CELL_ANGULAR_STR, &cell_angular_var), NC_CELL_ANGULAR_STR);
NC_CELL_SPATIAL_STR);
NCERRX( ncmpi_inq_varid(ncid, NC_CELL_ANGULAR_STR, &cell_angular_var),
NC_CELL_ANGULAR_STR);
NCERRX( ncmpi_inq_varid(ncid, NC_TIME_STR, &time_var), NC_TIME_STR ); NCERRX( ncmpi_inq_varid(ncid, NC_TIME_STR, &time_var), NC_TIME_STR );
NCERRX( ncmpi_inq_varid(ncid, NC_CELL_ORIGIN_STR, &cell_origin_var), NCERRX( ncmpi_inq_varid(ncid, NC_CELL_ORIGIN_STR, &cell_origin_var), NC_CELL_ORIGIN_STR );
NC_CELL_ORIGIN_STR ); NCERRX( ncmpi_inq_varid(ncid, NC_CELL_LENGTHS_STR, &cell_lengths_var), NC_CELL_LENGTHS_STR);
NCERRX( ncmpi_inq_varid(ncid, NC_CELL_LENGTHS_STR, &cell_lengths_var), NCERRX( ncmpi_inq_varid(ncid, NC_CELL_ANGLES_STR, &cell_angles_var), NC_CELL_ANGLES_STR);
NC_CELL_LENGTHS_STR);
NCERRX( ncmpi_inq_varid(ncid, NC_CELL_ANGLES_STR, &cell_angles_var),
NC_CELL_ANGLES_STR);
// variables specified in the input file // variables specified in the input file
for (int i = 0; i < n_perat; i++) { for (int i = 0; i < n_perat; i++) {
NCERRX( ncmpi_inq_varid(ncid, perat[i].name, &perat[i].var), NCERRX( ncmpi_inq_varid(ncid, perat[i].name, &perat[i].var), perat[i].name );
perat[i].name );
} }
// perframe variables // perframe variables
if (thermo) { if (thermo) {
Thermo *th = output->thermo; Thermo *th = output->thermo;
for (int i = 0; i < th->nfield; i++) { for (int i = 0; i < th->nfield; i++) {
NCERRX( ncmpi_inq_varid(ncid, th->keyword[i], &thermovar[i]), NCERRX( ncmpi_inq_varid(ncid, th->keyword[i], &thermovar[i]), th->keyword[i] );
th->keyword[i] );
} }
} }
@ -374,20 +347,14 @@ void DumpNetCDFMPIIO::openfile()
if (singlefile_opened) return; if (singlefile_opened) return;
singlefile_opened = 1; singlefile_opened = 1;
NCERRX( ncmpi_create(world, filecurrent, NC_64BIT_DATA, NCERRX( ncmpi_create(world, filecurrent, NC_64BIT_DATA, MPI_INFO_NULL, &ncid), filecurrent );
MPI_INFO_NULL, &ncid), filecurrent );
// dimensions // dimensions
NCERRX( ncmpi_def_dim(ncid, NC_FRAME_STR, NC_UNLIMITED, &frame_dim), NCERRX( ncmpi_def_dim(ncid, NC_FRAME_STR, NC_UNLIMITED, &frame_dim), NC_FRAME_STR );
NC_FRAME_STR ); NCERRX( ncmpi_def_dim(ncid, NC_ATOM_STR, ntotalgr, &atom_dim), NC_ATOM_STR );
NCERRX( ncmpi_def_dim(ncid, NC_ATOM_STR, ntotalgr, &atom_dim), NCERRX( ncmpi_def_dim(ncid, NC_CELL_SPATIAL_STR, 3, &cell_spatial_dim), NC_CELL_SPATIAL_STR );
NC_ATOM_STR ); NCERRX( ncmpi_def_dim(ncid, NC_CELL_ANGULAR_STR, 3, &cell_angular_dim), NC_CELL_ANGULAR_STR );
NCERRX( ncmpi_def_dim(ncid, NC_CELL_SPATIAL_STR, 3, &cell_spatial_dim), NCERRX( ncmpi_def_dim(ncid, NC_LABEL_STR, 10, &label_dim), NC_LABEL_STR );
NC_CELL_SPATIAL_STR );
NCERRX( ncmpi_def_dim(ncid, NC_CELL_ANGULAR_STR, 3, &cell_angular_dim),
NC_CELL_ANGULAR_STR );
NCERRX( ncmpi_def_dim(ncid, NC_LABEL_STR, 10, &label_dim),
NC_LABEL_STR );
for (int i = 0; i < n_perat; i++) { for (int i = 0; i < n_perat; i++) {
int dims = perat[i].dims; int dims = perat[i].dims;
@ -395,44 +362,34 @@ void DumpNetCDFMPIIO::openfile()
char dimstr[1024]; char dimstr[1024];
if (dims == 3) { if (dims == 3) {
strcpy(dimstr, NC_SPATIAL_STR); strcpy(dimstr, NC_SPATIAL_STR);
} } else if (dims == 6) {
else if (dims == 6) {
strcpy(dimstr, NC_VOIGT_STR); strcpy(dimstr, NC_VOIGT_STR);
} } else {
else {
sprintf(dimstr, "vec%i", dims); sprintf(dimstr, "vec%i", dims);
} }
if (dims != 1) { if (dims != 1) {
NCERRX( ncmpi_def_dim(ncid, dimstr, dims, &vector_dim[dims]), NCERRX( ncmpi_def_dim(ncid, dimstr, dims, &vector_dim[dims]), dimstr );
dimstr );
} }
} }
} }
// default variables // default variables
dims[0] = vector_dim[3]; dims[0] = vector_dim[3];
NCERRX( ncmpi_def_var(ncid, NC_SPATIAL_STR, NC_CHAR, 1, dims, &spatial_var), NCERRX( ncmpi_def_var(ncid, NC_SPATIAL_STR, NC_CHAR, 1, dims, &spatial_var), NC_SPATIAL_STR );
NC_SPATIAL_STR ); NCERRX( ncmpi_def_var(ncid, NC_CELL_SPATIAL_STR, NC_CHAR, 1, dims, &cell_spatial_var), NC_CELL_SPATIAL_STR );
NCERRX( ncmpi_def_var(ncid, NC_CELL_SPATIAL_STR, NC_CHAR, 1, dims,
&cell_spatial_var), NC_CELL_SPATIAL_STR );
dims[0] = vector_dim[3]; dims[0] = vector_dim[3];
dims[1] = label_dim; dims[1] = label_dim;
NCERRX( ncmpi_def_var(ncid, NC_CELL_ANGULAR_STR, NC_CHAR, 2, dims, NCERRX( ncmpi_def_var(ncid, NC_CELL_ANGULAR_STR, NC_CHAR, 2, dims, &cell_angular_var), NC_CELL_ANGULAR_STR );
&cell_angular_var), NC_CELL_ANGULAR_STR );
dims[0] = frame_dim; dims[0] = frame_dim;
NCERRX( ncmpi_def_var(ncid, NC_TIME_STR, NC_DOUBLE, 1, dims, &time_var), NCERRX( ncmpi_def_var(ncid, NC_TIME_STR, NC_DOUBLE, 1, dims, &time_var), NC_TIME_STR);
NC_TIME_STR);
dims[0] = frame_dim; dims[0] = frame_dim;
dims[1] = cell_spatial_dim; dims[1] = cell_spatial_dim;
NCERRX( ncmpi_def_var(ncid, NC_CELL_ORIGIN_STR, NC_DOUBLE, 2, dims, NCERRX( ncmpi_def_var(ncid, NC_CELL_ORIGIN_STR, NC_DOUBLE, 2, dims, &cell_origin_var), NC_CELL_ORIGIN_STR );
&cell_origin_var), NC_CELL_ORIGIN_STR ); NCERRX( ncmpi_def_var(ncid, NC_CELL_LENGTHS_STR, NC_DOUBLE, 2, dims, &cell_lengths_var), NC_CELL_LENGTHS_STR );
NCERRX( ncmpi_def_var(ncid, NC_CELL_LENGTHS_STR, NC_DOUBLE, 2, dims,
&cell_lengths_var), NC_CELL_LENGTHS_STR );
dims[0] = frame_dim; dims[0] = frame_dim;
dims[1] = cell_angular_dim; dims[1] = cell_angular_dim;
NCERRX( ncmpi_def_var(ncid, NC_CELL_ANGLES_STR, NC_DOUBLE, 2, dims, NCERRX( ncmpi_def_var(ncid, NC_CELL_ANGLES_STR, NC_DOUBLE, 2, dims, &cell_angles_var), NC_CELL_ANGLES_STR );
&cell_angles_var), NC_CELL_ANGLES_STR );
// variables specified in the input file // variables specified in the input file
dims[0] = frame_dim; dims[0] = frame_dim;
@ -443,9 +400,9 @@ void DumpNetCDFMPIIO::openfile()
nc_type xtype; nc_type xtype;
// Type mangling // Type mangling
if (vtype[perat[i].field[0]] == DUMP_INT) { if (vtype[perat[i].field[0]] == Dump::INT) {
xtype = NC_INT; xtype = NC_INT;
} else if (vtype[perat[i].field[0]] == DUMP_BIGINT) { } else if (vtype[perat[i].field[0]] == Dump::BIGINT) {
xtype = NC_INT64; xtype = NC_INT64;
} else { } else {
if (double_precision) if (double_precision)
@ -455,14 +412,11 @@ void DumpNetCDFMPIIO::openfile()
} }
if (perat[i].dims == 1) { if (perat[i].dims == 1) {
NCERRX( ncmpi_def_var(ncid, perat[i].name, xtype, 2, dims, NCERRX( ncmpi_def_var(ncid, perat[i].name, xtype, 2, dims, &perat[i].var), perat[i].name );
&perat[i].var), perat[i].name ); } else {
}
else {
// this is a vector // this is a vector
dims[2] = vector_dim[perat[i].dims]; dims[2] = vector_dim[perat[i].dims];
NCERRX( ncmpi_def_var(ncid, perat[i].name, xtype, 3, dims, NCERRX( ncmpi_def_var(ncid, perat[i].name, xtype, 3, dims, &perat[i].var), perat[i].name );
&perat[i].var), perat[i].name );
} }
} }
@ -470,104 +424,64 @@ void DumpNetCDFMPIIO::openfile()
if (thermo) { if (thermo) {
Thermo *th = output->thermo; Thermo *th = output->thermo;
for (int i = 0; i < th->nfield; i++) { for (int i = 0; i < th->nfield; i++) {
if (th->vtype[i] == THERMO_FLOAT) { if (th->vtype[i] == Thermo::FLOAT) {
NCERRX( ncmpi_def_var(ncid, th->keyword[i], NC_DOUBLE, 1, dims, NCERRX( ncmpi_def_var(ncid, th->keyword[i], NC_DOUBLE, 1, dims, &thermovar[i]), th->keyword[i] );
&thermovar[i]), th->keyword[i] ); } else if (th->vtype[i] == Thermo::INT) {
} NCERRX( ncmpi_def_var(ncid, th->keyword[i], NC_INT, 1, dims, &thermovar[i]), th->keyword[i] );
else if (th->vtype[i] == THERMO_INT) { } else if (th->vtype[i] == Thermo::BIGINT) {
NCERRX( ncmpi_def_var(ncid, th->keyword[i], NC_INT, 1, dims,
&thermovar[i]), th->keyword[i] );
}
else if (th->vtype[i] == THERMO_BIGINT) {
#if defined(LAMMPS_SMALLBIG) || defined(LAMMPS_BIGBIG) #if defined(LAMMPS_SMALLBIG) || defined(LAMMPS_BIGBIG)
NCERRX( ncmpi_def_var(ncid, th->keyword[i], NC_INT64, 1, dims, NCERRX( ncmpi_def_var(ncid, th->keyword[i], NC_INT64, 1, dims, &thermovar[i]), th->keyword[i] );
&thermovar[i]), th->keyword[i] );
#else #else
NCERRX( ncmpi_def_var(ncid, th->keyword[i], NC_LONG, 1, dims, NCERRX( ncmpi_def_var(ncid, th->keyword[i], NC_LONG, 1, dims, &thermovar[i]), th->keyword[i] );
&thermovar[i]), th->keyword[i] );
#endif #endif
} }
} }
} }
// attributes // attributes
NCERR( ncmpi_put_att_text(ncid, NC_GLOBAL, "Conventions", NCERR( ncmpi_put_att_text(ncid, NC_GLOBAL, "Conventions", 5, "AMBER") );
5, "AMBER") ); NCERR( ncmpi_put_att_text(ncid, NC_GLOBAL, "ConventionVersion", 3, "1.0") );
NCERR( ncmpi_put_att_text(ncid, NC_GLOBAL, "ConventionVersion",
3, "1.0") );
NCERR( ncmpi_put_att_text(ncid, NC_GLOBAL, "program", NCERR( ncmpi_put_att_text(ncid, NC_GLOBAL, "program", 6, "LAMMPS") );
6, "LAMMPS") ); NCERR( ncmpi_put_att_text(ncid, NC_GLOBAL, "programVersion", strlen(lmp->version), lmp->version) );
NCERR( ncmpi_put_att_text(ncid, NC_GLOBAL, "programVersion",
strlen(lmp->version), lmp->version) );
// units // units
if (!strcmp(update->unit_style, "lj")) { if (!strcmp(update->unit_style, "lj")) {
NCERR( ncmpi_put_att_text(ncid, time_var, NC_UNITS_STR, NCERR( ncmpi_put_att_text(ncid, time_var, NC_UNITS_STR, 2, "lj") );
2, "lj") ); NCERR( ncmpi_put_att_text(ncid, cell_origin_var, NC_UNITS_STR, 2, "lj") );
NCERR( ncmpi_put_att_text(ncid, cell_origin_var, NC_UNITS_STR, NCERR( ncmpi_put_att_text(ncid, cell_lengths_var, NC_UNITS_STR, 2, "lj") );
2, "lj") ); } else if (!strcmp(update->unit_style, "real")) {
NCERR( ncmpi_put_att_text(ncid, cell_lengths_var, NC_UNITS_STR, NCERR( ncmpi_put_att_text(ncid, time_var, NC_UNITS_STR, 11, "femtosecond") );
2, "lj") ); NCERR( ncmpi_put_att_text(ncid, cell_origin_var, NC_UNITS_STR, 8, "Angstrom") );
} NCERR( ncmpi_put_att_text(ncid, cell_lengths_var, NC_UNITS_STR, 8, "Angstrom") );
else if (!strcmp(update->unit_style, "real")) { } else if (!strcmp(update->unit_style, "metal")) {
NCERR( ncmpi_put_att_text(ncid, time_var, NC_UNITS_STR, NCERR( ncmpi_put_att_text(ncid, time_var, NC_UNITS_STR, 10, "picosecond") );
11, "femtosecond") ); NCERR( ncmpi_put_att_text(ncid, cell_origin_var, NC_UNITS_STR, 8, "Angstrom") );
NCERR( ncmpi_put_att_text(ncid, cell_origin_var, NC_UNITS_STR, NCERR( ncmpi_put_att_text(ncid, cell_lengths_var, NC_UNITS_STR, 8, "Angstrom") );
8, "Angstrom") ); } else if (!strcmp(update->unit_style, "si")) {
NCERR( ncmpi_put_att_text(ncid, cell_lengths_var, NC_UNITS_STR, NCERR( ncmpi_put_att_text(ncid, time_var, NC_UNITS_STR, 6, "second") );
8, "Angstrom") ); NCERR( ncmpi_put_att_text(ncid, cell_origin_var, NC_UNITS_STR, 5, "meter") );
} NCERR( ncmpi_put_att_text(ncid, cell_lengths_var, NC_UNITS_STR, 5, "meter") );
else if (!strcmp(update->unit_style, "metal")) { } else if (!strcmp(update->unit_style, "cgs")) {
NCERR( ncmpi_put_att_text(ncid, time_var, NC_UNITS_STR, NCERR( ncmpi_put_att_text(ncid, time_var, NC_UNITS_STR, 6, "second") );
10, "picosecond") ); NCERR( ncmpi_put_att_text(ncid, cell_origin_var, NC_UNITS_STR, 10, "centimeter") );
NCERR( ncmpi_put_att_text(ncid, cell_origin_var, NC_UNITS_STR, NCERR( ncmpi_put_att_text(ncid, cell_lengths_var, NC_UNITS_STR, 10, "centimeter") );
8, "Angstrom") ); } else if (!strcmp(update->unit_style, "electron")) {
NCERR( ncmpi_put_att_text(ncid, cell_lengths_var, NC_UNITS_STR, NCERR( ncmpi_put_att_text(ncid, time_var, NC_UNITS_STR, 11, "femtosecond") );
8, "Angstrom") ); NCERR( ncmpi_put_att_text(ncid, cell_origin_var, NC_UNITS_STR, 4, "Bohr") );
} NCERR( ncmpi_put_att_text(ncid, cell_lengths_var, NC_UNITS_STR, 4, "Bohr") );
else if (!strcmp(update->unit_style, "si")) { } else {
NCERR( ncmpi_put_att_text(ncid, time_var, NC_UNITS_STR, error->all(FLERR,"Unsupported unit style: {}", update->unit_style);
6, "second") );
NCERR( ncmpi_put_att_text(ncid, cell_origin_var, NC_UNITS_STR,
5, "meter") );
NCERR( ncmpi_put_att_text(ncid, cell_lengths_var, NC_UNITS_STR,
5, "meter") );
}
else if (!strcmp(update->unit_style, "cgs")) {
NCERR( ncmpi_put_att_text(ncid, time_var, NC_UNITS_STR,
6, "second") );
NCERR( ncmpi_put_att_text(ncid, cell_origin_var, NC_UNITS_STR,
10, "centimeter") );
NCERR( ncmpi_put_att_text(ncid, cell_lengths_var, NC_UNITS_STR,
10, "centimeter") );
}
else if (!strcmp(update->unit_style, "electron")) {
NCERR( ncmpi_put_att_text(ncid, time_var, NC_UNITS_STR,
11, "femtosecond") );
NCERR( ncmpi_put_att_text(ncid, cell_origin_var, NC_UNITS_STR,
4, "Bohr") );
NCERR( ncmpi_put_att_text(ncid, cell_lengths_var, NC_UNITS_STR,
4, "Bohr") );
}
else {
char errstr[1024];
sprintf(errstr, "Unsupported unit style '%s'", update->unit_style);
error->all(FLERR,errstr);
} }
NCERR( ncmpi_put_att_text(ncid, cell_angles_var, NC_UNITS_STR, NCERR( ncmpi_put_att_text(ncid, cell_angles_var, NC_UNITS_STR, 6, "degree") );
6, "degree") );
d[0] = update->dt; d[0] = update->dt;
NCERR( ncmpi_put_att_double(ncid, time_var, NC_SCALE_FACTOR_STR, NCERR( ncmpi_put_att_double(ncid, time_var, NC_SCALE_FACTOR_STR, NC_DOUBLE, 1, d) );
NC_DOUBLE, 1, d) );
d[0] = 1.0; d[0] = 1.0;
NCERR( ncmpi_put_att_double(ncid, cell_origin_var, NC_SCALE_FACTOR_STR, NCERR( ncmpi_put_att_double(ncid, cell_origin_var, NC_SCALE_FACTOR_STR, NC_DOUBLE, 1, d) );
NC_DOUBLE, 1, d) );
d[0] = 1.0; d[0] = 1.0;
NCERR( ncmpi_put_att_double(ncid, cell_lengths_var, NC_SCALE_FACTOR_STR, NCERR( ncmpi_put_att_double(ncid, cell_lengths_var, NC_SCALE_FACTOR_STR, NC_DOUBLE, 1, d) );
NC_DOUBLE, 1, d) );
/* /*
* Finished with definition * Finished with definition
@ -628,23 +542,21 @@ void DumpNetCDFMPIIO::closefile()
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
template <typename T> template <typename T>
int ncmpi_put_var1_bigint(int ncid, int varid, const MPI_Offset index[], int ncmpi_put_var1_bigint(int ncid, int varid, const MPI_Offset index[], const T* tp)
const T* tp)
{ {
return ncmpi_put_var1_int(ncid, varid, index, tp); return ncmpi_put_var1_int(ncid, varid, index, tp);
} }
template <> template <>
int ncmpi_put_var1_bigint<long>(int ncid, int varid, const MPI_Offset index[], int ncmpi_put_var1_bigint<long>(int ncid, int varid,
const long* tp) const MPI_Offset index[], const long* tp)
{ {
return ncmpi_put_var1_long(ncid, varid, index, tp); return ncmpi_put_var1_long(ncid, varid, index, tp);
} }
template <> template <>
int ncmpi_put_var1_bigint<long long>(int ncid, int varid, int ncmpi_put_var1_bigint<long long>(int ncid, int varid,
const MPI_Offset index[], const MPI_Offset index[], const long long* tp)
const long long* tp)
{ {
return ncmpi_put_var1_longlong(ncid, varid, index, tp); return ncmpi_put_var1_longlong(ncid, varid, index, tp);
} }
@ -657,45 +569,36 @@ int ncmpi_put_vara_bigint_all(int ncid, int varid, const MPI_Offset start[],
} }
template <> template <>
int ncmpi_put_vara_bigint_all<long>(int ncid, int varid, int ncmpi_put_vara_bigint_all<long>(int ncid, int varid, const MPI_Offset start[],
const MPI_Offset start[],
const MPI_Offset count[], const long* tp) const MPI_Offset count[], const long* tp)
{ {
return ncmpi_put_vara_long_all(ncid, varid, start, count, tp); return ncmpi_put_vara_long_all(ncid, varid, start, count, tp);
} }
template <> template <>
int ncmpi_put_vara_bigint_all<long long>(int ncid, int varid, int ncmpi_put_vara_bigint_all<long long>(int ncid, int varid, const MPI_Offset start[],
const MPI_Offset start[], const MPI_Offset count[], const long long* tp)
const MPI_Offset count[],
const long long* tp)
{ {
return ncmpi_put_vara_longlong_all(ncid, varid, start, count, tp); return ncmpi_put_vara_longlong_all(ncid, varid, start, count, tp);
} }
template <typename T> template <typename T>
int ncmpi_put_vars_bigint_all(int ncid, int varid, const MPI_Offset start[], int ncmpi_put_vars_bigint_all(int ncid, int varid, const MPI_Offset start[],
const MPI_Offset count[], const MPI_Offset count[], const MPI_Offset stride[], const T* tp)
const MPI_Offset stride[], const T* tp)
{ {
return ncmpi_put_vars_int_all(ncid, varid, start, count, stride, tp); return ncmpi_put_vars_int_all(ncid, varid, start, count, stride, tp);
} }
template <> template <>
int ncmpi_put_vars_bigint_all<long>(int ncid, int varid, int ncmpi_put_vars_bigint_all<long>(int ncid, int varid, const MPI_Offset start[], const MPI_Offset count[],
const MPI_Offset start[],
const MPI_Offset count[],
const MPI_Offset stride[], const long* tp) const MPI_Offset stride[], const long* tp)
{ {
return ncmpi_put_vars_long_all(ncid, varid, start, count, stride, tp); return ncmpi_put_vars_long_all(ncid, varid, start, count, stride, tp);
} }
template <> template <>
int ncmpi_put_vars_bigint_all<long long>(int ncid, int varid, int ncmpi_put_vars_bigint_all<long long>(int ncid, int varid, const MPI_Offset start[], const MPI_Offset count[],
const MPI_Offset start[], const MPI_Offset stride[], const long long* tp)
const MPI_Offset count[],
const MPI_Offset stride[],
const long long* tp)
{ {
return ncmpi_put_vars_longlong_all(ncid, varid, start, count, stride, tp); return ncmpi_put_vars_longlong_all(ncid, varid, start, count, stride, tp);
} }
@ -723,16 +626,14 @@ void DumpNetCDFMPIIO::write()
for (int i = 0; i < th->nfield; i++) { for (int i = 0; i < th->nfield; i++) {
th->call_vfunc(i); th->call_vfunc(i);
if (filewriter) { if (filewriter) {
if (th->vtype[i] == THERMO_FLOAT) { if (th->vtype[i] == Thermo::FLOAT) {
NCERRX( ncmpi_put_var1_double(ncid, thermovar[i], start, NCERRX( ncmpi_put_var1_double(ncid, thermovar[i], start,
&th->dvalue), &th->dvalue),
th->keyword[i] ); th->keyword[i] );
} } else if (th->vtype[i] == Thermo::INT) {
else if (th->vtype[i] == THERMO_INT) {
NCERRX( ncmpi_put_var1_int(ncid, thermovar[i], start, &th->ivalue), NCERRX( ncmpi_put_var1_int(ncid, thermovar[i], start, &th->ivalue),
th->keyword[i] ); th->keyword[i] );
} } else if (th->vtype[i] == Thermo::BIGINT) {
else if (th->vtype[i] == THERMO_BIGINT) {
NCERRX( ncmpi_put_var1_bigint(ncid, thermovar[i], start, &th->bivalue), NCERRX( ncmpi_put_var1_bigint(ncid, thermovar[i], start, &th->bivalue),
th->keyword[i] ); th->keyword[i] );
} }
@ -753,7 +654,7 @@ void DumpNetCDFMPIIO::write()
MPI_Allgather(&nme, 1, MPI_INT, block_sizes, 1, MPI_INT, world); MPI_Allgather(&nme, 1, MPI_INT, block_sizes, 1, MPI_INT, world);
blocki = 0; blocki = 0;
for (int i = 0; i < comm->me; i++) blocki += block_sizes[i]; for (int i = 0; i < comm->me; i++) blocki += block_sizes[i];
delete [] block_sizes; delete[] block_sizes;
// insure buf is sized for packing and communicating // insure buf is sized for packing and communicating
// use nme to insure filewriter proc can receive info from others // use nme to insure filewriter proc can receive info from others
@ -805,8 +706,7 @@ void DumpNetCDFMPIIO::write_time_and_cell()
cell_angles[0] = 90; cell_angles[0] = 90;
cell_angles[1] = 90; cell_angles[1] = 90;
cell_angles[2] = 90; cell_angles[2] = 90;
} } else {
else {
double cosalpha, cosbeta, cosgamma; double cosalpha, cosbeta, cosgamma;
double *h = domain->h; double *h = domain->h;
@ -839,12 +739,9 @@ void DumpNetCDFMPIIO::write_time_and_cell()
count[1] = 3; count[1] = 3;
if (filewriter) { if (filewriter) {
NCERR( ncmpi_put_var1_double(ncid, time_var, start, &time) ); NCERR( ncmpi_put_var1_double(ncid, time_var, start, &time) );
NCERR( ncmpi_put_vara_double(ncid, cell_origin_var, start, count, NCERR( ncmpi_put_vara_double(ncid, cell_origin_var, start, count, cell_origin) );
cell_origin) ); NCERR( ncmpi_put_vara_double(ncid, cell_lengths_var, start, count, cell_lengths) );
NCERR( ncmpi_put_vara_double(ncid, cell_lengths_var, start, count, NCERR( ncmpi_put_vara_double(ncid, cell_angles_var, start, count, cell_angles) );
cell_lengths) );
NCERR( ncmpi_put_vara_double(ncid, cell_angles_var, start, count,
cell_angles) );
} }
} }
@ -872,8 +769,7 @@ void DumpNetCDFMPIIO::write_data(int n, double *mybuf)
int_buffer = (bigint *) int_buffer = (bigint *)
memory->srealloc(int_buffer, n_buffer*sizeof(bigint),"dump::int_buffer"); memory->srealloc(int_buffer, n_buffer*sizeof(bigint),"dump::int_buffer");
double_buffer = (double *) double_buffer = (double *)
memory->srealloc(double_buffer, n_buffer*sizeof(double), memory->srealloc(double_buffer, n_buffer*sizeof(double), "dump::double_buffer");
"dump::double_buffer");
} }
start[0] = framei-1; start[0] = framei-1;
@ -896,14 +792,10 @@ void DumpNetCDFMPIIO::write_data(int n, double *mybuf)
for (int i = 0; i < n_perat; i++) { for (int i = 0; i < n_perat; i++) {
int iaux = perat[i].field[0]; int iaux = perat[i].field[0];
if (iaux < 0 || iaux >= size_one) { if (iaux < 0 || iaux >= size_one)
char errmsg[1024]; error->one(FLERR, "Internal error: name = {}, iaux = {}, size_one = {}", perat[i].name, iaux, size_one);
sprintf(errmsg, "Internal error: name = %s, iaux = %i, "
"size_one = %i", perat[i].name, iaux, size_one);
error->one(FLERR,errmsg);
}
if (vtype[iaux] == DUMP_INT || vtype[iaux] == DUMP_BIGINT) { if (vtype[iaux] == Dump::INT || vtype[iaux] == Dump::BIGINT) {
// integers // integers
if (perat[i].dims > 1) { if (perat[i].dims > 1) {
@ -911,41 +803,31 @@ void DumpNetCDFMPIIO::write_data(int n, double *mybuf)
iaux = perat[i].field[idim]; iaux = perat[i].field[idim];
if (iaux >= 0) { if (iaux >= 0) {
if (iaux >= size_one) { if (iaux >= size_one)
char errmsg[1024]; error->one(FLERR, "Internal error: name = {}, iaux = {}, size_one = {}", perat[i].name, iaux, size_one);
sprintf(errmsg, "Internal error: name = %s, iaux = %i, "
"size_one = %i", perat[i].name, iaux, size_one);
error->one(FLERR,errmsg);
}
if (vtype[iaux] == DUMP_INT) { if (vtype[iaux] == Dump::INT) {
for (int j = 0; j < n; j++, iaux+=size_one) { for (int j = 0; j < n; j++, iaux+=size_one) {
int_buffer[j] = static_cast<int>(mybuf[iaux]); int_buffer[j] = static_cast<int>(mybuf[iaux]);
} }
} } else { // Dump::BIGINT
else { // DUMP_BIGINT
for (int j = 0; j < n; j++, iaux+=size_one) { for (int j = 0; j < n; j++, iaux+=size_one) {
int_buffer[j] = static_cast<bigint>(mybuf[iaux]); int_buffer[j] = static_cast<bigint>(mybuf[iaux]);
} }
} }
start[2] = idim; start[2] = idim;
NCERRX( ncmpi_put_vars_bigint_all(ncid, perat[i].var, start, count, NCERRX( ncmpi_put_vars_bigint_all(ncid, perat[i].var, start, count,stride, int_buffer), perat[i].name );
stride, int_buffer),
perat[i].name );
} }
} }
} } else {
else {
for (int j = 0; j < n; j++, iaux+=size_one) { for (int j = 0; j < n; j++, iaux+=size_one) {
int_buffer[j] = mybuf[iaux]; int_buffer[j] = mybuf[iaux];
} }
NCERRX( ncmpi_put_vara_bigint_all(ncid, perat[i].var, start, count, NCERRX( ncmpi_put_vara_bigint_all(ncid, perat[i].var, start, count, int_buffer), perat[i].name );
int_buffer), perat[i].name );
} }
} } else {
else {
// doubles // doubles
if (perat[i].dims > 1) { if (perat[i].dims > 1) {
@ -953,12 +835,8 @@ void DumpNetCDFMPIIO::write_data(int n, double *mybuf)
iaux = perat[i].field[idim]; iaux = perat[i].field[idim];
if (iaux >= 0) { if (iaux >= 0) {
if (iaux >= size_one) { if (iaux >= size_one)
char errmsg[1024]; error->one(FLERR, "Internal error: name = {}, iaux = {}, size_one = {}", perat[i].name, iaux, size_one);
sprintf(errmsg, "Internal error: name = %s, iaux = %i, "
"size_one = %i", perat[i].name, iaux, size_one);
error->one(FLERR,errmsg);
}
for (int j = 0; j < n; j++, iaux+=size_one) { for (int j = 0; j < n; j++, iaux+=size_one) {
double_buffer[j] = mybuf[iaux]; double_buffer[j] = mybuf[iaux];
@ -969,8 +847,7 @@ void DumpNetCDFMPIIO::write_data(int n, double *mybuf)
stride, double_buffer), perat[i].name ); stride, double_buffer), perat[i].name );
} }
} }
} } else {
else {
for (int j = 0; j < n; j++, iaux+=size_one) { for (int j = 0; j < n; j++, iaux+=size_one) {
double_buffer[j] = mybuf[iaux]; double_buffer[j] = mybuf[iaux];
} }
@ -993,15 +870,12 @@ int DumpNetCDFMPIIO::modify_param(int narg, char **arg)
error->all(FLERR,"expected 'yes' or 'no' after 'double' keyword."); error->all(FLERR,"expected 'yes' or 'no' after 'double' keyword.");
if (strcmp(arg[iarg],"yes") == 0) { if (strcmp(arg[iarg],"yes") == 0) {
double_precision = true; double_precision = true;
} } else if (strcmp(arg[iarg],"no") == 0) {
else if (strcmp(arg[iarg],"no") == 0) {
double_precision = false; double_precision = false;
} } else error->all(FLERR,"expected 'yes' or 'no' after 'double' keyword.");
else error->all(FLERR,"expected 'yes' or 'no' after 'double' keyword.");
iarg++; iarg++;
return 2; return 2;
} } else if (strcmp(arg[iarg],"at") == 0) {
else if (strcmp(arg[iarg],"at") == 0) {
iarg++; iarg++;
if (iarg >= narg) if (iarg >= narg)
error->all(FLERR,"expected additional arg after 'at' keyword."); error->all(FLERR,"expected additional arg after 'at' keyword.");
@ -1010,18 +884,15 @@ int DumpNetCDFMPIIO::modify_param(int narg, char **arg)
else if (framei < 0) framei--; else if (framei < 0) framei--;
iarg++; iarg++;
return 2; return 2;
} } else if (strcmp(arg[iarg],"thermo") == 0) {
else if (strcmp(arg[iarg],"thermo") == 0) {
iarg++; iarg++;
if (iarg >= narg) if (iarg >= narg)
error->all(FLERR,"expected 'yes' or 'no' after 'thermo' keyword."); error->all(FLERR,"expected 'yes' or 'no' after 'thermo' keyword.");
if (strcmp(arg[iarg],"yes") == 0) { if (strcmp(arg[iarg],"yes") == 0) {
thermo = true; thermo = true;
} } else if (strcmp(arg[iarg],"no") == 0) {
else if (strcmp(arg[iarg],"no") == 0) {
thermo = false; thermo = false;
} } else error->all(FLERR,"expected 'yes' or 'no' after 'thermo' keyword.");
else error->all(FLERR,"expected 'yes' or 'no' after 'thermo' keyword.");
iarg++; iarg++;
return 2; return 2;
} else return 0; } else return 0;
@ -1032,16 +903,10 @@ int DumpNetCDFMPIIO::modify_param(int narg, char **arg)
void DumpNetCDFMPIIO::ncerr(int err, const char *descr, int line) void DumpNetCDFMPIIO::ncerr(int err, const char *descr, int line)
{ {
if (err != NC_NOERR) { if (err != NC_NOERR) {
char errstr[1024]; if (descr) error->one(FLERR,"NetCDF failed with error '{}' (while accessing '{}') "
if (descr) { " in line {} of {}.", ncmpi_strerror(err), descr, line, __FILE__);
sprintf(errstr, "NetCDF failed with error '%s' (while accessing '%s') " else error->one(FLERR,"NetCDF failed with error '{}' in line {} of {}.",
" in line %i of %s.", ncmpi_strerror(err), descr, line, __FILE__); ncmpi_strerror(err), line, __FILE__);
}
else {
sprintf(errstr, "NetCDF failed with error '%s' in line %i of %s.",
ncmpi_strerror(err), line, __FILE__);
}
error->one(FLERR,errstr);
} }
} }