add support for building/using the ADIOS package without MPI
This needs the ADIOS2 installation being configured accordingly.
This commit is contained in:
@ -316,6 +316,15 @@ if(PKG_ADIOS)
|
||||
# script that defines the MPI::MPI_C target
|
||||
enable_language(C)
|
||||
find_package(ADIOS2 REQUIRED)
|
||||
if(BUILD_MPI)
|
||||
if(NOT ADIOS2_HAVE_MPI)
|
||||
message(FATAL_ERROR "ADIOS2 must be built with MPI support when LAMMPS has MPI enabled")
|
||||
endif()
|
||||
else()
|
||||
if(ADIOS2_HAVE_MPI)
|
||||
message(FATAL_ERROR "ADIOS2 must be built without MPI support when LAMMPS has MPI disabled")
|
||||
endif()
|
||||
endif()
|
||||
target_link_libraries(lammps PRIVATE adios2::adios2)
|
||||
endif()
|
||||
|
||||
|
||||
@ -62,7 +62,11 @@ DumpAtomADIOS::DumpAtomADIOS(LAMMPS *lmp, int narg, char **arg) : DumpAtom(lmp,
|
||||
|
||||
internal = new DumpAtomADIOSInternal();
|
||||
try {
|
||||
#if defined(MPI_STUBS)
|
||||
internal->ad = new adios2::ADIOS("adios2_config.xml", adios2::DebugON);
|
||||
#else
|
||||
internal->ad = new adios2::ADIOS("adios2_config.xml", world, adios2::DebugON);
|
||||
#endif
|
||||
} catch (std::ios_base::failure &e) {
|
||||
error->all(FLERR, "ADIOS initialization failed with error: {}", e.what());
|
||||
}
|
||||
@ -84,11 +88,19 @@ void DumpAtomADIOS::openfile()
|
||||
if (multifile) {
|
||||
// if one file per timestep, replace '*' with current timestep
|
||||
auto filecurrent = utils::star_subst(filename, update->ntimestep, padflag);
|
||||
#if defined(MPI_STUBS)
|
||||
internal->fh = internal->io.Open(filecurrent, adios2::Mode::Write);
|
||||
#else
|
||||
internal->fh = internal->io.Open(filecurrent, adios2::Mode::Write, world);
|
||||
#endif
|
||||
if (!internal->fh) error->one(FLERR, "Cannot open dump file {}", filecurrent);
|
||||
} else {
|
||||
if (!singlefile_opened) {
|
||||
#if defined(MPI_STUBS)
|
||||
internal->fh = internal->io.Open(filename, adios2::Mode::Write);
|
||||
#else
|
||||
internal->fh = internal->io.Open(filename, adios2::Mode::Write, world);
|
||||
#endif
|
||||
if (!internal->fh) error->one(FLERR, "Cannot open dump file {}", filename);
|
||||
singlefile_opened = 1;
|
||||
}
|
||||
|
||||
@ -70,7 +70,11 @@ DumpCustomADIOS::DumpCustomADIOS(LAMMPS *lmp, int narg, char **arg) : DumpCustom
|
||||
|
||||
internal = new DumpCustomADIOSInternal();
|
||||
try {
|
||||
#if defined(MPI_STUBS)
|
||||
internal->ad = new adios2::ADIOS("adios2_config.xml", adios2::DebugON);
|
||||
#else
|
||||
internal->ad = new adios2::ADIOS("adios2_config.xml", world, adios2::DebugON);
|
||||
#endif
|
||||
} catch (std::ios_base::failure &e) {
|
||||
error->all(FLERR, "ADIOS initialization failed with error: {}", e.what());
|
||||
}
|
||||
@ -96,11 +100,19 @@ void DumpCustomADIOS::openfile()
|
||||
if (multifile) {
|
||||
// if one file per timestep, replace '*' with current timestep
|
||||
auto filecurrent = utils::star_subst(filename, update->ntimestep, padflag);
|
||||
#if defined(MPI_STUBS)
|
||||
internal->fh = internal->io.Open(filecurrent, adios2::Mode::Write);
|
||||
#else
|
||||
internal->fh = internal->io.Open(filecurrent, adios2::Mode::Write, world);
|
||||
#endif
|
||||
if (!internal->fh) error->one(FLERR, "Cannot open dump file {}", filecurrent);
|
||||
} else {
|
||||
if (!singlefile_opened) {
|
||||
#if defined(MPI_STUBS)
|
||||
internal->fh = internal->io.Open(filename, adios2::Mode::Write);
|
||||
#else
|
||||
internal->fh = internal->io.Open(filename, adios2::Mode::Write, world);
|
||||
#endif
|
||||
if (!internal->fh) error->one(FLERR, "Cannot open dump file {}", filename);
|
||||
singlefile_opened = 1;
|
||||
}
|
||||
|
||||
@ -82,7 +82,11 @@ ReaderADIOS::ReaderADIOS(LAMMPS *lmp) : Reader(lmp)
|
||||
|
||||
internal = new ReadADIOSInternal();
|
||||
try {
|
||||
#if defined(MPI_STUBS)
|
||||
internal->ad = new adios2::ADIOS("adios2_config.xml", adios2::DebugON);
|
||||
#else
|
||||
internal->ad = new adios2::ADIOS("adios2_config.xml", world, adios2::DebugON);
|
||||
#endif
|
||||
} catch (std::ios_base::failure &e) {
|
||||
error->one(FLERR, "ADIOS initialization failed with error: {}", e.what());
|
||||
}
|
||||
@ -134,7 +138,11 @@ void ReaderADIOS::open_file(const std::string &file)
|
||||
if (internal->fh) internal->fh.Close();
|
||||
|
||||
try {
|
||||
#if defined(MPI_STUBS)
|
||||
internal->fh = internal->io.Open(file, adios2::Mode::Read);
|
||||
#else
|
||||
internal->fh = internal->io.Open(file, adios2::Mode::Read, world);
|
||||
#endif
|
||||
} catch (std::ios_base::failure &e) {
|
||||
error->one(FLERR, "Error opening file {}: {}", file, e.what());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user