simplify processing for "*" in filenames for embedding timestep by using utility function
This commit is contained in:
@ -81,44 +81,18 @@ DumpAtomADIOS::~DumpAtomADIOS()
|
|||||||
|
|
||||||
void DumpAtomADIOS::openfile()
|
void DumpAtomADIOS::openfile()
|
||||||
{
|
{
|
||||||
if (multifile) {
|
if (multifile) {
|
||||||
// if one file per timestep, replace '*' with current timestep
|
// if one file per timestep, replace '*' with current timestep
|
||||||
char *filestar = strdup(filename);
|
auto filecurrent = utils::star_subst(filename, update->ntimestep, padflag);
|
||||||
char *filecurrent = new char[strlen(filestar) + 16];
|
internal->fh = internal->io.Open(filecurrent, adios2::Mode::Write, world);
|
||||||
char *ptr = strchr(filestar, '*');
|
if (!internal->fh) error->one(FLERR, "Cannot open dump file {}", filecurrent);
|
||||||
*ptr = '\0';
|
} else {
|
||||||
if (padflag == 0)
|
if (!singlefile_opened) {
|
||||||
snprintf(filecurrent, sizeof(filecurrent), "%s" BIGINT_FORMAT "%s",
|
internal->fh = internal->io.Open(filename, adios2::Mode::Write, world);
|
||||||
filestar, update->ntimestep, ptr + 1);
|
if (!internal->fh) error->one(FLERR, "Cannot open dump file {}", filename);
|
||||||
else {
|
singlefile_opened = 1;
|
||||||
char bif[8], pad[16];
|
|
||||||
strcpy(bif, BIGINT_FORMAT);
|
|
||||||
snprintf(pad, sizeof(pad), "%%s%%0%d%s%%s", padflag, &bif[1]);
|
|
||||||
snprintf(filecurrent, sizeof(filecurrent), pad, filestar,
|
|
||||||
update->ntimestep, ptr + 1);
|
|
||||||
}
|
|
||||||
internal->fh =
|
|
||||||
internal->io.Open(filecurrent, adios2::Mode::Write, world);
|
|
||||||
if (!internal->fh) {
|
|
||||||
char str[128];
|
|
||||||
snprintf(str, sizeof(str), "Cannot open dump file %s", filecurrent);
|
|
||||||
error->one(FLERR, str);
|
|
||||||
}
|
|
||||||
free(filestar);
|
|
||||||
delete[] filecurrent;
|
|
||||||
} else {
|
|
||||||
if (!singlefile_opened) {
|
|
||||||
internal->fh =
|
|
||||||
internal->io.Open(filename, adios2::Mode::Write, world);
|
|
||||||
if (!internal->fh) {
|
|
||||||
char str[128];
|
|
||||||
snprintf(str, sizeof(str), "Cannot open dump file %s",
|
|
||||||
filename);
|
|
||||||
error->one(FLERR, str);
|
|
||||||
}
|
|
||||||
singlefile_opened = 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|||||||
@ -93,42 +93,18 @@ DumpCustomADIOS::~DumpCustomADIOS()
|
|||||||
|
|
||||||
void DumpCustomADIOS::openfile()
|
void DumpCustomADIOS::openfile()
|
||||||
{
|
{
|
||||||
if (multifile) {
|
if (multifile) {
|
||||||
// if one file per timestep, replace '*' with current timestep
|
// if one file per timestep, replace '*' with current timestep
|
||||||
char *filestar = strdup(filename);
|
auto filecurrent = utils::star_subst(filename, update->ntimestep, padflag);
|
||||||
char *filecurrent = new char[strlen(filestar) + 16];
|
internal->fh = internal->io.Open(filecurrent, adios2::Mode::Write, world);
|
||||||
char *ptr = strchr(filestar, '*');
|
if (!internal->fh) error->one(FLERR, "Cannot open dump file {}", filecurrent);
|
||||||
*ptr = '\0';
|
} else {
|
||||||
if (padflag == 0)
|
if (!singlefile_opened) {
|
||||||
sprintf(filecurrent, "%s" BIGINT_FORMAT "%s", filestar,
|
internal->fh = internal->io.Open(filename, adios2::Mode::Write, world);
|
||||||
update->ntimestep, ptr + 1);
|
if (!internal->fh) error->one(FLERR, "Cannot open dump file {}", filename);
|
||||||
else {
|
singlefile_opened = 1;
|
||||||
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);
|
|
||||||
}
|
|
||||||
internal->fh =
|
|
||||||
internal->io.Open(filecurrent, adios2::Mode::Write, world);
|
|
||||||
if (!internal->fh) {
|
|
||||||
char str[128];
|
|
||||||
sprintf(str, "Cannot open dump file %s", filecurrent);
|
|
||||||
error->one(FLERR, str);
|
|
||||||
}
|
|
||||||
free(filestar);
|
|
||||||
delete[] filecurrent;
|
|
||||||
} else {
|
|
||||||
if (!singlefile_opened) {
|
|
||||||
internal->fh =
|
|
||||||
internal->io.Open(filename, adios2::Mode::Write, world);
|
|
||||||
if (!internal->fh) {
|
|
||||||
char str[128];
|
|
||||||
sprintf(str, "Cannot open dump file %s", filename);
|
|
||||||
error->one(FLERR, str);
|
|
||||||
}
|
|
||||||
singlefile_opened = 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|||||||
@ -46,19 +46,7 @@ void DumpAtomGZ::openfile()
|
|||||||
if (multiproc) filecurrent = multiname;
|
if (multiproc) filecurrent = multiname;
|
||||||
|
|
||||||
if (multifile) {
|
if (multifile) {
|
||||||
char *filestar = filecurrent;
|
filecurrent = utils::strdup(utils::star_subst(filecurrent, update->ntimestep, padflag));
|
||||||
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 = '*';
|
|
||||||
if (maxfiles > 0) {
|
if (maxfiles > 0) {
|
||||||
if (numfiles < maxfiles) {
|
if (numfiles < maxfiles) {
|
||||||
nameslist[numfiles] = utils::strdup(filecurrent);
|
nameslist[numfiles] = utils::strdup(filecurrent);
|
||||||
|
|||||||
@ -52,19 +52,7 @@ void DumpAtomZstd::openfile()
|
|||||||
if (multiproc) filecurrent = multiname;
|
if (multiproc) filecurrent = multiname;
|
||||||
|
|
||||||
if (multifile) {
|
if (multifile) {
|
||||||
char *filestar = filecurrent;
|
filecurrent = utils::strdup(utils::star_subst(filecurrent, update->ntimestep, padflag));
|
||||||
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 = '*';
|
|
||||||
if (maxfiles > 0) {
|
if (maxfiles > 0) {
|
||||||
if (numfiles < maxfiles) {
|
if (numfiles < maxfiles) {
|
||||||
nameslist[numfiles] = utils::strdup(filecurrent);
|
nameslist[numfiles] = utils::strdup(filecurrent);
|
||||||
|
|||||||
@ -48,19 +48,7 @@ void DumpCFGGZ::openfile()
|
|||||||
if (multiproc) filecurrent = multiname;
|
if (multiproc) filecurrent = multiname;
|
||||||
|
|
||||||
if (multifile) {
|
if (multifile) {
|
||||||
char *filestar = filecurrent;
|
filecurrent = utils::strdup(utils::star_subst(filecurrent, update->ntimestep, padflag));
|
||||||
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 = '*';
|
|
||||||
if (maxfiles > 0) {
|
if (maxfiles > 0) {
|
||||||
if (numfiles < maxfiles) {
|
if (numfiles < maxfiles) {
|
||||||
nameslist[numfiles] = utils::strdup(filecurrent);
|
nameslist[numfiles] = utils::strdup(filecurrent);
|
||||||
|
|||||||
@ -54,19 +54,7 @@ void DumpCFGZstd::openfile()
|
|||||||
if (multiproc) filecurrent = multiname;
|
if (multiproc) filecurrent = multiname;
|
||||||
|
|
||||||
if (multifile) {
|
if (multifile) {
|
||||||
char *filestar = filecurrent;
|
filecurrent = utils::strdup(utils::star_subst(filecurrent, update->ntimestep, padflag));
|
||||||
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 = '*';
|
|
||||||
if (maxfiles > 0) {
|
if (maxfiles > 0) {
|
||||||
if (numfiles < maxfiles) {
|
if (numfiles < maxfiles) {
|
||||||
nameslist[numfiles] = utils::strdup(filecurrent);
|
nameslist[numfiles] = utils::strdup(filecurrent);
|
||||||
|
|||||||
@ -46,19 +46,7 @@ void DumpCustomGZ::openfile()
|
|||||||
if (multiproc) filecurrent = multiname;
|
if (multiproc) filecurrent = multiname;
|
||||||
|
|
||||||
if (multifile) {
|
if (multifile) {
|
||||||
char *filestar = filecurrent;
|
filecurrent = utils::strdup(utils::star_subst(filecurrent, update->ntimestep, padflag));
|
||||||
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 = '*';
|
|
||||||
if (maxfiles > 0) {
|
if (maxfiles > 0) {
|
||||||
if (numfiles < maxfiles) {
|
if (numfiles < maxfiles) {
|
||||||
nameslist[numfiles] = utils::strdup(filecurrent);
|
nameslist[numfiles] = utils::strdup(filecurrent);
|
||||||
|
|||||||
@ -56,20 +56,7 @@ void DumpCustomZstd::openfile()
|
|||||||
if (multiproc) filecurrent = multiname;
|
if (multiproc) filecurrent = multiname;
|
||||||
|
|
||||||
if (multifile) {
|
if (multifile) {
|
||||||
char *filestar = filecurrent;
|
filecurrent = utils::strdup(utils::star_subst(filecurrent, update->ntimestep, padflag));
|
||||||
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 = '*';
|
|
||||||
if (maxfiles > 0) {
|
if (maxfiles > 0) {
|
||||||
if (numfiles < maxfiles) {
|
if (numfiles < maxfiles) {
|
||||||
nameslist[numfiles] = utils::strdup(filecurrent);
|
nameslist[numfiles] = utils::strdup(filecurrent);
|
||||||
|
|||||||
@ -46,19 +46,7 @@ void DumpLocalGZ::openfile()
|
|||||||
if (multiproc) filecurrent = multiname;
|
if (multiproc) filecurrent = multiname;
|
||||||
|
|
||||||
if (multifile) {
|
if (multifile) {
|
||||||
char *filestar = filecurrent;
|
filecurrent = utils::strdup(utils::star_subst(filecurrent, update->ntimestep, padflag));
|
||||||
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 = '*';
|
|
||||||
if (maxfiles > 0) {
|
if (maxfiles > 0) {
|
||||||
if (numfiles < maxfiles) {
|
if (numfiles < maxfiles) {
|
||||||
nameslist[numfiles] = utils::strdup(filecurrent);
|
nameslist[numfiles] = utils::strdup(filecurrent);
|
||||||
|
|||||||
@ -52,19 +52,7 @@ void DumpLocalZstd::openfile()
|
|||||||
if (multiproc) filecurrent = multiname;
|
if (multiproc) filecurrent = multiname;
|
||||||
|
|
||||||
if (multifile) {
|
if (multifile) {
|
||||||
char *filestar = filecurrent;
|
filecurrent = utils::strdup(utils::star_subst(filecurrent, update->ntimestep, padflag));
|
||||||
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 = '*';
|
|
||||||
if (maxfiles > 0) {
|
if (maxfiles > 0) {
|
||||||
if (numfiles < maxfiles) {
|
if (numfiles < maxfiles) {
|
||||||
nameslist[numfiles] = utils::strdup(filecurrent);
|
nameslist[numfiles] = utils::strdup(filecurrent);
|
||||||
|
|||||||
@ -45,19 +45,7 @@ void DumpXYZGZ::openfile()
|
|||||||
if (multiproc) filecurrent = multiname;
|
if (multiproc) filecurrent = multiname;
|
||||||
|
|
||||||
if (multifile) {
|
if (multifile) {
|
||||||
char *filestar = filecurrent;
|
filecurrent = utils::strdup(utils::star_subst(filecurrent, update->ntimestep, padflag));
|
||||||
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 = '*';
|
|
||||||
if (maxfiles > 0) {
|
if (maxfiles > 0) {
|
||||||
if (numfiles < maxfiles) {
|
if (numfiles < maxfiles) {
|
||||||
nameslist[numfiles] = utils::strdup(filecurrent);
|
nameslist[numfiles] = utils::strdup(filecurrent);
|
||||||
|
|||||||
@ -51,19 +51,7 @@ void DumpXYZZstd::openfile()
|
|||||||
if (multiproc) filecurrent = multiname;
|
if (multiproc) filecurrent = multiname;
|
||||||
|
|
||||||
if (multifile) {
|
if (multifile) {
|
||||||
char *filestar = filecurrent;
|
filecurrent = utils::strdup(utils::star_subst(filecurrent, update->ntimestep, padflag));
|
||||||
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 = '*';
|
|
||||||
if (maxfiles > 0) {
|
if (maxfiles > 0) {
|
||||||
if (numfiles < maxfiles) {
|
if (numfiles < maxfiles) {
|
||||||
nameslist[numfiles] = utils::strdup(filecurrent);
|
nameslist[numfiles] = utils::strdup(filecurrent);
|
||||||
|
|||||||
@ -274,29 +274,12 @@ void DumpMolfile::openfile()
|
|||||||
|
|
||||||
// if one file per timestep, replace '*' with current timestep
|
// if one file per timestep, replace '*' with current timestep
|
||||||
|
|
||||||
char *filecurrent = new char[strlen(filename) + 16];
|
std::string filecurrent = filename;
|
||||||
if (multifile == 0) {
|
if (multifile == 1)
|
||||||
strcpy(filecurrent,filename);
|
filecurrent = utils::star_subst(filename, update->ntimestep, padflag);
|
||||||
} else {
|
|
||||||
char *ptr = strchr(filename,'*');
|
|
||||||
char *p1 = filename;
|
|
||||||
char *p2 = filecurrent;
|
|
||||||
while (p1 != ptr)
|
|
||||||
*p2++ = *p1++;
|
|
||||||
|
|
||||||
if (padflag == 0) {
|
if (mf->open(filecurrent.c_str(), &natoms))
|
||||||
sprintf(p2,BIGINT_FORMAT "%s",update->ntimestep,ptr+1);
|
error->one(FLERR,"Cannot open dump file {}: {}", filecurrent, utils::getsyserror());
|
||||||
} else {
|
|
||||||
char bif[8],pad[16];
|
|
||||||
strcpy(bif,BIGINT_FORMAT);
|
|
||||||
sprintf(pad,"%%0%d%s%%s",padflag,&bif[1]);
|
|
||||||
sprintf(p2,pad,update->ntimestep,ptr+1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mf->open(filecurrent,&natoms))
|
|
||||||
error->one(FLERR,"Cannot open dump file");
|
|
||||||
delete[] filecurrent;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -69,19 +69,7 @@ void DumpAtomMPIIO::openfile()
|
|||||||
filecurrent = filename;
|
filecurrent = filename;
|
||||||
|
|
||||||
if (multifile) {
|
if (multifile) {
|
||||||
char *filestar = filecurrent;
|
filecurrent = utils::strdup(utils::star_subst(filecurrent, update->ntimestep, padflag));
|
||||||
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 = '*';
|
|
||||||
if (maxfiles > 0) {
|
if (maxfiles > 0) {
|
||||||
if (numfiles < maxfiles) {
|
if (numfiles < maxfiles) {
|
||||||
nameslist[numfiles] = new char[strlen(filecurrent) + 1];
|
nameslist[numfiles] = new char[strlen(filecurrent) + 1];
|
||||||
@ -98,8 +86,8 @@ void DumpAtomMPIIO::openfile()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (append_flag) { // append open
|
if (append_flag) { // append open
|
||||||
int err = MPI_File_open(world, filecurrent, MPI_MODE_CREATE | MPI_MODE_APPEND | MPI_MODE_WRONLY,
|
int err = MPI_File_open(world, filecurrent, MPI_MODE_CREATE | MPI_MODE_APPEND |
|
||||||
MPI_INFO_NULL, &mpifh);
|
MPI_MODE_WRONLY, MPI_INFO_NULL, &mpifh);
|
||||||
if (err != MPI_SUCCESS)
|
if (err != MPI_SUCCESS)
|
||||||
error->one(FLERR, "Cannot open dump file {}: {}", filecurrent, utils::getsyserror());
|
error->one(FLERR, "Cannot open dump file {}: {}", filecurrent, utils::getsyserror());
|
||||||
|
|
||||||
@ -112,8 +100,8 @@ void DumpAtomMPIIO::openfile()
|
|||||||
|
|
||||||
} else { // replace open
|
} else { // replace open
|
||||||
|
|
||||||
int err =
|
int err = MPI_File_open(world, filecurrent, MPI_MODE_CREATE | MPI_MODE_WRONLY,
|
||||||
MPI_File_open(world, filecurrent, MPI_MODE_CREATE | MPI_MODE_WRONLY, MPI_INFO_NULL, &mpifh);
|
MPI_INFO_NULL, &mpifh);
|
||||||
if (err != MPI_SUCCESS)
|
if (err != MPI_SUCCESS)
|
||||||
error->one(FLERR, "Cannot open dump file {}: {}", filecurrent, utils::getsyserror());
|
error->one(FLERR, "Cannot open dump file {}: {}", filecurrent, utils::getsyserror());
|
||||||
|
|
||||||
|
|||||||
@ -81,20 +81,7 @@ void DumpCFGMPIIO::openfile()
|
|||||||
filecurrent = filename;
|
filecurrent = filename;
|
||||||
|
|
||||||
if (multifile) {
|
if (multifile) {
|
||||||
char *filestar = filecurrent;
|
filecurrent = utils::strdup(utils::star_subst(filecurrent, update->ntimestep, padflag));
|
||||||
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 = '*';
|
|
||||||
if (maxfiles > 0) {
|
if (maxfiles > 0) {
|
||||||
if (numfiles < maxfiles) {
|
if (numfiles < maxfiles) {
|
||||||
nameslist[numfiles] = new char[strlen(filecurrent)+1];
|
nameslist[numfiles] = new char[strlen(filecurrent)+1];
|
||||||
@ -111,12 +98,10 @@ void DumpCFGMPIIO::openfile()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (append_flag) { // append open
|
if (append_flag) { // append open
|
||||||
int err = MPI_File_open( world, filecurrent, MPI_MODE_CREATE | MPI_MODE_APPEND | MPI_MODE_WRONLY , MPI_INFO_NULL, &mpifh);
|
int err = MPI_File_open( world, filecurrent, MPI_MODE_CREATE | MPI_MODE_APPEND |
|
||||||
if (err != MPI_SUCCESS) {
|
MPI_MODE_WRONLY, MPI_INFO_NULL, &mpifh);
|
||||||
char str[128];
|
if (err != MPI_SUCCESS) error->one(FLERR, "Cannot open dump file {}", filecurrent);
|
||||||
sprintf(str,"Cannot open dump file %s",filecurrent);
|
|
||||||
error->one(FLERR,str);
|
|
||||||
}
|
|
||||||
int myrank;
|
int myrank;
|
||||||
MPI_Comm_rank(world,&myrank);
|
MPI_Comm_rank(world,&myrank);
|
||||||
if (myrank == 0)
|
if (myrank == 0)
|
||||||
@ -125,15 +110,11 @@ void DumpCFGMPIIO::openfile()
|
|||||||
MPI_File_set_size(mpifh,mpifo+headerSize+sumFileSize);
|
MPI_File_set_size(mpifh,mpifo+headerSize+sumFileSize);
|
||||||
currentFileSize = mpifo+headerSize+sumFileSize;
|
currentFileSize = mpifo+headerSize+sumFileSize;
|
||||||
|
|
||||||
}
|
} else { // replace open
|
||||||
else { // replace open
|
|
||||||
|
|
||||||
int err = MPI_File_open( world, filecurrent, MPI_MODE_CREATE | MPI_MODE_WRONLY , MPI_INFO_NULL, &mpifh);
|
int err = MPI_File_open( world, filecurrent, MPI_MODE_CREATE | MPI_MODE_WRONLY,
|
||||||
if (err != MPI_SUCCESS) {
|
MPI_INFO_NULL, &mpifh);
|
||||||
char str[128];
|
if (err != MPI_SUCCESS) error->one(FLERR, "Cannot open dump file {}", filecurrent);
|
||||||
sprintf(str,"Cannot open dump file %s",filecurrent);
|
|
||||||
error->one(FLERR,str);
|
|
||||||
}
|
|
||||||
mpifo = 0;
|
mpifo = 0;
|
||||||
|
|
||||||
MPI_File_set_size(mpifh,(MPI_Offset) (headerSize+sumFileSize));
|
MPI_File_set_size(mpifh,(MPI_Offset) (headerSize+sumFileSize));
|
||||||
|
|||||||
@ -36,7 +36,6 @@
|
|||||||
|
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
|
|
||||||
#define MAX_TEXT_HEADER_SIZE 4096
|
|
||||||
#define DUMP_BUF_CHUNK_SIZE 16384
|
#define DUMP_BUF_CHUNK_SIZE 16384
|
||||||
#define DUMP_BUF_INCREMENT_SIZE 4096
|
#define DUMP_BUF_INCREMENT_SIZE 4096
|
||||||
|
|
||||||
@ -71,7 +70,7 @@ DumpCustomMPIIO::~DumpCustomMPIIO()
|
|||||||
|
|
||||||
void DumpCustomMPIIO::openfile()
|
void DumpCustomMPIIO::openfile()
|
||||||
{
|
{
|
||||||
if (singlefile_opened) { // single file already opened, so just return after resetting filesize
|
if (singlefile_opened) { // single file already opened, so just return after resetting filesize
|
||||||
mpifo = currentFileSize;
|
mpifo = currentFileSize;
|
||||||
MPI_File_set_size(mpifh, mpifo + headerSize + sumFileSize);
|
MPI_File_set_size(mpifh, mpifo + headerSize + sumFileSize);
|
||||||
currentFileSize = mpifo + headerSize + sumFileSize;
|
currentFileSize = mpifo + headerSize + sumFileSize;
|
||||||
@ -84,19 +83,7 @@ void DumpCustomMPIIO::openfile()
|
|||||||
filecurrent = filename;
|
filecurrent = filename;
|
||||||
|
|
||||||
if (multifile) {
|
if (multifile) {
|
||||||
char *filestar = filecurrent;
|
filecurrent = utils::strdup(utils::star_subst(filecurrent, update->ntimestep, padflag));
|
||||||
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 = '*';
|
|
||||||
if (maxfiles > 0) {
|
if (maxfiles > 0) {
|
||||||
if (numfiles < maxfiles) {
|
if (numfiles < maxfiles) {
|
||||||
nameslist[numfiles] = new char[strlen(filecurrent) + 1];
|
nameslist[numfiles] = new char[strlen(filecurrent) + 1];
|
||||||
|
|||||||
@ -81,20 +81,7 @@ void DumpXYZMPIIO::openfile()
|
|||||||
filecurrent = filename;
|
filecurrent = filename;
|
||||||
|
|
||||||
if (multifile) {
|
if (multifile) {
|
||||||
char *filestar = filecurrent;
|
filecurrent = utils::strdup(utils::star_subst(filecurrent, update->ntimestep, padflag));
|
||||||
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 = '*';
|
|
||||||
if (maxfiles > 0) {
|
if (maxfiles > 0) {
|
||||||
if (numfiles < maxfiles) {
|
if (numfiles < maxfiles) {
|
||||||
nameslist[numfiles] = new char[strlen(filecurrent)+1];
|
nameslist[numfiles] = new char[strlen(filecurrent)+1];
|
||||||
@ -111,12 +98,10 @@ void DumpXYZMPIIO::openfile()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (append_flag) { // append open
|
if (append_flag) { // append open
|
||||||
int err = MPI_File_open( world, filecurrent, MPI_MODE_CREATE | MPI_MODE_APPEND | MPI_MODE_WRONLY , MPI_INFO_NULL, &mpifh);
|
int err = MPI_File_open( world, filecurrent, MPI_MODE_CREATE | MPI_MODE_APPEND |
|
||||||
if (err != MPI_SUCCESS) {
|
MPI_MODE_WRONLY , MPI_INFO_NULL, &mpifh);
|
||||||
char str[128];
|
if (err != MPI_SUCCESS) error->one(FLERR, "Cannot open dump file {}",filecurrent);
|
||||||
sprintf(str,"Cannot open dump file %s",filecurrent);
|
|
||||||
error->one(FLERR,str);
|
|
||||||
}
|
|
||||||
int myrank;
|
int myrank;
|
||||||
MPI_Comm_rank(world,&myrank);
|
MPI_Comm_rank(world,&myrank);
|
||||||
if (myrank == 0)
|
if (myrank == 0)
|
||||||
@ -124,20 +109,15 @@ void DumpXYZMPIIO::openfile()
|
|||||||
MPI_Bcast(&mpifo, 1, MPI_LMP_BIGINT, 0, world);
|
MPI_Bcast(&mpifo, 1, MPI_LMP_BIGINT, 0, world);
|
||||||
MPI_File_set_size(mpifh,mpifo+headerSize+sumFileSize);
|
MPI_File_set_size(mpifh,mpifo+headerSize+sumFileSize);
|
||||||
currentFileSize = mpifo+headerSize+sumFileSize;
|
currentFileSize = mpifo+headerSize+sumFileSize;
|
||||||
}
|
} else { // replace open
|
||||||
else { // replace open
|
|
||||||
|
|
||||||
int err = MPI_File_open( world, filecurrent, MPI_MODE_CREATE | MPI_MODE_WRONLY , MPI_INFO_NULL, &mpifh);
|
int err = MPI_File_open( world, filecurrent, MPI_MODE_CREATE | MPI_MODE_WRONLY,
|
||||||
if (err != MPI_SUCCESS) {
|
MPI_INFO_NULL, &mpifh);
|
||||||
char str[128];
|
if (err != MPI_SUCCESS) error->one(FLERR, "Cannot open dump file {}",filecurrent);
|
||||||
sprintf(str,"Cannot open dump file %s",filecurrent);
|
|
||||||
error->one(FLERR,str);
|
|
||||||
}
|
|
||||||
mpifo = 0;
|
mpifo = 0;
|
||||||
|
|
||||||
MPI_File_set_size(mpifh,(MPI_Offset) (headerSize+sumFileSize));
|
MPI_File_set_size(mpifh,(MPI_Offset) (headerSize+sumFileSize));
|
||||||
currentFileSize = (headerSize+sumFileSize);
|
currentFileSize = (headerSize+sumFileSize);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -221,8 +201,8 @@ void DumpXYZMPIIO::write()
|
|||||||
performEstimate = 0;
|
performEstimate = 0;
|
||||||
write_data(nme,buf);
|
write_data(nme,buf);
|
||||||
|
|
||||||
if (multifile) MPI_File_close(&mpifh);
|
if (multifile) MPI_File_close(&mpifh);
|
||||||
if (multifile) delete [] filecurrent;
|
if (multifile) delete[] filecurrent;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
@ -231,7 +211,7 @@ void DumpXYZMPIIO::init_style()
|
|||||||
{
|
{
|
||||||
// format = copy of default or user-specified line format
|
// format = copy of default or user-specified line format
|
||||||
|
|
||||||
delete [] format;
|
delete[] format;
|
||||||
char *str;
|
char *str;
|
||||||
if (format_line_user) str = format_line_user;
|
if (format_line_user) str = format_line_user;
|
||||||
else str = format_default;
|
else str = format_default;
|
||||||
@ -246,10 +226,8 @@ void DumpXYZMPIIO::init_style()
|
|||||||
|
|
||||||
if (typenames == nullptr) {
|
if (typenames == nullptr) {
|
||||||
typenames = new char*[ntypes+1];
|
typenames = new char*[ntypes+1];
|
||||||
for (int itype = 1; itype <= ntypes; itype++) {
|
for (int itype = 1; itype <= ntypes; itype++)
|
||||||
typenames[itype] = new char[12];
|
typenames[itype] = utils::strdup(std::to_string(itype));
|
||||||
sprintf(typenames[itype],"%d",itype);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// setup function ptr
|
// setup function ptr
|
||||||
@ -267,8 +245,7 @@ void DumpXYZMPIIO::write_header(bigint n)
|
|||||||
headerSize = 0;
|
headerSize = 0;
|
||||||
headerSize += sprintf(((char*)&((char*)headerBuffer)[headerSize]),BIGINT_FORMAT "\n",n);
|
headerSize += sprintf(((char*)&((char*)headerBuffer)[headerSize]),BIGINT_FORMAT "\n",n);
|
||||||
headerSize += sprintf(&((char*)headerBuffer)[headerSize],"Atoms. Timestep: " BIGINT_FORMAT "\n",update->ntimestep);
|
headerSize += sprintf(&((char*)headerBuffer)[headerSize],"Atoms. Timestep: " BIGINT_FORMAT "\n",update->ntimestep);
|
||||||
}
|
} else { // write data
|
||||||
else { // write data
|
|
||||||
|
|
||||||
if (me == 0)
|
if (me == 0)
|
||||||
MPI_File_write_at(mpifh,mpifo,headerBuffer,headerSize,MPI_CHAR,MPI_STATUS_IGNORE);
|
MPI_File_write_at(mpifh,mpifo,headerBuffer,headerSize,MPI_CHAR,MPI_STATUS_IGNORE);
|
||||||
|
|||||||
@ -178,7 +178,7 @@ DumpNetCDF::DumpNetCDF(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
for (int j = 0; j < DUMP_NC_MAX_DIMS; j++) {
|
for (int j = 0; j < DUMP_NC_MAX_DIMS; j++) {
|
||||||
perat[inc].field[j] = -1;
|
perat[inc].field[j] = -1;
|
||||||
}
|
}
|
||||||
strncpy(perat[inc].name, mangled.c_str(), NC_FIELD_NAME_MAX);
|
strncpy(perat[inc].name, mangled.c_str(), NC_FIELD_NAME_MAX-1);
|
||||||
n_perat++;
|
n_perat++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -217,22 +217,9 @@ DumpNetCDF::~DumpNetCDF()
|
|||||||
|
|
||||||
void DumpNetCDF::openfile()
|
void DumpNetCDF::openfile()
|
||||||
{
|
{
|
||||||
char *filecurrent = filename;
|
std::string filecurrent = filename;
|
||||||
if (multifile && !singlefile_opened) {
|
if (multifile && !singlefile_opened)
|
||||||
char *filestar = filecurrent;
|
filecurrent = utils::star_subst(filename, update->ntimestep, padflag);
|
||||||
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 = '*';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (thermo && !singlefile_opened) {
|
if (thermo && !singlefile_opened) {
|
||||||
delete[] thermovar;
|
delete[] thermovar;
|
||||||
@ -291,7 +278,7 @@ void DumpNetCDF::openfile()
|
|||||||
if (singlefile_opened) return;
|
if (singlefile_opened) return;
|
||||||
singlefile_opened = 1;
|
singlefile_opened = 1;
|
||||||
|
|
||||||
NCERRX( nc_open(filecurrent, NC_WRITE, &ncid), filecurrent );
|
NCERRX( nc_open(filecurrent.c_str(), NC_WRITE, &ncid), filecurrent.c_str() );
|
||||||
|
|
||||||
// dimensions
|
// dimensions
|
||||||
NCERRX( nc_inq_dimid(ncid, NC_FRAME_STR, &frame_dim), NC_FRAME_STR );
|
NCERRX( nc_inq_dimid(ncid, NC_FRAME_STR, &frame_dim), NC_FRAME_STR );
|
||||||
@ -356,7 +343,7 @@ void DumpNetCDF::openfile()
|
|||||||
if (singlefile_opened) return;
|
if (singlefile_opened) return;
|
||||||
singlefile_opened = 1;
|
singlefile_opened = 1;
|
||||||
|
|
||||||
NCERRX( nc_create(filecurrent, NC_64BIT_DATA, &ncid), filecurrent );
|
NCERRX( nc_create(filecurrent.c_str(), NC_64BIT_DATA, &ncid), filecurrent.c_str() );
|
||||||
|
|
||||||
// dimensions
|
// dimensions
|
||||||
NCERRX( nc_def_dim(ncid, NC_FRAME_STR, NC_UNLIMITED, &frame_dim), NC_FRAME_STR );
|
NCERRX( nc_def_dim(ncid, NC_FRAME_STR, NC_UNLIMITED, &frame_dim), NC_FRAME_STR );
|
||||||
|
|||||||
@ -177,7 +177,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;
|
||||||
}
|
}
|
||||||
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++;
|
n_perat++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -214,22 +214,9 @@ DumpNetCDFMPIIO::~DumpNetCDFMPIIO()
|
|||||||
|
|
||||||
void DumpNetCDFMPIIO::openfile()
|
void DumpNetCDFMPIIO::openfile()
|
||||||
{
|
{
|
||||||
char *filecurrent = filename;
|
std::string filecurrent = filename;
|
||||||
if (multifile && !singlefile_opened) {
|
if (multifile && !singlefile_opened)
|
||||||
char *filestar = filecurrent;
|
filecurrent = utils::star_subst(filename, update->ntimestep, padflag);
|
||||||
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 = '*';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (thermo && !singlefile_opened) {
|
if (thermo && !singlefile_opened) {
|
||||||
delete[] thermovar;
|
delete[] thermovar;
|
||||||
@ -287,7 +274,8 @@ 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, &ncid), filecurrent );
|
NCERRX( ncmpi_open(world, filecurrent.c_str(), NC_WRITE, MPI_INFO_NULL, &ncid),
|
||||||
|
filecurrent.c_str() );
|
||||||
|
|
||||||
// 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 );
|
||||||
@ -352,7 +340,8 @@ 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, MPI_INFO_NULL, &ncid), filecurrent );
|
NCERRX( ncmpi_create(world, filecurrent.c_str(), NC_64BIT_DATA, MPI_INFO_NULL, &ncid),
|
||||||
|
filecurrent.c_str() );
|
||||||
|
|
||||||
// dimensions
|
// dimensions
|
||||||
NCERRX( ncmpi_def_dim(ncid, NC_FRAME_STR, NC_UNLIMITED, &frame_dim), NC_FRAME_STR );
|
NCERRX( ncmpi_def_dim(ncid, NC_FRAME_STR, NC_UNLIMITED, &frame_dim), NC_FRAME_STR );
|
||||||
|
|||||||
@ -644,29 +644,15 @@ void FixReaxFFSpecies::WriteFormulas(int Nmole, int Nspec)
|
|||||||
|
|
||||||
void FixReaxFFSpecies::OpenPos()
|
void FixReaxFFSpecies::OpenPos()
|
||||||
{
|
{
|
||||||
char *filecurrent;
|
|
||||||
bigint ntimestep = update->ntimestep;
|
|
||||||
|
|
||||||
filecurrent = (char*) malloc((strlen(filepos)+16)*sizeof(char));
|
|
||||||
char *ptr = strchr(filepos,'*');
|
|
||||||
*ptr = '\0';
|
|
||||||
if (padflag == 0)
|
|
||||||
sprintf(filecurrent,"%s" BIGINT_FORMAT "%s",filepos,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,filepos,ntimestep,ptr+1);
|
|
||||||
}
|
|
||||||
*ptr = '*';
|
|
||||||
|
|
||||||
if (me == 0) {
|
if (me == 0) {
|
||||||
pos = fopen(filecurrent, "w");
|
auto filecurrent = utils::star_subst(filepos, update->ntimestep, padflag);
|
||||||
if (pos == nullptr) error->one(FLERR,"Cannot open fix reaxff/species position file");
|
pos = fopen(filecurrent.c_str(), "w");
|
||||||
} else pos = nullptr;
|
if (pos == nullptr)
|
||||||
|
error->one(FLERR, "Cannot open fix reaxff/species position file {}: {}", filecurrent,
|
||||||
|
utils::getsyserror());
|
||||||
|
} else
|
||||||
|
pos = nullptr;
|
||||||
multipos_opened = 1;
|
multipos_opened = 1;
|
||||||
|
|
||||||
free(filecurrent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|||||||
@ -1009,13 +1009,13 @@ void DumpVTK::write_data(int n, double *mybuf)
|
|||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
void DumpVTK::setFileCurrent() {
|
void DumpVTK::setFileCurrent() {
|
||||||
delete [] filecurrent;
|
delete[] filecurrent;
|
||||||
filecurrent = nullptr;
|
filecurrent = nullptr;
|
||||||
|
|
||||||
char *filestar = filename;
|
char *filestar = filename;
|
||||||
if (multiproc) {
|
if (multiproc) {
|
||||||
if (multiproc > 1) { // if dump_modify fileper or nfile was used
|
if (multiproc > 1) { // if dump_modify fileper or nfile was used
|
||||||
delete [] multiname_ex;
|
delete[] multiname_ex;
|
||||||
multiname_ex = nullptr;
|
multiname_ex = nullptr;
|
||||||
char *ptr = strchr(filename,'%');
|
char *ptr = strchr(filename,'%');
|
||||||
if (ptr) {
|
if (ptr) {
|
||||||
@ -1034,26 +1034,13 @@ void DumpVTK::setFileCurrent() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (multifile == 0) {
|
if (multifile == 0) {
|
||||||
filecurrent = new char[strlen(filestar) + 1];
|
filecurrent = utils::strdup(filestar);
|
||||||
strcpy(filecurrent, filestar);
|
|
||||||
} else {
|
} else {
|
||||||
filecurrent = new char[strlen(filestar) + 16];
|
filecurrent = utils::strdup(utils::star_subst(filestar, update->ntimestep, padflag));
|
||||||
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 = '*';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// filename of domain box data file
|
// filename of domain box data file
|
||||||
delete [] domainfilecurrent;
|
delete[] domainfilecurrent;
|
||||||
domainfilecurrent = nullptr;
|
domainfilecurrent = nullptr;
|
||||||
if (multiproc) {
|
if (multiproc) {
|
||||||
// remove '%' character
|
// remove '%' character
|
||||||
@ -1074,21 +1061,9 @@ void DumpVTK::setFileCurrent() {
|
|||||||
domainfilecurrent = new char[strlen(filestar) + 1];
|
domainfilecurrent = new char[strlen(filestar) + 1];
|
||||||
strcpy(domainfilecurrent, filestar);
|
strcpy(domainfilecurrent, filestar);
|
||||||
} else {
|
} else {
|
||||||
domainfilecurrent = new char[strlen(filestar) + 16];
|
domainfilecurrent = utils::strdup(utils::star_subst(filestar, update->ntimestep, padflag));
|
||||||
char *ptr = strchr(filestar,'*');
|
|
||||||
*ptr = '\0';
|
|
||||||
if (padflag == 0) {
|
|
||||||
sprintf(domainfilecurrent,"%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(domainfilecurrent,pad,filestar,update->ntimestep,ptr+1);
|
|
||||||
}
|
|
||||||
*ptr = '*';
|
|
||||||
}
|
}
|
||||||
delete [] filestar;
|
delete[] filestar;
|
||||||
filestar = nullptr;
|
filestar = nullptr;
|
||||||
} else {
|
} else {
|
||||||
domainfilecurrent = new char[strlen(filecurrent) + 16];
|
domainfilecurrent = new char[strlen(filecurrent) + 16];
|
||||||
@ -1100,7 +1075,7 @@ void DumpVTK::setFileCurrent() {
|
|||||||
|
|
||||||
// filename of parallel file
|
// filename of parallel file
|
||||||
if (multiproc && me == 0) {
|
if (multiproc && me == 0) {
|
||||||
delete [] parallelfilecurrent;
|
delete[] parallelfilecurrent;
|
||||||
parallelfilecurrent = nullptr;
|
parallelfilecurrent = nullptr;
|
||||||
|
|
||||||
// remove '%' character and add 'p' to file extension
|
// remove '%' character and add 'p' to file extension
|
||||||
@ -1119,24 +1094,11 @@ void DumpVTK::setFileCurrent() {
|
|||||||
*ptr++= 0;
|
*ptr++= 0;
|
||||||
|
|
||||||
if (multifile == 0) {
|
if (multifile == 0) {
|
||||||
parallelfilecurrent = new char[strlen(filestar) + 1];
|
parallelfilecurrent = utils::strdup(filestar);
|
||||||
strcpy(parallelfilecurrent, filestar);
|
|
||||||
} else {
|
} else {
|
||||||
parallelfilecurrent = new char[strlen(filestar) + 16];
|
parallelfilecurrent = utils::strdup(utils::star_subst(filestar, update->ntimestep, padflag));
|
||||||
char *ptr = strchr(filestar,'*');
|
|
||||||
*ptr = '\0';
|
|
||||||
if (padflag == 0) {
|
|
||||||
sprintf(parallelfilecurrent,"%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(parallelfilecurrent,pad,filestar,update->ntimestep,ptr+1);
|
|
||||||
}
|
|
||||||
*ptr = '*';
|
|
||||||
}
|
}
|
||||||
delete [] filestar;
|
delete[] filestar;
|
||||||
filestar = nullptr;
|
filestar = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
17
src/dump.cpp
17
src/dump.cpp
@ -549,20 +549,7 @@ void Dump::openfile()
|
|||||||
if (multiproc) filecurrent = multiname;
|
if (multiproc) filecurrent = multiname;
|
||||||
|
|
||||||
if (multifile) {
|
if (multifile) {
|
||||||
char *filestar = filecurrent;
|
filecurrent = utils::strdup(utils::star_subst(filecurrent, update->ntimestep, padflag));
|
||||||
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 = '*';
|
|
||||||
if (maxfiles > 0) {
|
if (maxfiles > 0) {
|
||||||
if (numfiles < maxfiles) {
|
if (numfiles < maxfiles) {
|
||||||
nameslist[numfiles] = utils::strdup(filecurrent);
|
nameslist[numfiles] = utils::strdup(filecurrent);
|
||||||
@ -594,7 +581,7 @@ void Dump::openfile()
|
|||||||
|
|
||||||
// delete string with timestep replaced
|
// delete string with timestep replaced
|
||||||
|
|
||||||
if (multifile) delete [] filecurrent;
|
if (multifile) delete[] filecurrent;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user