mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Improve exception handling in ParallelEclipseState::get_global-*
In particular we make sure that all processes throw on unknown keywords.
This commit is contained in:
parent
5c8cdc8024
commit
f4876becfb
@ -74,8 +74,26 @@ const std::vector<int>& ParallelFieldPropsManager::get_int(const std::string& ke
|
|||||||
std::vector<int> ParallelFieldPropsManager::get_global_int(const std::string& keyword) const
|
std::vector<int> ParallelFieldPropsManager::get_global_int(const std::string& keyword) const
|
||||||
{
|
{
|
||||||
std::vector<int> result;
|
std::vector<int> result;
|
||||||
|
int exceptionThrown{};
|
||||||
|
|
||||||
if (m_comm.rank() == 0)
|
if (m_comm.rank() == 0)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
result = m_manager.get_global_int(keyword);
|
result = m_manager.get_global_int(keyword);
|
||||||
|
}catch(std::exception& e) {
|
||||||
|
exceptionThrown = 1;
|
||||||
|
OpmLog::error("No integer property field: " + keyword + " ("+e.what()+")");
|
||||||
|
m_comm.broadcast(&exceptionThrown, 1, 0);
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_comm.broadcast(&exceptionThrown, 1, 0);
|
||||||
|
|
||||||
|
if (exceptionThrown)
|
||||||
|
OPM_THROW_NOLOG(std::runtime_error, "No integer property field: " + keyword);
|
||||||
|
|
||||||
size_t size = result.size();
|
size_t size = result.size();
|
||||||
m_comm.broadcast(&size, 1, 0);
|
m_comm.broadcast(&size, 1, 0);
|
||||||
result.resize(size);
|
result.resize(size);
|
||||||
@ -98,8 +116,26 @@ const std::vector<double>& ParallelFieldPropsManager::get_double(const std::stri
|
|||||||
std::vector<double> ParallelFieldPropsManager::get_global_double(const std::string& keyword) const
|
std::vector<double> ParallelFieldPropsManager::get_global_double(const std::string& keyword) const
|
||||||
{
|
{
|
||||||
std::vector<double> result;
|
std::vector<double> result;
|
||||||
|
int exceptionThrown{};
|
||||||
|
|
||||||
if (m_comm.rank() == 0)
|
if (m_comm.rank() == 0)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
result = m_manager.get_global_double(keyword);
|
result = m_manager.get_global_double(keyword);
|
||||||
|
}catch(std::exception& e) {
|
||||||
|
exceptionThrown = 1;
|
||||||
|
OpmLog::error("No double property field: " + keyword + " ("+e.what()+")");
|
||||||
|
m_comm.broadcast(&exceptionThrown, 1, 0);
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_comm.broadcast(&exceptionThrown, 1, 0);
|
||||||
|
|
||||||
|
if (exceptionThrown)
|
||||||
|
OPM_THROW_NOLOG(std::runtime_error, "No double property field: " + keyword);
|
||||||
|
|
||||||
size_t size = result.size();
|
size_t size = result.size();
|
||||||
m_comm.broadcast(&size, 1, 0);
|
m_comm.broadcast(&size, 1, 0);
|
||||||
result.resize(size);
|
result.resize(size);
|
||||||
|
Loading…
Reference in New Issue
Block a user