Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ParmParse::addfile needs Init #3440

Merged
merged 1 commit into from
Sep 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions Src/Base/AMReX_ParmParse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <list>
#include <numeric>
#include <regex>
#include <stdexcept>
#include <set>
#include <sstream>
#include <string>
Expand Down Expand Up @@ -538,6 +539,13 @@ read_file (const char* fname, std::list<ParmParse::PP_entry>& tab)
//
if ( fname != nullptr && fname[0] != 0 )
{
#ifdef AMREX_USE_MPI
if (ParallelDescriptor::Communicator() == MPI_COMM_NULL)
{
throw std::runtime_error("read_file: AMReX must be initialized");
}
#endif

Vector<char> fileCharPtr;
std::string filename = fname;
ParallelDescriptor::ReadAndBcastFile(filename, fileCharPtr);
ax3l marked this conversation as resolved.
Show resolved Hide resolved
Expand Down Expand Up @@ -1069,6 +1077,13 @@ ParmParse::prefixedName (const std::string& str) const

void
ParmParse::addfile (std::string const& filename) {
#ifdef AMREX_USE_MPI
if (ParallelDescriptor::Communicator() == MPI_COMM_NULL)
{
throw std::runtime_error("ParmParse::addfile: AMReX must be initialized");
}
#endif

auto l = std::list<std::string>{filename};
auto file = FileKeyword;
addDefn(file,
Expand Down
Loading