From ebf4b63aa49ebddb9d1fb119028058b8f8c56dd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A5rd=20Skaflestad?= Date: Thu, 28 Jun 2012 14:42:04 +0200 Subject: [PATCH] Use a "const" DataMap object. As a fall-out, we can no longer use std::map::operator[], because that function cannot be applied to "const" objects. Replace by .find(). --- opm/core/utility/writeECLData.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/opm/core/utility/writeECLData.cpp b/opm/core/utility/writeECLData.cpp index ef7eb1fd..9c34f0eb 100644 --- a/opm/core/utility/writeECLData.cpp +++ b/opm/core/utility/writeECLData.cpp @@ -53,7 +53,7 @@ namespace Opm void writeECLData(const UnstructuredGrid& grid, - DataMap& data, + const DataMap& data, const SimulatorTimer& simtimer, const std::string& output_dir, const std::string& base_name) { @@ -79,15 +79,21 @@ namespace Opm ecl_rst_file_start_solution( rst_file ); { - ecl_kw_type * pressure_kw = ecl_kw_wrapper( grid , "PRESSURE" , data["pressure"] , 0 , 1); - ecl_rst_file_add_kw( rst_file , pressure_kw ); - ecl_kw_free( pressure_kw ); + DataMap::const_iterator i = data.find("pressure"); + if (i != data.end()) { + ecl_kw_type * pressure_kw = ecl_kw_wrapper( grid , "PRESSURE" , i->second , 0 , 1); + ecl_rst_file_add_kw( rst_file , pressure_kw ); + ecl_kw_free( pressure_kw ); + } } { - ecl_kw_type * swat_kw = ecl_kw_wrapper( grid , "SWAT" , data["saturation"] , 0 , 2); - ecl_rst_file_add_kw( rst_file , swat_kw ); - ecl_kw_free( swat_kw ); + DataMap::const_iterator i = data.find("saturation"); + if (i != data.end()) { + 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 ); + } } ecl_rst_file_end_solution( rst_file );