update and improve ADIOS support
- modernize code - remove dead code and unused definitions, enums, and includes - create default adios2_config.xml file if it doesn't exist - enable and apply clang-format - update documentation
This commit is contained in:
@ -35,13 +35,21 @@ Examples
|
|||||||
Description
|
Description
|
||||||
"""""""""""
|
"""""""""""
|
||||||
|
|
||||||
Dump a snapshot of atom coordinates every N timesteps in the
|
Dump a snapshot of atom coordinates every N timesteps in the `ADIOS
|
||||||
`ADIOS <adios_>`_ based "BP" file format, or using different I/O solutions in ADIOS,
|
<adios_>`_ based "BP" file format, or using different I/O solutions in
|
||||||
to a stream that can be read on-line by another program.
|
ADIOS, to a stream that can be read on-line by another program.
|
||||||
ADIOS-BP files are binary, portable and self-describing.
|
ADIOS-BP files are binary, portable and self-describing.
|
||||||
|
|
||||||
.. _adios: https://github.com/ornladios/ADIOS2
|
.. _adios: https://github.com/ornladios/ADIOS2
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
|
||||||
|
To be able to use ADIOS, a file ``adios2_config.xml`` with specific
|
||||||
|
configuration settings is expected in the current working directory.
|
||||||
|
If the file is not present, LAMMPS will try to create a minimal
|
||||||
|
default file. Please refer to the ADIOS documentation for details on
|
||||||
|
how to adjust this file for optimal performance and desired features.
|
||||||
|
|
||||||
**Use from write_dump:**
|
**Use from write_dump:**
|
||||||
|
|
||||||
It is possible to use these dump styles with the
|
It is possible to use these dump styles with the
|
||||||
|
|||||||
39
src/ADIOS/adios_common.h
Normal file
39
src/ADIOS/adios_common.h
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
/* -*- c++ -*- ----------------------------------------------------------
|
||||||
|
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||||
|
https://www.lammps.org/, Sandia National Laboratories
|
||||||
|
Steve Plimpton, sjplimp@sandia.gov
|
||||||
|
|
||||||
|
Copyright (2003) Sandia Corporation. Under the terms of Contract
|
||||||
|
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
|
||||||
|
certain rights in this software. This software is distributed under
|
||||||
|
the GNU General Public License.
|
||||||
|
|
||||||
|
See the README file in the top-level LAMMPS directory.
|
||||||
|
|
||||||
|
Contributed by Norbert Podhorszki (Oak Ridge National Laboratory)
|
||||||
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
#ifndef LMP_ADIOS_COMMON_H
|
||||||
|
#define LMP_ADIOS_COMMON_H
|
||||||
|
|
||||||
|
// common definitions for all ADIOS package classes
|
||||||
|
|
||||||
|
static const char default_config[] = "<?xml version=\"1.0\"?>\n"
|
||||||
|
"<adios-config>\n"
|
||||||
|
" <io name=\"atom\">\n"
|
||||||
|
" <engine type=\"BP4\">\n"
|
||||||
|
" <parameter key=\"substreams\" value=\"1\"/>\n"
|
||||||
|
" </engine>\n"
|
||||||
|
" </io>\n"
|
||||||
|
" <io name=\"custom\">\n"
|
||||||
|
" <engine type=\"BP4\">\n"
|
||||||
|
" <parameter key=\"substreams\" value=\"1\"/>\n"
|
||||||
|
" </engine>\n"
|
||||||
|
" </io>\n"
|
||||||
|
" <io name=\"read_dump\">\n"
|
||||||
|
" <engine type=\"BP4\">\n"
|
||||||
|
" </engine>\n"
|
||||||
|
" </io>\n"
|
||||||
|
"</adios-config>\n";
|
||||||
|
|
||||||
|
#endif
|
||||||
@ -1,4 +1,3 @@
|
|||||||
// clang-format off
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||||
https://www.lammps.org/, Sandia National Laboratories
|
https://www.lammps.org/, Sandia National Laboratories
|
||||||
@ -24,20 +23,16 @@
|
|||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
#include "universe.h"
|
#include "universe.h"
|
||||||
#include "update.h"
|
#include "update.h"
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
#include "adios2.h"
|
#include "adios2.h"
|
||||||
|
#include "adios_common.h"
|
||||||
|
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
|
|
||||||
#define MAX_TEXT_HEADER_SIZE 4096
|
namespace LAMMPS_NS {
|
||||||
#define DUMP_BUF_CHUNK_SIZE 16384
|
class DumpAtomADIOSInternal {
|
||||||
#define DUMP_BUF_INCREMENT_SIZE 4096
|
|
||||||
|
|
||||||
namespace LAMMPS_NS
|
|
||||||
{
|
|
||||||
class DumpAtomADIOSInternal
|
|
||||||
{
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DumpAtomADIOSInternal(){};
|
DumpAtomADIOSInternal(){};
|
||||||
@ -55,18 +50,21 @@ public:
|
|||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
DumpAtomADIOS::DumpAtomADIOS(LAMMPS *lmp, int narg, char **arg)
|
DumpAtomADIOS::DumpAtomADIOS(LAMMPS *lmp, int narg, char **arg) : DumpAtom(lmp, narg, arg)
|
||||||
: DumpAtom(lmp, narg, arg)
|
|
||||||
{
|
{
|
||||||
|
// create a default adios2_config.xml if it doesn't exist yet.
|
||||||
|
FILE *cfgfp = fopen("adios2_config.xml", "r");
|
||||||
|
if (!cfgfp) {
|
||||||
|
cfgfp = fopen("adios2_config.xml", "w");
|
||||||
|
if (cfgfp) fputs(default_config, cfgfp);
|
||||||
|
}
|
||||||
|
if (cfgfp) fclose(cfgfp);
|
||||||
|
|
||||||
internal = new DumpAtomADIOSInternal();
|
internal = new DumpAtomADIOSInternal();
|
||||||
try {
|
try {
|
||||||
internal->ad =
|
internal->ad = new adios2::ADIOS("adios2_config.xml", world, adios2::DebugON);
|
||||||
new adios2::ADIOS("adios2_config.xml", world, adios2::DebugON);
|
|
||||||
} catch (std::ios_base::failure &e) {
|
} catch (std::ios_base::failure &e) {
|
||||||
char str[256];
|
error->all(FLERR, "ADIOS initialization failed with error: {}", e.what());
|
||||||
snprintf(str, sizeof(str), "ADIOS initialization failed with error: %s",
|
|
||||||
e.what());
|
|
||||||
error->one(FLERR, str);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,9 +72,7 @@ DumpAtomADIOS::DumpAtomADIOS(LAMMPS *lmp, int narg, char **arg)
|
|||||||
|
|
||||||
DumpAtomADIOS::~DumpAtomADIOS()
|
DumpAtomADIOS::~DumpAtomADIOS()
|
||||||
{
|
{
|
||||||
if (internal->fh) {
|
if (internal->fh) internal->fh.Close();
|
||||||
internal->fh.Close();
|
|
||||||
}
|
|
||||||
delete internal->ad;
|
delete internal->ad;
|
||||||
delete internal;
|
delete internal;
|
||||||
}
|
}
|
||||||
@ -192,8 +188,7 @@ void DumpAtomADIOS::write()
|
|||||||
pack(ids);
|
pack(ids);
|
||||||
else
|
else
|
||||||
pack(nullptr);
|
pack(nullptr);
|
||||||
if (sort_flag)
|
if (sort_flag) sort();
|
||||||
sort();
|
|
||||||
|
|
||||||
openfile();
|
openfile();
|
||||||
internal->fh.BeginStep();
|
internal->fh.BeginStep();
|
||||||
@ -225,9 +220,7 @@ void DumpAtomADIOS::write()
|
|||||||
internal->fh.Put<double>(internal->varAtoms, buf);
|
internal->fh.Put<double>(internal->varAtoms, buf);
|
||||||
internal->fh.EndStep(); // I/O will happen now...
|
internal->fh.EndStep(); // I/O will happen now...
|
||||||
|
|
||||||
if (multifile) {
|
if (multifile) internal->fh.Close();
|
||||||
internal->fh.Close();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
@ -244,14 +237,13 @@ void DumpAtomADIOS::init_style()
|
|||||||
domain->boundary_string(boundstr);
|
domain->boundary_string(boundstr);
|
||||||
|
|
||||||
// remove % from filename since ADIOS always writes a global file with
|
// remove % from filename since ADIOS always writes a global file with
|
||||||
// data/metadata
|
// data/metadata.
|
||||||
int len = strlen(filename);
|
|
||||||
char *ptr = strchr(filename, '%');
|
char *ptr = strchr(filename, '%');
|
||||||
if (ptr) {
|
if (ptr) {
|
||||||
*ptr = '\0';
|
while (*ptr) {
|
||||||
char *s = new char[len - 1];
|
ptr[0] = ptr[1];
|
||||||
snprintf(s, sizeof(s), "%s%s", filename, ptr + 1);
|
++ptr;
|
||||||
strncpy(filename, s, len);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// setup column string
|
// setup column string
|
||||||
@ -295,16 +287,12 @@ void DumpAtomADIOS::init_style()
|
|||||||
// BPFile is the default writer
|
// BPFile is the default writer
|
||||||
internal->io.SetEngine("BPFile");
|
internal->io.SetEngine("BPFile");
|
||||||
int num_aggregators = multiproc;
|
int num_aggregators = multiproc;
|
||||||
if (num_aggregators == 0)
|
if (num_aggregators == 0) num_aggregators = 1;
|
||||||
num_aggregators = 1;
|
auto nstreams = std::to_string(num_aggregators);
|
||||||
char nstreams[128];
|
|
||||||
snprintf(nstreams, sizeof(nstreams), "%d", num_aggregators);
|
|
||||||
internal->io.SetParameters({{"substreams", nstreams}});
|
internal->io.SetParameters({{"substreams", nstreams}});
|
||||||
if (me == 0 && screen)
|
if (me == 0)
|
||||||
fprintf(
|
utils::logmesg(lmp, "ADIOS method for {} is n-to-m (aggregation with {} writers)\n", filename,
|
||||||
screen,
|
nstreams);
|
||||||
"ADIOS method for %s is n-to-m (aggregation with %s writers)\n",
|
|
||||||
filename, nstreams);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal->io.DefineVariable<uint64_t>("ntimestep");
|
internal->io.DefineVariable<uint64_t>("ntimestep");
|
||||||
@ -332,25 +320,20 @@ void DumpAtomADIOS::init_style()
|
|||||||
internal->io.DefineAttribute<int>("boundary", boundaryptr, 6);
|
internal->io.DefineAttribute<int>("boundary", boundaryptr, 6);
|
||||||
|
|
||||||
size_t nColumns = static_cast<size_t>(size_one);
|
size_t nColumns = static_cast<size_t>(size_one);
|
||||||
internal->io.DefineAttribute<std::string>("columns", columnNames.data(),
|
internal->io.DefineAttribute<std::string>("columns", columnNames.data(), nColumns);
|
||||||
nColumns);
|
|
||||||
internal->io.DefineAttribute<std::string>("columnstr", columns);
|
internal->io.DefineAttribute<std::string>("columnstr", columns);
|
||||||
internal->io.DefineAttribute<std::string>("boundarystr", boundstr);
|
internal->io.DefineAttribute<std::string>("boundarystr", boundstr);
|
||||||
internal->io.DefineAttribute<std::string>("LAMMPS/dump_style", "atom");
|
internal->io.DefineAttribute<std::string>("LAMMPS/dump_style", "atom");
|
||||||
internal->io.DefineAttribute<std::string>("LAMMPS/version",
|
internal->io.DefineAttribute<std::string>("LAMMPS/version", lmp->version);
|
||||||
lmp->version);
|
internal->io.DefineAttribute<std::string>("LAMMPS/num_ver", std::to_string(lmp->num_ver));
|
||||||
internal->io.DefineAttribute<std::string>("LAMMPS/num_ver",
|
|
||||||
std::to_string(lmp->num_ver));
|
|
||||||
|
|
||||||
internal->io.DefineVariable<uint64_t>(
|
// local dimension variables
|
||||||
"nme", {adios2::LocalValueDim}); // local dimension variable
|
internal->io.DefineVariable<uint64_t>("nme", {adios2::LocalValueDim});
|
||||||
internal->io.DefineVariable<uint64_t>(
|
internal->io.DefineVariable<uint64_t>("offset", {adios2::LocalValueDim});
|
||||||
"offset", {adios2::LocalValueDim}); // local dimension variable
|
|
||||||
|
|
||||||
// atom table size is not known at the moment
|
// atom table size is not known at the moment
|
||||||
// it will be correctly defined at the moment of write
|
// it will be correctly defined at the moment of write
|
||||||
size_t UnknownSizeYet = 1;
|
size_t UnknownSizeYet = 1;
|
||||||
internal->varAtoms = internal->io.DefineVariable<double>(
|
internal->varAtoms = internal->io.DefineVariable<double>(
|
||||||
"atoms", {UnknownSizeYet, nColumns}, {UnknownSizeYet, 0},
|
"atoms", {UnknownSizeYet, nColumns}, {UnknownSizeYet, 0}, {UnknownSizeYet, nColumns});
|
||||||
{UnknownSizeYet, nColumns});
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
// clang-format off
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||||
https://www.lammps.org/, Sandia National Laboratories
|
https://www.lammps.org/, Sandia National Laboratories
|
||||||
@ -17,98 +16,28 @@
|
|||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
#include "dump_custom_adios.h"
|
#include "dump_custom_adios.h"
|
||||||
|
|
||||||
#include "atom.h"
|
#include "atom.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 "input.h"
|
#include "input.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
#include "modify.h"
|
#include "modify.h"
|
||||||
#include "region.h"
|
|
||||||
#include "universe.h"
|
|
||||||
#include "update.h"
|
#include "update.h"
|
||||||
#include "variable.h"
|
#include "variable.h"
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
#include "adios2.h"
|
#include "adios2.h"
|
||||||
|
#include "adios_common.h"
|
||||||
|
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
|
|
||||||
#define MAX_TEXT_HEADER_SIZE 4096
|
namespace LAMMPS_NS {
|
||||||
#define DUMP_BUF_CHUNK_SIZE 16384
|
class DumpCustomADIOSInternal {
|
||||||
#define DUMP_BUF_INCREMENT_SIZE 4096
|
|
||||||
|
|
||||||
enum {
|
|
||||||
ID,
|
|
||||||
MOL,
|
|
||||||
TYPE,
|
|
||||||
ELEMENT,
|
|
||||||
MASS,
|
|
||||||
X,
|
|
||||||
Y,
|
|
||||||
Z,
|
|
||||||
XS,
|
|
||||||
YS,
|
|
||||||
ZS,
|
|
||||||
XSTRI,
|
|
||||||
YSTRI,
|
|
||||||
ZSTRI,
|
|
||||||
XU,
|
|
||||||
YU,
|
|
||||||
ZU,
|
|
||||||
XUTRI,
|
|
||||||
YUTRI,
|
|
||||||
ZUTRI,
|
|
||||||
XSU,
|
|
||||||
YSU,
|
|
||||||
ZSU,
|
|
||||||
XSUTRI,
|
|
||||||
YSUTRI,
|
|
||||||
ZSUTRI,
|
|
||||||
IX,
|
|
||||||
IY,
|
|
||||||
IZ,
|
|
||||||
VX,
|
|
||||||
VY,
|
|
||||||
VZ,
|
|
||||||
FX,
|
|
||||||
FY,
|
|
||||||
FZ,
|
|
||||||
Q,
|
|
||||||
MUX,
|
|
||||||
MUY,
|
|
||||||
MUZ,
|
|
||||||
MU,
|
|
||||||
RADIUS,
|
|
||||||
DIAMETER,
|
|
||||||
OMEGAX,
|
|
||||||
OMEGAY,
|
|
||||||
OMEGAZ,
|
|
||||||
ANGMOMX,
|
|
||||||
ANGMOMY,
|
|
||||||
ANGMOMZ,
|
|
||||||
TQX,
|
|
||||||
TQY,
|
|
||||||
TQZ,
|
|
||||||
SPIN,
|
|
||||||
ERADIUS,
|
|
||||||
ERVEL,
|
|
||||||
ERFORCE,
|
|
||||||
COMPUTE,
|
|
||||||
FIX,
|
|
||||||
VARIABLE
|
|
||||||
};
|
|
||||||
enum { LT, LE, GT, GE, EQ, NEQ };
|
|
||||||
enum { INT, DOUBLE, STRING, BIGINT }; // same as in DumpCustom
|
|
||||||
|
|
||||||
namespace LAMMPS_NS
|
|
||||||
{
|
|
||||||
class DumpCustomADIOSInternal
|
|
||||||
{
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DumpCustomADIOSInternal(){};
|
DumpCustomADIOSInternal(){};
|
||||||
@ -129,28 +58,25 @@ public:
|
|||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
DumpCustomADIOS::DumpCustomADIOS(LAMMPS *lmp, int narg, char **arg)
|
DumpCustomADIOS::DumpCustomADIOS(LAMMPS *lmp, int narg, char **arg) : DumpCustom(lmp, narg, arg)
|
||||||
: DumpCustom(lmp, narg, arg)
|
|
||||||
{
|
{
|
||||||
|
// create a default adios2_config.xml if it doesn't exist yet.
|
||||||
|
FILE *cfgfp = fopen("adios2_config.xml", "r");
|
||||||
|
if (!cfgfp) {
|
||||||
|
cfgfp = fopen("adios2_config.xml", "w");
|
||||||
|
if (cfgfp) fputs(default_config, cfgfp);
|
||||||
|
}
|
||||||
|
if (cfgfp) fclose(cfgfp);
|
||||||
|
|
||||||
internal = new DumpCustomADIOSInternal();
|
internal = new DumpCustomADIOSInternal();
|
||||||
try {
|
try {
|
||||||
internal->ad =
|
internal->ad = new adios2::ADIOS("adios2_config.xml", world, adios2::DebugON);
|
||||||
new adios2::ADIOS("adios2_config.xml", world, adios2::DebugON);
|
|
||||||
} catch (std::ios_base::failure &e) {
|
} catch (std::ios_base::failure &e) {
|
||||||
char str[256];
|
error->all(FLERR, "ADIOS initialization failed with error: {}", e.what());
|
||||||
snprintf(str, sizeof(str), "ADIOS initialization failed with error: %s",
|
|
||||||
e.what());
|
|
||||||
error->one(FLERR, str);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (screen) fprintf(screen, "DumpCustomADIOS constructor: nvariable=%d
|
|
||||||
// id_variable=%p, variables=%p, nfield=%d, earg=%p\n", nvariable,
|
|
||||||
// id_variable, variable, nfield, earg);
|
|
||||||
internal->columnNames.reserve(nfield);
|
internal->columnNames.reserve(nfield);
|
||||||
for (int i = 0; i < nfield; ++i) {
|
for (int i = 0; i < nfield; ++i) { internal->columnNames.push_back(earg[i]); }
|
||||||
internal->columnNames.push_back(earg[i]);
|
|
||||||
// if (screen) fprintf(screen, "earg[%d] = '%s'\n", i, earg[i]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
@ -158,9 +84,7 @@ DumpCustomADIOS::DumpCustomADIOS(LAMMPS *lmp, int narg, char **arg)
|
|||||||
DumpCustomADIOS::~DumpCustomADIOS()
|
DumpCustomADIOS::~DumpCustomADIOS()
|
||||||
{
|
{
|
||||||
internal->columnNames.clear();
|
internal->columnNames.clear();
|
||||||
if (internal->fh) {
|
if (internal->fh) { internal->fh.Close(); }
|
||||||
internal->fh.Close();
|
|
||||||
}
|
|
||||||
delete internal->ad;
|
delete internal->ad;
|
||||||
delete internal;
|
delete internal;
|
||||||
}
|
}
|
||||||
@ -260,8 +184,7 @@ void DumpCustomADIOS::write()
|
|||||||
// sort buf as needed
|
// sort buf as needed
|
||||||
|
|
||||||
if (nme > maxbuf) {
|
if (nme > maxbuf) {
|
||||||
if ((bigint)nme * size_one > MAXSMALLINT)
|
if ((bigint) nme * size_one > MAXSMALLINT) error->all(FLERR, "Too much per-proc info for dump");
|
||||||
error->all(FLERR, "Too much per-proc info for dump");
|
|
||||||
maxbuf = nme;
|
maxbuf = nme;
|
||||||
memory->destroy(buf);
|
memory->destroy(buf);
|
||||||
memory->create(buf, (maxbuf * size_one), "dump:buf");
|
memory->create(buf, (maxbuf * size_one), "dump:buf");
|
||||||
@ -276,8 +199,7 @@ void DumpCustomADIOS::write()
|
|||||||
pack(ids);
|
pack(ids);
|
||||||
else
|
else
|
||||||
pack(nullptr);
|
pack(nullptr);
|
||||||
if (sort_flag)
|
if (sort_flag) sort();
|
||||||
sort();
|
|
||||||
|
|
||||||
openfile();
|
openfile();
|
||||||
internal->fh.BeginStep();
|
internal->fh.BeginStep();
|
||||||
@ -309,29 +231,25 @@ void DumpCustomADIOS::write()
|
|||||||
internal->fh.Put<double>("atoms", buf);
|
internal->fh.Put<double>("atoms", buf);
|
||||||
internal->fh.EndStep(); // I/O will happen now...
|
internal->fh.EndStep(); // I/O will happen now...
|
||||||
|
|
||||||
if (multifile) {
|
if (multifile) { internal->fh.Close(); }
|
||||||
internal->fh.Close();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
void DumpCustomADIOS::init_style()
|
void DumpCustomADIOS::init_style()
|
||||||
{
|
{
|
||||||
|
|
||||||
// setup boundary string
|
// setup boundary string
|
||||||
|
|
||||||
domain->boundary_string(boundstr);
|
domain->boundary_string(boundstr);
|
||||||
|
|
||||||
// remove % from filename since ADIOS always writes a global file with
|
// remove % from filename since ADIOS always writes a global file with
|
||||||
// data/metadata
|
// data/metadata
|
||||||
int len = strlen(filename);
|
|
||||||
char *ptr = strchr(filename, '%');
|
char *ptr = strchr(filename, '%');
|
||||||
if (ptr) {
|
if (ptr) {
|
||||||
*ptr = '\0';
|
while (*ptr) {
|
||||||
char *s = new char[len - 1];
|
ptr[0] = ptr[1];
|
||||||
sprintf(s, "%s%s", filename, ptr + 1);
|
++ptr;
|
||||||
strncpy(filename, s, len);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The next four loops are copied from dump_custom_mpiio, but nothing is
|
/* The next four loops are copied from dump_custom_mpiio, but nothing is
|
||||||
@ -345,35 +263,30 @@ void DumpCustomADIOS::init_style()
|
|||||||
int icompute;
|
int icompute;
|
||||||
for (int i = 0; i < ncompute; i++) {
|
for (int i = 0; i < ncompute; i++) {
|
||||||
icompute = modify->find_compute(id_compute[i]);
|
icompute = modify->find_compute(id_compute[i]);
|
||||||
if (icompute < 0)
|
if (icompute < 0) error->all(FLERR, "Could not find dump custom compute ID");
|
||||||
error->all(FLERR, "Could not find dump custom compute ID");
|
|
||||||
compute[i] = modify->compute[icompute];
|
compute[i] = modify->compute[icompute];
|
||||||
}
|
}
|
||||||
|
|
||||||
int ifix;
|
int ifix;
|
||||||
for (int i = 0; i < nfix; i++) {
|
for (int i = 0; i < nfix; i++) {
|
||||||
ifix = modify->find_fix(id_fix[i]);
|
ifix = modify->find_fix(id_fix[i]);
|
||||||
if (ifix < 0)
|
if (ifix < 0) error->all(FLERR, "Could not find dump custom fix ID");
|
||||||
error->all(FLERR, "Could not find dump custom fix ID");
|
|
||||||
fix[i] = modify->fix[ifix];
|
fix[i] = modify->fix[ifix];
|
||||||
if (nevery % modify->fix[ifix]->peratom_freq)
|
if (nevery % modify->fix[ifix]->peratom_freq)
|
||||||
error->all(FLERR,
|
error->all(FLERR, "Dump custom and fix not computed at compatible times");
|
||||||
"Dump custom and fix not computed at compatible times");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int ivariable;
|
int ivariable;
|
||||||
for (int i = 0; i < nvariable; i++) {
|
for (int i = 0; i < nvariable; i++) {
|
||||||
ivariable = input->variable->find(id_variable[i]);
|
ivariable = input->variable->find(id_variable[i]);
|
||||||
if (ivariable < 0)
|
if (ivariable < 0) error->all(FLERR, "Could not find dump custom variable name");
|
||||||
error->all(FLERR, "Could not find dump custom variable name");
|
|
||||||
variable[i] = ivariable;
|
variable[i] = ivariable;
|
||||||
}
|
}
|
||||||
|
|
||||||
// set index and check validity of region
|
// set index and check validity of region
|
||||||
if (iregion >= 0) {
|
if (iregion >= 0) {
|
||||||
iregion = domain->find_region(idregion);
|
iregion = domain->find_region(idregion);
|
||||||
if (iregion == -1)
|
if (iregion == -1) error->all(FLERR, "Region ID for dump custom does not exist");
|
||||||
error->all(FLERR, "Region ID for dump custom does not exist");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Define the group of variables for the atom style here since it's a fixed
|
/* Define the group of variables for the atom style here since it's a fixed
|
||||||
@ -384,16 +297,12 @@ void DumpCustomADIOS::init_style()
|
|||||||
// BPFile is the default writer
|
// BPFile is the default writer
|
||||||
internal->io.SetEngine("BPFile");
|
internal->io.SetEngine("BPFile");
|
||||||
int num_aggregators = multiproc;
|
int num_aggregators = multiproc;
|
||||||
if (num_aggregators == 0)
|
if (num_aggregators == 0) num_aggregators = 1;
|
||||||
num_aggregators = 1;
|
auto nstreams = std::to_string(num_aggregators);
|
||||||
char nstreams[128];
|
|
||||||
sprintf(nstreams, "%d", num_aggregators);
|
|
||||||
internal->io.SetParameters({{"substreams", nstreams}});
|
internal->io.SetParameters({{"substreams", nstreams}});
|
||||||
if (me == 0 && screen)
|
if (me == 0)
|
||||||
fprintf(
|
utils::logmesg(lmp, "ADIOS method for {} is n-to-m (aggregation with {} writers)\n", filename,
|
||||||
screen,
|
nstreams);
|
||||||
"ADIOS method for %s is n-to-m (aggregation with %s writers)\n",
|
|
||||||
filename, nstreams);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal->io.DefineVariable<uint64_t>("ntimestep");
|
internal->io.DefineVariable<uint64_t>("ntimestep");
|
||||||
@ -419,25 +328,21 @@ void DumpCustomADIOS::init_style()
|
|||||||
internal->io.DefineAttribute<int>("boundary", boundaryptr, 6);
|
internal->io.DefineAttribute<int>("boundary", boundaryptr, 6);
|
||||||
|
|
||||||
size_t nColumns = static_cast<size_t>(size_one);
|
size_t nColumns = static_cast<size_t>(size_one);
|
||||||
internal->io.DefineAttribute<std::string>(
|
internal->io.DefineAttribute<std::string>("columns", internal->columnNames.data(), nColumns);
|
||||||
"columns", internal->columnNames.data(), nColumns);
|
|
||||||
internal->io.DefineAttribute<std::string>("columnstr", columns);
|
internal->io.DefineAttribute<std::string>("columnstr", columns);
|
||||||
internal->io.DefineAttribute<std::string>("boundarystr", boundstr);
|
internal->io.DefineAttribute<std::string>("boundarystr", boundstr);
|
||||||
internal->io.DefineAttribute<std::string>("LAMMPS/dump_style", "custom");
|
internal->io.DefineAttribute<std::string>("LAMMPS/dump_style", "custom");
|
||||||
internal->io.DefineAttribute<std::string>("LAMMPS/version",
|
internal->io.DefineAttribute<std::string>("LAMMPS/version", lmp->version);
|
||||||
lmp->version);
|
internal->io.DefineAttribute<std::string>("LAMMPS/num_ver", std::to_string(lmp->num_ver));
|
||||||
internal->io.DefineAttribute<std::string>("LAMMPS/num_ver",
|
|
||||||
std::to_string(lmp->num_ver));
|
|
||||||
|
|
||||||
internal->io.DefineVariable<uint64_t>(
|
internal->io.DefineVariable<uint64_t>("nme",
|
||||||
"nme", {adios2::LocalValueDim}); // local dimension variable
|
{adios2::LocalValueDim}); // local dimension variable
|
||||||
internal->io.DefineVariable<uint64_t>(
|
internal->io.DefineVariable<uint64_t>("offset",
|
||||||
"offset", {adios2::LocalValueDim}); // local dimension variable
|
{adios2::LocalValueDim}); // local dimension variable
|
||||||
|
|
||||||
// atom table size is not known at the moment
|
// atom table size is not known at the moment
|
||||||
// it will be correctly defined at the moment of write
|
// it will be correctly defined at the moment of write
|
||||||
size_t UnknownSizeYet = 1;
|
size_t UnknownSizeYet = 1;
|
||||||
internal->varAtoms = internal->io.DefineVariable<double>(
|
internal->varAtoms = internal->io.DefineVariable<double>(
|
||||||
"atoms", {UnknownSizeYet, nColumns}, {UnknownSizeYet, 0},
|
"atoms", {UnknownSizeYet, nColumns}, {UnknownSizeYet, 0}, {UnknownSizeYet, nColumns});
|
||||||
{UnknownSizeYet, nColumns});
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
// clang-format off
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||||
https://www.lammps.org/, Sandia National Laboratories
|
https://www.lammps.org/, Sandia National Laboratories
|
||||||
@ -17,20 +16,20 @@
|
|||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
#include "reader_adios.h"
|
#include "reader_adios.h"
|
||||||
|
|
||||||
#include "comm.h"
|
#include "comm.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
#include "adios2.h"
|
#include "adios2.h"
|
||||||
#include "math_const.h"
|
#include "adios_common.h"
|
||||||
|
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
|
|
||||||
using namespace MathConst;
|
|
||||||
|
|
||||||
// also in read_dump.cpp
|
// also in read_dump.cpp
|
||||||
|
|
||||||
enum { ID, TYPE, X, Y, Z, VX, VY, VZ, Q, IX, IY, IZ, FX, FY, FZ };
|
enum { ID, TYPE, X, Y, Z, VX, VY, VZ, Q, IX, IY, IZ, FX, FY, FZ };
|
||||||
@ -38,17 +37,8 @@ enum { UNSET, NOSCALE_NOWRAP, NOSCALE_WRAP, SCALE_NOWRAP, SCALE_WRAP };
|
|||||||
|
|
||||||
#define SMALL 1.0e-6
|
#define SMALL 1.0e-6
|
||||||
|
|
||||||
// true if the difference between two floats is "small".
|
namespace LAMMPS_NS {
|
||||||
// cannot use fabsf() since it is not fully portable.
|
class ReadADIOSInternal {
|
||||||
static bool is_smalldiff(const float &val1, const float &val2)
|
|
||||||
{
|
|
||||||
return (fabs(static_cast<double>(val1 - val2)) < SMALL);
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace LAMMPS_NS
|
|
||||||
{
|
|
||||||
class ReadADIOSInternal
|
|
||||||
{
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ReadADIOSInternal(){};
|
ReadADIOSInternal(){};
|
||||||
@ -82,15 +72,19 @@ ReaderADIOS::ReaderADIOS(LAMMPS *lmp) : Reader(lmp)
|
|||||||
nid = 0;
|
nid = 0;
|
||||||
me = comm->me;
|
me = comm->me;
|
||||||
|
|
||||||
|
// create a default adios2_config.xml if it doesn't exist yet.
|
||||||
|
FILE *cfgfp = fopen("adios2_config.xml", "r");
|
||||||
|
if (!cfgfp) {
|
||||||
|
cfgfp = fopen("adios2_config.xml", "w");
|
||||||
|
if (cfgfp) fputs(default_config, cfgfp);
|
||||||
|
}
|
||||||
|
if (cfgfp) fclose(cfgfp);
|
||||||
|
|
||||||
internal = new ReadADIOSInternal();
|
internal = new ReadADIOSInternal();
|
||||||
try {
|
try {
|
||||||
internal->ad =
|
internal->ad = new adios2::ADIOS("adios2_config.xml", world, adios2::DebugON);
|
||||||
new adios2::ADIOS("adios2_config.xml", world, adios2::DebugON);
|
|
||||||
} catch (std::ios_base::failure &e) {
|
} catch (std::ios_base::failure &e) {
|
||||||
char str[256];
|
error->one(FLERR, "ADIOS initialization failed with error: {}", e.what());
|
||||||
snprintf(str, sizeof(str), "ADIOS initialization failed with error: %s",
|
|
||||||
e.what());
|
|
||||||
error->one(FLERR, str);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Define the group holding all variables and attributes */
|
/* Define the group holding all variables and attributes */
|
||||||
@ -101,13 +95,9 @@ ReaderADIOS::ReaderADIOS(LAMMPS *lmp) : Reader(lmp)
|
|||||||
|
|
||||||
ReaderADIOS::~ReaderADIOS()
|
ReaderADIOS::~ReaderADIOS()
|
||||||
{
|
{
|
||||||
if (me == 0) {
|
if (me == 0) memory->destroy(fieldindex);
|
||||||
memory->destroy(fieldindex);
|
|
||||||
}
|
|
||||||
internal->columnNames.clear();
|
internal->columnNames.clear();
|
||||||
if (internal->fh) {
|
if (internal->fh) internal->fh.Close();
|
||||||
internal->fh.Close();
|
|
||||||
}
|
|
||||||
delete internal->ad;
|
delete internal->ad;
|
||||||
delete internal;
|
delete internal;
|
||||||
}
|
}
|
||||||
@ -126,11 +116,7 @@ void ReaderADIOS::settings(int narg, char **arg)
|
|||||||
internal->io.SetParameter("OpenTimeoutSecs", arg[idx + 1]);
|
internal->io.SetParameter("OpenTimeoutSecs", arg[idx + 1]);
|
||||||
++idx;
|
++idx;
|
||||||
} else {
|
} else {
|
||||||
char str[128];
|
error->one(FLERR, "Missing value for 'timeout' option for ADIOS read_dump command");
|
||||||
snprintf(str, sizeof(str),
|
|
||||||
"Missing value for 'timeout' option for ADIOS "
|
|
||||||
"read_dump command");
|
|
||||||
error->one(FLERR, str);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
++idx;
|
++idx;
|
||||||
@ -142,26 +128,17 @@ void ReaderADIOS::settings(int narg, char **arg)
|
|||||||
Every process must call this Collective operation
|
Every process must call this Collective operation
|
||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void ReaderADIOS::open_file(const char *file)
|
void ReaderADIOS::open_file(const std::string &file)
|
||||||
{
|
{
|
||||||
int rv;
|
|
||||||
char str[1024];
|
|
||||||
|
|
||||||
// close open file, if needed.
|
// close open file, if needed.
|
||||||
if (internal->fh)
|
if (internal->fh) internal->fh.Close();
|
||||||
internal->fh.Close();
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
internal->fh = internal->io.Open(file, adios2::Mode::Read, world);
|
internal->fh = internal->io.Open(file, adios2::Mode::Read, world);
|
||||||
} catch (std::ios_base::failure &e) {
|
} catch (std::ios_base::failure &e) {
|
||||||
char str[256];
|
error->one(FLERR, "Error opening file {}: {}", file, e.what());
|
||||||
snprintf(str, sizeof(str), "%s", e.what());
|
|
||||||
error->one(FLERR, str);
|
|
||||||
}
|
|
||||||
if (!internal->fh) {
|
|
||||||
snprintf(str, sizeof(str), "Cannot open file %s using ADIOS", file);
|
|
||||||
error->one(FLERR, str);
|
|
||||||
}
|
}
|
||||||
|
if (!internal->fh) error->one(FLERR, "Cannot open file {} using ADIOS", file);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
@ -172,9 +149,7 @@ void ReaderADIOS::open_file(const char *file)
|
|||||||
void ReaderADIOS::close_file()
|
void ReaderADIOS::close_file()
|
||||||
{
|
{
|
||||||
// close open file, if needed.
|
// close open file, if needed.
|
||||||
if (internal->fh) {
|
if (internal->fh) { internal->fh.Close(); }
|
||||||
internal->fh.Close();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
@ -185,10 +160,7 @@ void ReaderADIOS::close_file()
|
|||||||
|
|
||||||
int ReaderADIOS::read_time(bigint &ntimestep)
|
int ReaderADIOS::read_time(bigint &ntimestep)
|
||||||
{
|
{
|
||||||
char str[1024];
|
adios2::StepStatus status = internal->fh.BeginStep(adios2::StepMode::Read, internal->timeout);
|
||||||
|
|
||||||
adios2::StepStatus status =
|
|
||||||
internal->fh.BeginStep(adios2::StepMode::Read, internal->timeout);
|
|
||||||
|
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case adios2::StepStatus::EndOfStream:
|
case adios2::StepStatus::EndOfStream:
|
||||||
@ -199,19 +171,12 @@ int ReaderADIOS::read_time(bigint &ntimestep)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal->varNtimestep =
|
internal->varNtimestep = internal->io.InquireVariable<uint64_t>("ntimestep");
|
||||||
internal->io.InquireVariable<uint64_t>("ntimestep");
|
|
||||||
|
|
||||||
if (!internal->varNtimestep) {
|
if (!internal->varNtimestep)
|
||||||
snprintf(str, sizeof(str),
|
error->one(FLERR, "Did not find 'ntimestep' variable in ADIOS file {}", internal->fh.Name());
|
||||||
"Did not find 'ntimestep' variable in ADIOS file %s",
|
|
||||||
internal->fh.Name().c_str());
|
|
||||||
error->one(FLERR, str);
|
|
||||||
}
|
|
||||||
|
|
||||||
ntimestep = static_cast<bigint>(internal->varNtimestep.Max());
|
ntimestep = static_cast<bigint>(internal->varNtimestep.Max());
|
||||||
// std::cerr << " **** ReaderADIOS::read_time found step " << ntimestep
|
|
||||||
// << " **** " << std::endl;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -220,7 +185,10 @@ int ReaderADIOS::read_time(bigint &ntimestep)
|
|||||||
Called by all processors.
|
Called by all processors.
|
||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void ReaderADIOS::skip() { internal->fh.EndStep(); }
|
void ReaderADIOS::skip()
|
||||||
|
{
|
||||||
|
internal->fh.EndStep();
|
||||||
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
read remaining header info:
|
read remaining header info:
|
||||||
@ -236,31 +204,24 @@ void ReaderADIOS::skip() { internal->fh.EndStep(); }
|
|||||||
only called by proc 0
|
only called by proc 0
|
||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
bigint ReaderADIOS::read_header(double box[3][3], int &boxinfo, int &triclinic,
|
bigint ReaderADIOS::read_header(double box[3][3], int &boxinfo, int &triclinic, int fieldinfo,
|
||||||
int fieldinfo, int nfield, int *fieldtype,
|
int nfield, int *fieldtype, char **fieldlabel, int scaleflag,
|
||||||
char **fieldlabel, int scaleflag, int wrapflag,
|
int wrapflag, int &fieldflag, int &xflag, int &yflag, int &zflag)
|
||||||
int &fieldflag, int &xflag, int &yflag,
|
|
||||||
int &zflag)
|
|
||||||
{
|
{
|
||||||
char str[1024];
|
|
||||||
nid = 0;
|
nid = 0;
|
||||||
|
|
||||||
// signal that we have no box info at all so far.
|
// signal that we have no box info at all so far.
|
||||||
|
|
||||||
internal->varNatoms = internal->io.InquireVariable<uint64_t>("natoms");
|
internal->varNatoms = internal->io.InquireVariable<uint64_t>("natoms");
|
||||||
if (!internal->varNatoms) {
|
if (!internal->varNatoms)
|
||||||
snprintf(str, sizeof(str),
|
error->one(FLERR, "Did not find 'natoms' variable in ADIOS file {}", internal->fh.Name());
|
||||||
"Did not find 'natoms' variable in ADIOS file %s",
|
|
||||||
internal->fh.Name().c_str());
|
|
||||||
error->one(FLERR, str);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* nAtoms */
|
/* nAtoms */
|
||||||
nAtomsTotal = internal->varNatoms.Max();
|
nAtomsTotal = internal->varNatoms.Max();
|
||||||
uint64_t rem = nAtomsTotal % comm->nprocs;
|
uint64_t rem = nAtomsTotal % comm->nprocs;
|
||||||
nAtoms = nAtomsTotal / comm->nprocs;
|
nAtoms = nAtomsTotal / comm->nprocs;
|
||||||
atomOffset = comm->me * nAtoms;
|
atomOffset = comm->me * nAtoms;
|
||||||
if (comm->me < rem) {
|
if (comm->me < (int)rem) {
|
||||||
++nAtoms;
|
++nAtoms;
|
||||||
atomOffset += comm->me;
|
atomOffset += comm->me;
|
||||||
} else {
|
} else {
|
||||||
@ -268,30 +229,19 @@ bigint ReaderADIOS::read_header(double box[3][3], int &boxinfo, int &triclinic,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* triclinic */
|
/* triclinic */
|
||||||
adios2::Attribute<int32_t> attTriclinic =
|
adios2::Attribute<int32_t> attTriclinic = internal->io.InquireAttribute<int32_t>("triclinic");
|
||||||
internal->io.InquireAttribute<int32_t>("triclinic");
|
if (!attTriclinic)
|
||||||
if (!attTriclinic) {
|
error->one(FLERR, "Did not find 'triclinic' attribute in ADIOS file {}", internal->fh.Name());
|
||||||
snprintf(str, sizeof(str),
|
|
||||||
"Did not find 'triclinic' attribute in ADIOS file %s",
|
|
||||||
internal->fh.Name().c_str());
|
|
||||||
error->one(FLERR, str);
|
|
||||||
}
|
|
||||||
|
|
||||||
triclinic = attTriclinic.Data()[0];
|
triclinic = attTriclinic.Data()[0];
|
||||||
|
|
||||||
/* read Box */
|
/* read Box */
|
||||||
adios2::Variable<double> varBoxxlo =
|
adios2::Variable<double> varBoxxlo = internal->io.InquireVariable<double>("boxxlo");
|
||||||
internal->io.InquireVariable<double>("boxxlo");
|
adios2::Variable<double> varBoxxhi = internal->io.InquireVariable<double>("boxxhi");
|
||||||
adios2::Variable<double> varBoxxhi =
|
adios2::Variable<double> varBoxylo = internal->io.InquireVariable<double>("boxylo");
|
||||||
internal->io.InquireVariable<double>("boxxhi");
|
adios2::Variable<double> varBoxyhi = internal->io.InquireVariable<double>("boxyhi");
|
||||||
adios2::Variable<double> varBoxylo =
|
adios2::Variable<double> varBoxzlo = internal->io.InquireVariable<double>("boxzlo");
|
||||||
internal->io.InquireVariable<double>("boxylo");
|
adios2::Variable<double> varBoxzhi = internal->io.InquireVariable<double>("boxzhi");
|
||||||
adios2::Variable<double> varBoxyhi =
|
|
||||||
internal->io.InquireVariable<double>("boxyhi");
|
|
||||||
adios2::Variable<double> varBoxzlo =
|
|
||||||
internal->io.InquireVariable<double>("boxzlo");
|
|
||||||
adios2::Variable<double> varBoxzhi =
|
|
||||||
internal->io.InquireVariable<double>("boxzhi");
|
|
||||||
|
|
||||||
box[0][0] = varBoxxlo.Max();
|
box[0][0] = varBoxxlo.Max();
|
||||||
box[0][1] = varBoxxhi.Max();
|
box[0][1] = varBoxxhi.Max();
|
||||||
@ -304,12 +254,9 @@ bigint ReaderADIOS::read_header(double box[3][3], int &boxinfo, int &triclinic,
|
|||||||
box[2][2] = 0.0;
|
box[2][2] = 0.0;
|
||||||
|
|
||||||
if (triclinic) {
|
if (triclinic) {
|
||||||
adios2::Variable<double> varBoxxy =
|
adios2::Variable<double> varBoxxy = internal->io.InquireVariable<double>("boxxy");
|
||||||
internal->io.InquireVariable<double>("boxxy");
|
adios2::Variable<double> varBoxxz = internal->io.InquireVariable<double>("boxxz");
|
||||||
adios2::Variable<double> varBoxxz =
|
adios2::Variable<double> varBoxyz = internal->io.InquireVariable<double>("boxyz");
|
||||||
internal->io.InquireVariable<double>("boxxz");
|
|
||||||
adios2::Variable<double> varBoxyz =
|
|
||||||
internal->io.InquireVariable<double>("boxyz");
|
|
||||||
|
|
||||||
box[0][2] = varBoxxy.Max();
|
box[0][2] = varBoxxy.Max();
|
||||||
box[1][2] = varBoxxz.Max();
|
box[1][2] = varBoxxz.Max();
|
||||||
@ -320,21 +267,17 @@ bigint ReaderADIOS::read_header(double box[3][3], int &boxinfo, int &triclinic,
|
|||||||
|
|
||||||
// if no field info requested, just return
|
// if no field info requested, just return
|
||||||
|
|
||||||
if (!fieldinfo)
|
if (!fieldinfo) return nAtoms;
|
||||||
return nAtoms;
|
|
||||||
|
|
||||||
memory->create(fieldindex, nfield, "read_dump:fieldindex");
|
memory->create(fieldindex, nfield, "read_dump:fieldindex");
|
||||||
|
|
||||||
/* Columns */
|
/* Columns */
|
||||||
adios2::Attribute<std::string> attColumns =
|
adios2::Attribute<std::string> attColumns = internal->io.InquireAttribute<std::string>("columns");
|
||||||
internal->io.InquireAttribute<std::string>("columns");
|
|
||||||
|
|
||||||
std::vector<std::string> labelVector = attColumns.Data();
|
std::vector<std::string> labelVector = attColumns.Data();
|
||||||
int nwords = labelVector.size();
|
int nwords = labelVector.size();
|
||||||
std::map<std::string, int> labels;
|
std::map<std::string, int> labels;
|
||||||
for (int i = 0; i < nwords; ++i) {
|
for (int i = 0; i < nwords; ++i) { labels.emplace(labelVector[i], i); }
|
||||||
labels.emplace(labelVector[i], i);
|
|
||||||
}
|
|
||||||
|
|
||||||
int s_index, u_index, su_index;
|
int s_index, u_index, su_index;
|
||||||
xflag = UNSET;
|
xflag = UNSET;
|
||||||
@ -380,8 +323,7 @@ bigint ReaderADIOS::read_header(double box[3][3], int &boxinfo, int &triclinic,
|
|||||||
xflag = SCALE_NOWRAP;
|
xflag = SCALE_NOWRAP;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (fieldindex[i] == nwords)
|
if (fieldindex[i] == nwords) fieldindex[i] = -1;
|
||||||
fieldindex[i] = -1;
|
|
||||||
|
|
||||||
} else if (fieldtype[i] == Y) {
|
} else if (fieldtype[i] == Y) {
|
||||||
fieldindex[i] = find_label("y", labels);
|
fieldindex[i] = find_label("y", labels);
|
||||||
@ -404,8 +346,7 @@ bigint ReaderADIOS::read_header(double box[3][3], int &boxinfo, int &triclinic,
|
|||||||
yflag = SCALE_NOWRAP;
|
yflag = SCALE_NOWRAP;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (fieldindex[i] == nwords)
|
if (fieldindex[i] == nwords) fieldindex[i] = -1;
|
||||||
fieldindex[i] = -1;
|
|
||||||
|
|
||||||
} else if (fieldtype[i] == Z) {
|
} else if (fieldtype[i] == Z) {
|
||||||
fieldindex[i] = find_label("z", labels);
|
fieldindex[i] = find_label("z", labels);
|
||||||
@ -428,8 +369,7 @@ bigint ReaderADIOS::read_header(double box[3][3], int &boxinfo, int &triclinic,
|
|||||||
zflag = SCALE_NOWRAP;
|
zflag = SCALE_NOWRAP;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (fieldindex[i] == nwords)
|
if (fieldindex[i] == nwords) fieldindex[i] = -1;
|
||||||
fieldindex[i] = -1;
|
|
||||||
|
|
||||||
} else if (fieldtype[i] == VX)
|
} else if (fieldtype[i] == VX)
|
||||||
fieldindex[i] = find_label("vx", labels);
|
fieldindex[i] = find_label("vx", labels);
|
||||||
@ -460,8 +400,7 @@ bigint ReaderADIOS::read_header(double box[3][3], int &boxinfo, int &triclinic,
|
|||||||
|
|
||||||
fieldflag = 0;
|
fieldflag = 0;
|
||||||
for (int i = 0; i < nfield; i++)
|
for (int i = 0; i < nfield; i++)
|
||||||
if (fieldindex[i] < 0)
|
if (fieldindex[i] < 0) fieldflag = -1;
|
||||||
fieldflag = -1;
|
|
||||||
|
|
||||||
return nAtoms;
|
return nAtoms;
|
||||||
}
|
}
|
||||||
@ -475,24 +414,18 @@ bigint ReaderADIOS::read_header(double box[3][3], int &boxinfo, int &triclinic,
|
|||||||
|
|
||||||
void ReaderADIOS::read_atoms(int n, int nfield, double **fields)
|
void ReaderADIOS::read_atoms(int n, int nfield, double **fields)
|
||||||
{
|
{
|
||||||
char str[1024];
|
|
||||||
|
|
||||||
/* Read Atoms */
|
/* Read Atoms */
|
||||||
/* This is the firsts (and last) read of array data, so we
|
/* This is the firsts (and last) read of array data, so we
|
||||||
* call EndStep() here instead of PerformGets()
|
* call EndStep() here instead of PerformGets()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
adios2::Variable<double> varAtoms =
|
adios2::Variable<double> varAtoms = internal->io.InquireVariable<double>("atoms");
|
||||||
internal->io.InquireVariable<double>("atoms");
|
|
||||||
|
|
||||||
if (n != nAtoms) {
|
if ((uint64_t)n != nAtoms)
|
||||||
snprintf(
|
error->one(FLERR,
|
||||||
str, sizeof(str),
|
"ReaderADIOS::read_atoms() expects 'n={}' equal to the number of "
|
||||||
"ReaderADIOS::read_atoms() expects 'n=%d' equal to the number of "
|
"atoms (={}) for process {} in ADIOS file {}.",
|
||||||
"atoms (=%" PRIu64 ") for process %d in ADIOS file %s.",
|
n, nAtoms, comm->me, internal->fh.Name());
|
||||||
n, nAtoms, comm->me, internal->fh.Name().c_str());
|
|
||||||
error->one(FLERR, str);
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t ncols = varAtoms.Count()[1];
|
size_t ncols = varAtoms.Count()[1];
|
||||||
varAtoms.SetSelection({{atomOffset, 0}, {nAtoms, ncols}});
|
varAtoms.SetSelection({{atomOffset, 0}, {nAtoms, ncols}});
|
||||||
@ -504,11 +437,9 @@ void ReaderADIOS::read_atoms(int n, int nfield, double **fields)
|
|||||||
internal->fh.EndStep();
|
internal->fh.EndStep();
|
||||||
|
|
||||||
size_t idx;
|
size_t idx;
|
||||||
for (int i = 0; i < nAtoms; i++) {
|
for (uint64_t i = 0; i < nAtoms; i++) {
|
||||||
idx = i * ncols;
|
idx = i * ncols;
|
||||||
for (int m = 0; m < nfield; m++) {
|
for (int m = 0; m < nfield; m++) { fields[i][m] = table[idx + fieldindex[m]]; }
|
||||||
fields[i][m] = table[idx + fieldindex[m]];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -517,12 +448,9 @@ void ReaderADIOS::read_atoms(int n, int nfield, double **fields)
|
|||||||
return index of match or -1 if no match
|
return index of match or -1 if no match
|
||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
int ReaderADIOS::find_label(const std::string &label,
|
int ReaderADIOS::find_label(const std::string &label, const std::map<std::string, int> &labels)
|
||||||
const std::map<std::string, int> &labels)
|
|
||||||
{
|
{
|
||||||
std::map<std::string, int>::const_iterator it = labels.find(label);
|
std::map<std::string, int>::const_iterator it = labels.find(label);
|
||||||
if (it != labels.end()) {
|
if (it != labels.end()) { return it->second; }
|
||||||
return it->second;
|
|
||||||
}
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -44,7 +44,7 @@ class ReaderADIOS : public Reader {
|
|||||||
int &, int &, int &) override;
|
int &, int &, int &) override;
|
||||||
void read_atoms(int, int, double **) override;
|
void read_atoms(int, int, double **) override;
|
||||||
|
|
||||||
void open_file(const char *) override;
|
void open_file(const std::string &) override;
|
||||||
void close_file() override;
|
void close_file() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
Reference in New Issue
Block a user