update list and order of include files from include-what-you-use analysis
This commit is contained in:
@ -1,4 +1,3 @@
|
||||
// clang-format off
|
||||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
https://www.lammps.org/, Sandia National Laboratories
|
||||
@ -19,6 +18,7 @@
|
||||
#ifdef LAMMPS_ZSTD
|
||||
|
||||
#include "domain.h"
|
||||
|
||||
#include "dump_atom_zstd.h"
|
||||
#include "error.h"
|
||||
#include "file_writer.h"
|
||||
@ -26,21 +26,16 @@
|
||||
|
||||
#include <cstring>
|
||||
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
DumpAtomZstd::DumpAtomZstd(LAMMPS *lmp, int narg, char **arg) :
|
||||
DumpAtom(lmp, narg, arg)
|
||||
DumpAtomZstd::DumpAtomZstd(LAMMPS *lmp, int narg, char **arg) : DumpAtom(lmp, narg, arg)
|
||||
{
|
||||
if (!compressed)
|
||||
error->all(FLERR,"Dump atom/zstd only writes compressed files");
|
||||
if (!compressed) error->all(FLERR, "Dump atom/zstd only writes compressed files");
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
DumpAtomZstd::~DumpAtomZstd()
|
||||
{
|
||||
}
|
||||
DumpAtomZstd::~DumpAtomZstd() {}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
generic opening of a dump file
|
||||
@ -63,16 +58,15 @@ void DumpAtomZstd::openfile()
|
||||
if (multifile) {
|
||||
char *filestar = filecurrent;
|
||||
filecurrent = new char[strlen(filestar) + 16];
|
||||
char *ptr = strchr(filestar,'*');
|
||||
char *ptr = strchr(filestar, '*');
|
||||
*ptr = '\0';
|
||||
if (padflag == 0)
|
||||
sprintf(filecurrent,"%s" BIGINT_FORMAT "%s",
|
||||
filestar,update->ntimestep,ptr+1);
|
||||
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);
|
||||
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) {
|
||||
@ -102,7 +96,7 @@ void DumpAtomZstd::openfile()
|
||||
|
||||
// delete string with timestep replaced
|
||||
|
||||
if (multifile) delete [] filecurrent;
|
||||
if (multifile) delete[] filecurrent;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
@ -114,12 +108,10 @@ void DumpAtomZstd::write_header(bigint ndump)
|
||||
if ((multiproc) || (!multiproc && me == 0)) {
|
||||
if (unit_flag && !unit_count) {
|
||||
++unit_count;
|
||||
header = fmt::format("ITEM: UNITS\n{}\n",update->unit_style);
|
||||
header = fmt::format("ITEM: UNITS\n{}\n", update->unit_style);
|
||||
}
|
||||
|
||||
if (time_flag) {
|
||||
header += fmt::format("ITEM: TIME\n{0:.16g}\n", compute_time());
|
||||
}
|
||||
if (time_flag) { header += fmt::format("ITEM: TIME\n{0:.16g}\n", compute_time()); }
|
||||
|
||||
header += fmt::format("ITEM: TIMESTEP\n{}\n", update->ntimestep);
|
||||
header += fmt::format("ITEM: NUMBER OF ATOMS\n{}\n", ndump);
|
||||
@ -153,14 +145,14 @@ void DumpAtomZstd::write_data(int n, double *mybuf)
|
||||
for (int i = 0; i < n; i++) {
|
||||
int written = 0;
|
||||
if (image_flag == 1) {
|
||||
written = snprintf(vbuffer, VBUFFER_SIZE, format,
|
||||
static_cast<tagint> (mybuf[m]), static_cast<int> (mybuf[m+1]),
|
||||
mybuf[m+2],mybuf[m+3],mybuf[m+4], static_cast<int> (mybuf[m+5]),
|
||||
static_cast<int> (mybuf[m+6]), static_cast<int> (mybuf[m+7]));
|
||||
written = snprintf(vbuffer, VBUFFER_SIZE, format, static_cast<tagint>(mybuf[m]),
|
||||
static_cast<int>(mybuf[m + 1]), mybuf[m + 2], mybuf[m + 3], mybuf[m + 4],
|
||||
static_cast<int>(mybuf[m + 5]), static_cast<int>(mybuf[m + 6]),
|
||||
static_cast<int>(mybuf[m + 7]));
|
||||
} else {
|
||||
written = snprintf(vbuffer, VBUFFER_SIZE, format,
|
||||
static_cast<tagint> (mybuf[m]), static_cast<int> (mybuf[m+1]),
|
||||
mybuf[m+2],mybuf[m+3],mybuf[m+4]);
|
||||
written =
|
||||
snprintf(vbuffer, VBUFFER_SIZE, format, static_cast<tagint>(mybuf[m]),
|
||||
static_cast<int>(mybuf[m + 1]), mybuf[m + 2], mybuf[m + 3], mybuf[m + 4]);
|
||||
}
|
||||
if (written > 0) {
|
||||
writer.write(vbuffer, written);
|
||||
@ -182,9 +174,7 @@ void DumpAtomZstd::write()
|
||||
if (multifile) {
|
||||
writer.close();
|
||||
} else {
|
||||
if (flush_flag && writer.isopen()) {
|
||||
writer.flush();
|
||||
}
|
||||
if (flush_flag && writer.isopen()) { writer.flush(); }
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -196,20 +186,23 @@ int DumpAtomZstd::modify_param(int narg, char **arg)
|
||||
int consumed = DumpAtom::modify_param(narg, arg);
|
||||
if (consumed == 0) {
|
||||
try {
|
||||
if (strcmp(arg[0],"checksum") == 0) {
|
||||
if (narg < 2) error->all(FLERR,"Illegal dump_modify command");
|
||||
if (strcmp(arg[1],"yes") == 0) writer.setChecksum(true);
|
||||
else if (strcmp(arg[1],"no") == 0) writer.setChecksum(false);
|
||||
else error->all(FLERR,"Illegal dump_modify command");
|
||||
if (strcmp(arg[0], "checksum") == 0) {
|
||||
if (narg < 2) error->all(FLERR, "Illegal dump_modify command");
|
||||
if (strcmp(arg[1], "yes") == 0)
|
||||
writer.setChecksum(true);
|
||||
else if (strcmp(arg[1], "no") == 0)
|
||||
writer.setChecksum(false);
|
||||
else
|
||||
error->all(FLERR, "Illegal dump_modify command");
|
||||
return 2;
|
||||
} else if (strcmp(arg[0],"compression_level") == 0) {
|
||||
if (narg < 2) error->all(FLERR,"Illegal dump_modify command");
|
||||
} else if (strcmp(arg[0], "compression_level") == 0) {
|
||||
if (narg < 2) error->all(FLERR, "Illegal dump_modify command");
|
||||
int compression_level = utils::inumeric(FLERR, arg[1], false, lmp);
|
||||
writer.setCompressionLevel(compression_level);
|
||||
return 2;
|
||||
}
|
||||
} catch (FileWriterException &e) {
|
||||
error->one(FLERR,"Illegal dump_modify command: {}", e.what());
|
||||
error->one(FLERR, "Illegal dump_modify command: {}", e.what());
|
||||
}
|
||||
}
|
||||
return consumed;
|
||||
|
||||
Reference in New Issue
Block a user