diff --git a/opm/core/utility/writeECLData.cpp b/opm/core/utility/writeECLData.cpp index 5e9d4205..6baadb2a 100644 --- a/opm/core/utility/writeECLData.cpp +++ b/opm/core/utility/writeECLData.cpp @@ -18,21 +18,25 @@ along with OPM. If not, see . */ - +#if HAVE_CONFIG_H +#include "config.h" +#endif #include #include #include #include +#include #include +#ifdef HAVE_ERT // This one goes almost to the bottom of the file + #include #include #include - namespace Opm { @@ -41,8 +45,12 @@ namespace Opm const std::vector * data , int offset , int stride ) { - - ecl_kw_type * ecl_kw = ecl_kw_alloc( kw_name.c_str() , data->size() / stride , ECL_FLOAT_TYPE ); + const int ecl_data_size = grid.cartdims[0]*grid.cartdims[1]*grid.cartdims[2]; + if (ecl_data_size < int(data->size()) / stride) { + THROW("Logical cartesian size claimed to be " << ecl_data_size << ", while active data size is " << data->size() + << "\n --- check if the grid is really a corner-point grid or other logical cartesian grid."); + } + ecl_kw_type * ecl_kw = ecl_kw_alloc( kw_name.c_str() , ecl_data_size , ECL_FLOAT_TYPE ); if (grid.global_cell == NULL) { for (int i=0; i < grid.number_of_cells; i++) ecl_kw_iset_float( ecl_kw , i , (*data)[i*stride + offset]); @@ -94,6 +102,9 @@ namespace Opm { DataMap::const_iterator i = data.find("saturation"); if (i != data.end()) { + if (int(i->second->size()) != 2 * grid.number_of_cells) { + THROW("writeECLData() requires saturation field to have two phases."); + } ecl_kw_type * swat_kw = ecl_kw_wrapper( grid , "SWAT" , i->second , 0 , 2); ecl_rst_file_add_kw( rst_file , swat_kw ); ecl_kw_free( swat_kw ); @@ -106,3 +117,18 @@ namespace Opm } } +#else // that is, we have not defined HAVE_ERT + +namespace Opm +{ + void writeECLData(const UnstructuredGrid&, + const DataMap&, + const SimulatorTimer&, + const std::string&, + const std::string&) + { + THROW("Cannot call writeECLData() without ert library support. Reconfigure opm-core with --with-ert and recompile."); + } +} + +#endif