Skip to content

Commit

Permalink
Allow EXP to run without an 'External' config stanza
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin D. Weinberg committed Oct 14, 2023
1 parent 24400e2 commit db54897
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 3 deletions.
6 changes: 6 additions & 0 deletions src/ExternalCollection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ void ExternalCollection::initialize()

dynamicload();

if (not parse["External"]) {
if (myid==0)
std::cout << "---- ExternalCollection: "
<< "no entries found. Continuing ..." << std::endl;
}

YAML::Node ext;

try {
Expand Down
37 changes: 34 additions & 3 deletions utils/Test/test_config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,18 @@ class EXPparser

void EXPparser::exp_check(const YAML::Node& root)
{
// All EXP stanzas
const std::vector<std::string> stanzas
{
"Global", "Components", "Output", "External", "Interaction"
};

// Optional EXP stanzas
const std::vector<std::string> optional
{
"External", "Interaction"
};

std::vector<std::string> unexpected, remain(stanzas), duplicates;

for (YAML::const_iterator it=root.begin(); it!=root.end(); it++) {
Expand All @@ -61,10 +68,34 @@ void EXPparser::exp_check(const YAML::Node& root)

std::ostringstream sout;

// Check EXP stanzas not found
if (remain.size()) {
sout << "The following stanzas were not found:";
for (auto s : remain) sout << " " << s;
throw std::runtime_error(sout.str());

// Find and remove optional stanzas
std::vector<std::string> opt;
for (auto s : optional) {
auto it = std::find(remain.begin(), remain.end(), s);
if (it != remain.end()) {
opt.push_back(s);
remain.erase(it);
}
}

// Print info message for optional stanzas
if (opt.size()) {
if (ostr.rdbuf() == std::cout.rdbuf())
std::cout << std::string(70, '=') << std::endl;

std::cout << "The following optional stanzas were not found:";
for (auto s : opt) std::cout << " " << s;
std::cout << std::endl;
}

if (remain.size()) {
sout << "The following required stanzas were not found:";
for (auto s : remain) sout << " " << s;
throw std::runtime_error(sout.str());
}
}

if (unexpected.size()) {
Expand Down

0 comments on commit db54897

Please sign in to comment.