From a2883e505732f1e6d43ca710d01c8e1fe7877e45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A5rd=20Skaflestad?= Date: Sun, 15 Oct 2017 20:55:08 -0500 Subject: [PATCH] Table Output: Switch to One-Based Offset Indices This is needed for compatibility with Fortran and external software that reads the .INIT file. --- src/opm/output/eclipse/Tables.cpp | 2 +- tests/test_Tables.cpp | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/opm/output/eclipse/Tables.cpp b/src/opm/output/eclipse/Tables.cpp index d4ea28426..5068b76d8 100644 --- a/src/opm/output/eclipse/Tables.cpp +++ b/src/opm/output/eclipse/Tables.cpp @@ -35,7 +35,7 @@ namespace Opm { void Tables::addData( size_t offset_index, const std::vector& new_data) { - this->tabdims[ offset_index ] = this->data.size(); + this->tabdims[ offset_index ] = this->data.size() + 1; this->data.insert( this->data.end() , new_data.begin() , new_data.end()); this->tabdims[ TABDIMS_TAB_SIZE_ITEM ] = this->data.size(); } diff --git a/tests/test_Tables.cpp b/tests/test_Tables.cpp index cd6bad071..90588126e 100644 --- a/tests/test_Tables.cpp +++ b/tests/test_Tables.cpp @@ -90,8 +90,8 @@ BOOST_AUTO_TEST_CASE(Test_PVTX) { BOOST_CHECK_EQUAL( ecl_kw_get_size( tab ) , ecl_kw_iget_int( tabdims , TABDIMS_TAB_SIZE_ITEM )); /* PVTO */ { - int offset = ecl_kw_iget_int( tabdims , TABDIMS_IBPVTO_OFFSET_ITEM ); - int rs_offset = ecl_kw_iget_int( tabdims , TABDIMS_JBPVTO_OFFSET_ITEM ); + int offset = ecl_kw_iget_int( tabdims , TABDIMS_IBPVTO_OFFSET_ITEM ) - 1; + int rs_offset = ecl_kw_iget_int( tabdims , TABDIMS_JBPVTO_OFFSET_ITEM ) - 1; int column_stride = ecl_kw_iget_int( tabdims , TABDIMS_NRPVTO_ITEM ) * ecl_kw_iget_int( tabdims , TABDIMS_NPPVTO_ITEM ) * ecl_kw_iget_int( tabdims , TABDIMS_NTPVTO_ITEM ); BOOST_CHECK_EQUAL( 2, ecl_kw_iget_int( tabdims , TABDIMS_NRPVTO_ITEM ) ); @@ -113,8 +113,8 @@ BOOST_AUTO_TEST_CASE(Test_PVTX) { /* PVTG */ { - int offset = ecl_kw_iget_int( tabdims , TABDIMS_IBPVTG_OFFSET_ITEM ); - int pg_offset = ecl_kw_iget_int( tabdims , TABDIMS_JBPVTG_OFFSET_ITEM ); + int offset = ecl_kw_iget_int( tabdims , TABDIMS_IBPVTG_OFFSET_ITEM ) - 1; + int pg_offset = ecl_kw_iget_int( tabdims , TABDIMS_JBPVTG_OFFSET_ITEM ) - 1; int column_stride = ecl_kw_iget_int( tabdims , TABDIMS_NRPVTG_ITEM ) * ecl_kw_iget_int( tabdims , TABDIMS_NPPVTG_ITEM ) * ecl_kw_iget_int( tabdims , TABDIMS_NTPVTG_ITEM ); BOOST_CHECK_EQUAL( 2, ecl_kw_iget_int( tabdims , TABDIMS_NRPVTG_ITEM ) ); @@ -132,7 +132,7 @@ BOOST_AUTO_TEST_CASE(Test_PVTX) { /* PVTW */ { - int offset = ecl_kw_iget_int( tabdims , TABDIMS_IBPVTW_OFFSET_ITEM ); + int offset = ecl_kw_iget_int( tabdims , TABDIMS_IBPVTW_OFFSET_ITEM ) - 1; int column_stride = ecl_kw_iget_int( tabdims , TABDIMS_NTPVTW_ITEM ); BOOST_CHECK( ecl_kw_get_size( tab ) >= (offset + column_stride * 5 )); @@ -150,7 +150,7 @@ BOOST_AUTO_TEST_CASE(Test_PVTX) { // Density { - int offset = ecl_kw_iget_int( tabdims , TABDIMS_IBDENS_OFFSET_ITEM ); + int offset = ecl_kw_iget_int( tabdims , TABDIMS_IBDENS_OFFSET_ITEM ) - 1; int column_stride = ecl_kw_iget_int( tabdims , TABDIMS_NTDENS_ITEM ); BOOST_CHECK( ecl_kw_get_size( tab ) >= (offset + column_stride * 3 )); BOOST_CHECK_CLOSE( 859.5 , ecl_kw_iget_double( tab , offset ) , 1e-6 );