simplify processing for "*" in filenames for embedding timestep by using utility function
This commit is contained in:
@ -177,7 +177,7 @@ DumpNetCDFMPIIO::DumpNetCDFMPIIO(LAMMPS *lmp, int narg, char **arg) :
|
||||
for (int j = 0; j < DUMP_NC_MPIIO_MAX_DIMS; j++) {
|
||||
perat[inc].field[j] = -1;
|
||||
}
|
||||
strncpy(perat[inc].name, mangled.c_str(), NC_MPIIO_FIELD_NAME_MAX);
|
||||
strncpy(perat[inc].name, mangled.c_str(), NC_MPIIO_FIELD_NAME_MAX-1);
|
||||
n_perat++;
|
||||
}
|
||||
|
||||
@ -214,22 +214,9 @@ DumpNetCDFMPIIO::~DumpNetCDFMPIIO()
|
||||
|
||||
void DumpNetCDFMPIIO::openfile()
|
||||
{
|
||||
char *filecurrent = filename;
|
||||
if (multifile && !singlefile_opened) {
|
||||
char *filestar = filecurrent;
|
||||
filecurrent = new char[strlen(filestar) + 16];
|
||||
char *ptr = strchr(filestar,'*');
|
||||
*ptr = '\0';
|
||||
if (padflag == 0)
|
||||
sprintf(filecurrent,"%s" BIGINT_FORMAT "%s", filestar,update->ntimestep,ptr+1);
|
||||
else {
|
||||
char bif[8],pad[16];
|
||||
strcpy(bif,BIGINT_FORMAT);
|
||||
sprintf(pad,"%%s%%0%d%s%%s",padflag,&bif[1]);
|
||||
sprintf(filecurrent,pad,filestar,update->ntimestep,ptr+1);
|
||||
}
|
||||
*ptr = '*';
|
||||
}
|
||||
std::string filecurrent = filename;
|
||||
if (multifile && !singlefile_opened)
|
||||
filecurrent = utils::star_subst(filename, update->ntimestep, padflag);
|
||||
|
||||
if (thermo && !singlefile_opened) {
|
||||
delete[] thermovar;
|
||||
@ -287,7 +274,8 @@ void DumpNetCDFMPIIO::openfile()
|
||||
if (singlefile_opened) return;
|
||||
singlefile_opened = 1;
|
||||
|
||||
NCERRX( ncmpi_open(world, filecurrent, NC_WRITE, MPI_INFO_NULL, &ncid), filecurrent );
|
||||
NCERRX( ncmpi_open(world, filecurrent.c_str(), NC_WRITE, MPI_INFO_NULL, &ncid),
|
||||
filecurrent.c_str() );
|
||||
|
||||
// dimensions
|
||||
NCERRX( ncmpi_inq_dimid(ncid, NC_FRAME_STR, &frame_dim), NC_FRAME_STR );
|
||||
@ -352,7 +340,8 @@ void DumpNetCDFMPIIO::openfile()
|
||||
if (singlefile_opened) return;
|
||||
singlefile_opened = 1;
|
||||
|
||||
NCERRX( ncmpi_create(world, filecurrent, NC_64BIT_DATA, MPI_INFO_NULL, &ncid), filecurrent );
|
||||
NCERRX( ncmpi_create(world, filecurrent.c_str(), NC_64BIT_DATA, MPI_INFO_NULL, &ncid),
|
||||
filecurrent.c_str() );
|
||||
|
||||
// dimensions
|
||||
NCERRX( ncmpi_def_dim(ncid, NC_FRAME_STR, NC_UNLIMITED, &frame_dim), NC_FRAME_STR );
|
||||
|
||||
Reference in New Issue
Block a user