diff --git a/tests/data/summary_deck_non_constant_porosity.DATA b/tests/data/summary_deck_non_constant_porosity.DATA
new file mode 100644
index 000000000..bdf3d2248
--- /dev/null
+++ b/tests/data/summary_deck_non_constant_porosity.DATA
@@ -0,0 +1,658 @@
+-- Synthetic test deck based on Norne. This data set is meant to be a simple,
+-- well-documented deck for the behaviour of SUMMARY specified output. Data
+-- is mostly entered to *traceable* and does not necessarily make sense from
+-- a simulation point of view.
+
+START
+10 MAI 2007 /
+RUNSPEC
+
+TITLE
+SUMMARYTESTS
+
+-- A simple 10x10x10 cube. Simple to reason about, large enough for all tests
+DIMENS
+ 10 10 10 /
+
+REGDIMS
+ 3 /
+
+OIL
+GAS
+WATER
+DISGAS
+
+METRIC
+
+GRID
+
+DX
+1000*1 /
+DY
+1000*1 /
+DZ
+1000*1 /
+TOPS
+100*1 /
+
+ACTNUM
+ 1000*1/
+
+PORO
+500*0.1 500*0.2/
+
+PERMX
+ 1000*500 /
+
+REGIONS
+
+FIPNUM
+ 400*1
+ 200*2
+ 400*3 /
+
+PROPS
+
+PVTW
+ 1 1000 0 0.318 0.0 /
+
+ROCK
+ 14.7 3E-6 /
+
+SWOF
+0.12 0 1 0
+0.18 4.64876033057851E-008 1 0
+0.24 0.000000186 0.997 0
+0.3 4.18388429752066E-007 0.98 0
+0.36 7.43801652892562E-007 0.7 0
+0.42 1.16219008264463E-006 0.35 0
+0.48 1.67355371900826E-006 0.2 0
+0.54 2.27789256198347E-006 0.09 0
+0.6 2.97520661157025E-006 0.021 0
+0.66 3.7654958677686E-006 0.01 0
+0.72 4.64876033057851E-006 0.001 0
+0.78 0.000005625 0.0001 0
+0.84 6.69421487603306E-006 0 0
+0.91 8.05914256198347E-006 0 0
+1 0.00001 0 0 /
+
+
+SGOF
+0 0 1 0
+0.001 0 1 0
+0.02 0 0.997 0
+0.05 0.005 0.980 0
+0.12 0.025 0.700 0
+0.2 0.075 0.350 0
+0.25 0.125 0.200 0
+0.3 0.190 0.090 0
+0.4 0.410 0.021 0
+0.45 0.60 0.010 0
+0.5 0.72 0.001 0
+0.6 0.87 0.0001 0
+0.7 0.94 0.000 0
+0.85 0.98 0.000 0
+0.88 0.984 0.000 0 /
+
+DENSITY
+ 53.66 64.49 0.0533 /
+
+PVDG
+1 100 1
+10 10 1 /
+
+PVTO
+0 1 10 1 /
+1 1 10 1
+ 10 1 1 /
+/
+
+SUMMARY
+DATE
+PERFORMA
+--
+-- Field Data
+-- Production Rates
+FVPR
+FWPR
+FWPRH
+FOPR
+FOPRH
+FGPR
+FGPRH
+FLPR
+FLPRH
+FGSR
+FGCR
+FNPR -- solvent
+--FTPRSEA
+-- Injection Rates
+FVIR
+FWIR
+FWIRH
+FGIR
+FNIR -- solvent
+FGIRH
+-- Production Cummulatives
+FVPT
+FWPT
+FOPT
+FLPT
+FLPTH
+FGPT
+FNPT
+FOPTH
+FGPTH
+FWPTH
+FGST
+FGCT
+-- Injection Cummulatives
+FVIT
+FWIT
+FWITH
+FGIT
+FNIT
+FGITH
+-- In place
+FWIP
+FOIP
+FGIP
+-- Ratios
+FWCT
+FWCTH
+FGOR
+FGORH
+
+-- From model2
+FMWPR
+FMWIN
+FOE
+
+-- Pressures
+FPR
+FPRP
+
+BPR
+ 1 1 1 /
+ 1 1 2 /
+ 1 1 3 /
+ 1 1 4 /
+ 1 1 5 /
+ 1 1 6 /
+ 1 1 7 /
+ 1 1 8 /
+ 1 1 9 /
+ 1 1 10 /
+ 2 1 10 / -- This cell is not ACTIVE
+/
+
+BSGAS
+ 1 1 1 /
+/
+
+
+BSWAT
+ 1 1 1 /
+/
+
+
+-- Region data
+RPR
+/
+ROPT
+/
+RGPT
+/
+RWPT
+/
+RGFT
+/
+RWFT
+/
+ROIP
+/
+ROP
+/
+ROPR
+/
+RGPR
+/
+RWPR
+/
+RGIR
+/
+RGIT
+/
+RWIR
+/
+RWIT
+/
+RWPT
+/
+ROIPL
+/
+ROIPG
+/
+RGIP
+/
+RGIPL
+/
+RGIPG
+/
+RWIP
+/
+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+WWCTH
+/
+WGOR
+/
+WGORH
+/
+WGLR
+/
+WGLRH
+/
+
+
+-- Performance
+WBHP
+/
+WBHPH
+/
+WTHP
+/
+WTHPH
+/
+WPI
+/
+WBP
+/
+WBP4
+/
+
+-- from model2
+WOPTF
+/
+WOPTS
+/
+WOPTH
+/
+WOPRS
+/
+WOPRF
+/
+WGPTF
+/
+WGPTS
+/
+WGPRF
+/
+WTPRS
+/
+WGLIR
+/
+WVPR
+/
+WVPT
+/
+WOPP
+/
+WVIR
+/
+WVIT
+/
+WMCTL
+/
+
+-- Water injection per connection
+CWIR
+ * /
+/
+
+-- Gas injection on 3 1 1 (45)
+CGIR
+'W_3' 3 1 1 /
+/
+
+CWIT
+'W_3' /
+/
+
+CGIT
+* /
+/
+
+-- Production per connection
+-- Using all the different ways of specifying connections here
+-- as an informal test that we still get the data we want
+CWPR
+ 'W_1' 1 1 1 /
+/
+
+COPR
+ 'W_1' /
+ 'W_2' /
+ 'W_3' /
+/
+
+CGPR
+ '*' /
+/
+
+CNFR
+ '*' /
+/
+
+CNPT
+ '*' /
+/
+
+CNIT
+ '*' /
+/
+
+CWPT
+ 'W_1' 1 1 1 /
+/
+
+COPT
+ 'W_1' /
+/
+
+CGPT
+ 'W_1' /
+ 'W_2' /
+ 'W_3' /
+/
+
+---- Connection production rates
+----CGFR
+----'E-4AH' /
+----/
+----CWFR
+----'E-2H' /
+----/
+
+SOLUTION
+
+SWAT
+ 1000*0.2 /
+
+SGAS
+ 1000*0.0 /
+
+PRESSURE
+ 100*1.0
+ 100*2.0
+ 100*3.0
+ 100*4.0
+ 100*5.0
+ 100*6.0
+ 100*7.0
+ 100*8.0
+ 100*9.0
+ 100*10.0/
+
+RS
+ 1000*0 /
+
+
+SCHEDULE
+
+-- Three wells, two producers (so that we can form a group) and one injector
+WELSPECS
+ 'W_1' 'G_1' 1 1 3.33 'OIL' 7* /
+ 'W_2' 'G_1' 2 1 3.33 'OIL' 7* /
+ 'W_3' 'G_2' 3 1 3.92 'WATER' 7* /
+/
+
+-- Completion data.
+COMPDAT
+-- 'Well' I J K1 K2
+-- Passing 0 to I/J means they'll get the well head I/J
+ W_1 0 0 1 1 / -- Active index: 0
+ W_2 0 0 1 1 / -- Active index: 1
+ W_2 0 0 2 2 / -- Active index: 101
+ W_3 0 0 1 1 / -- Active index: 2
+/
+
+WCONHIST
+-- history rates are set so that W_1 produces 1, W_2 produces 2 etc.
+-- index.offset.
+-- organised as oil-water-gas
+ W_1 SHUT ORAT 10.1 10 10.2 /
+ W_2 SHUT ORAT 20.1 20 20.2 /
+/
+
+WCONINJH
+-- Injection historical rates (water only, as we only support pure injectors)
+ W_3 WATER STOP 30.0 /
+/
+
+TSTEP
+-- register time steps (in days). This allows us to write *two* report steps (1
+-- and 2. Without this, totals/accumulations would fail (segfault) when looking
+-- up historical rates and volumes. These volumes however don't change, i.e.
+-- every time step has the same set of values
+10 10 /
+
+-- Register a fourth well with completions later. This ensure we handle when
+-- wells are registered or activated later in a simulation
+WELSPECS
+ 'W_4' 'G_3' 1 1 3.33 'OIL' 7* /
+/
+
+COMPDAT
+ W_4 1 1 3 3 /
+/
+
+TSTEP
+10 10 /
diff --git a/tests/test_ecl_output.cpp b/tests/test_ecl_output.cpp
new file mode 100644
index 000000000..b6e65b877
--- /dev/null
+++ b/tests/test_ecl_output.cpp
@@ -0,0 +1,192 @@
+// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+// vi: set et ts=4 sw=4 sts=4:
+/*
+ This file is part of the Open Porous Media project (OPM).
+
+ OPM is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ OPM is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with OPM. If not, see .
+
+ Consult the COPYING file in the top-level source directory of this
+ module for the precise wording of the license and the list of
+ copyright holders.
+*/
+#include "config.h"
+
+#include
+#include
+#include
+
+#include
+#include
+
+#include
+
+
+#include
+#include
+#include
+#include
+
+#if HAVE_DUNE_FEM
+#include
+#else
+#include
+#endif
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#define CHECK(value, expected) \
+ { \
+ if ((value) != (expected)) \
+ std::abort(); \
+ }
+
+#define CHECK_CLOSE(value, expected, reltol) \
+ { \
+ if (std::fabs((expected) - (value)) > 1e-14 && \
+ std::fabs(((expected) - (value))/((expected) + (value))) > reltol) \
+ { \
+ std::cout << "Test failure: "; \
+ std::cout << "expected value " << expected << " is not close to value " << value << std::endl; \
+ std::abort(); \
+ } \
+ } \
+
+#define REQUIRE(cond) \
+ { \
+ if (!(cond)) \
+ std::abort(); \
+ }
+
+namespace Ewoms {
+namespace Properties {
+NEW_TYPE_TAG(TestEclOutputTypeTag, INHERITS_FROM(BlackOilModel, EclBaseProblem));
+SET_BOOL_PROP(TestEclOutputTypeTag, EnableGravity, false);
+}}
+
+static const int day = 24 * 60 * 60;
+
+template
+std::unique_ptr
+initSimulator(const char *filename)
+{
+ typedef typename GET_PROP_TYPE(TypeTag, Simulator) Simulator;
+
+ std::string filenameArg = "--ecl-deck-file-name=";
+ filenameArg += filename;
+
+ const char* argv[] = {
+ "test_equil",
+ filenameArg.c_str()
+ };
+
+ Ewoms::setupParameters_(/*argc=*/sizeof(argv)/sizeof(argv[0]), argv, /*registerParams=*/false);
+
+ return std::unique_ptr(new Simulator);
+}
+
+ERT::ert_unique_ptr< ecl_sum_type, ecl_sum_free > readsum( const std::string& base ) {
+ return ERT::ert_unique_ptr< ecl_sum_type, ecl_sum_free >(
+ ecl_sum_fread_alloc_case( base.c_str(), ":" )
+ );
+}
+
+void test_summary()
+{
+ typedef typename TTAG(TestEclOutputTypeTag) TypeTag;
+ const std::string filename = "data/summary_deck_non_constant_porosity.DATA";
+ const std::string casename = "summary_deck_non_constant_porosity";
+
+ auto simulator = initSimulator(filename.data());
+ typedef typename GET_PROP_TYPE(TypeTag, GridManager) GridManager;
+ typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar;
+ typedef Ewoms::CollectDataToIORank< GridManager > CollectDataToIORankType;
+ CollectDataToIORankType collectToIORank(simulator->gridManager());
+ Ewoms::EclOutputBlackOilModule eclOutputModule(*simulator, collectToIORank);
+
+ typedef Ewoms::EclWriter EclWriterType;
+ // create the actual ECL writer
+ std::unique_ptr eclWriter = std::unique_ptr(new EclWriterType(*simulator));
+
+ simulator->model().applyInitialSolution();
+ Opm::data::Wells dw;
+ bool substep = false;
+ Scalar totalSolverTime = 0;
+ Scalar nextstep = 0;
+ simulator->setEpisodeIndex(0);
+ eclWriter->writeOutput(dw, 0 * day, substep, totalSolverTime, nextstep);
+ simulator->setEpisodeIndex(1);
+ eclWriter->writeOutput(dw, 1 * day, substep, totalSolverTime, nextstep);
+ simulator->setEpisodeIndex(2);
+ eclWriter->writeOutput(dw, 2 * day, substep, totalSolverTime, nextstep);
+
+ auto res = readsum( casename );
+ const auto* resp = res.get();
+
+ // fpr = sum_ (p * hcpv ) / hcpv, hcpv = pv * (1 - sw)
+ const double fpr = ( (3 * 0.1 + 8 * 0.2) * 500 * (1 - 0.2) ) / ( (500*0.1 + 500*0.2) * (1 - 0.2));
+ CHECK_CLOSE( fpr, ecl_sum_get_field_var( resp, 1, "FPR" ) , 1e-5 );
+
+ // foip = sum_ (b * s * pv), rs == 0;
+ const double foip = ( (0.3 * 0.1 + 0.8 * 0.2) * 500 * (1 - 0.2) );
+ CHECK_CLOSE(foip, ecl_sum_get_field_var( resp, 1, "FOIP" ), 1e-3 );
+
+ // fgip = sum_ (b * pv * s), sg == 0;
+ const double fgip = 0.0;
+ CHECK_CLOSE(fgip, ecl_sum_get_field_var( resp, 1, "FGIP" ), 1e-3 );
+
+ // fgip = sum_ (b * pv * s),
+ const double fwip = 1.0/1000 * ( 0.1 + 0.2) * 500 * 0.2;
+ CHECK_CLOSE(fwip, ecl_sum_get_field_var( resp, 1, "FWIP" ), 1e-3 );
+
+ // region 1
+ // rpr = sum_ (p * hcpv ) / hcpv, hcpv = pv * (1 - sw)
+ const double rpr1 = ( 2.5 * 0.1 * 400 * (1 - 0.2) ) / (400*0.1 * (1 - 0.2));
+ CHECK_CLOSE( rpr1, ecl_sum_get_general_var( resp, 1, "RPR:1" ) , 1e-5 );
+ // roip = sum_ (b * s * pv) // rs == 0;
+ const double roip1 = ( 0.25 * 0.1 * 400 * (1 - 0.2) );
+ CHECK_CLOSE(roip1, ecl_sum_get_general_var( resp, 1, "ROIP:1" ), 1e-3 );
+
+
+ // region 2
+ // rpr = sum_ (p * hcpv ) / hcpv, hcpv = pv * (1 - sw)
+ const double rpr2 = ( (5 * 0.1 * 100 + 6 * 0.2 * 100) * (1 - 0.2) ) / ( (100*0.1 + 100*0.2) * (1 - 0.2));
+ CHECK_CLOSE( rpr2, ecl_sum_get_general_var( resp, 1, "RPR:2" ) , 1e-5 );
+ // roip = sum_ (b * s * pv) // rs == 0;
+ const double roip2 = ( (0.5 * 0.1 * 100 + 0.6 * 0.2 * 100) * (1 - 0.2) );
+ CHECK_CLOSE(roip2, ecl_sum_get_general_var( resp, 1, "ROIP:2" ), 1e-3 );
+}
+
+int main(int argc, char** argv)
+{
+#if HAVE_DUNE_FEM
+ Dune::Fem::MPIManager::initialize(argc, argv);
+#else
+ Dune::MPIHelper::instance(argc, argv);
+#endif
+
+ typedef TTAG(TestEclOutputTypeTag) TypeTag;
+ Ewoms::registerAllParameters_();
+ test_summary();
+
+ return 0;
+}
+
+