changed: log keyword location when parsing a table failed

This commit is contained in:
Arne Morten Kvarving 2022-06-13 12:13:50 +02:00
parent 3af1d464eb
commit 050540525f
2 changed files with 16 additions and 5 deletions

View File

@ -23,6 +23,8 @@
#include <opm/input/eclipse/EclipseState/Tables/TableSchema.hpp>
#include <opm/input/eclipse/Deck/DeckItem.hpp>
#include <fmt/format.h>
namespace Opm {
SimpleTable::SimpleTable( TableSchema schema, const DeckItem& deckItem) :
@ -85,9 +87,14 @@ namespace Opm {
void SimpleTable::init( const DeckItem& deckItem, double scaling_factor) {
this->addColumns();
if ( (deckItem.data_size() % numColumns()) != 0)
throw std::runtime_error("Number of columns in the data file is"
"inconsistent with the ones specified");
if ( (deckItem.data_size() % numColumns()) != 0) {
throw std::runtime_error {
fmt::format("Number of input table elements ({}) is "
"not a multiple of table's specified number "
"of columns ({})",
deckItem.data_size(), this->numColumns())
};
}
size_t rows = deckItem.data_size() / numColumns();
for (size_t colIdx = 0; colIdx < numColumns(); ++colIdx) {

View File

@ -1562,8 +1562,12 @@ DensityTable make_density_table(const GravityTable& gravity) {
for (size_t tableIdx = 0; tableIdx < tableKeyword.size(); ++tableIdx) {
const auto& dataItem = tableKeyword.getRecord( tableIdx ).getItem("DATA");
if (dataItem.data_size() > 0) {
try {
std::shared_ptr<TableType> table = std::make_shared<TableType>( dataItem, useJFunc() );
container.addTable( tableIdx , table );
} catch (const std::runtime_error& err) {
throw OpmInputError(err, tableKeyword.location());
}
}
}
}