diff --git a/opm/io/eclipse/ESmry.hpp b/opm/io/eclipse/ESmry.hpp index c45a68209..7c7d03366 100644 --- a/opm/io/eclipse/ESmry.hpp +++ b/opm/io/eclipse/ESmry.hpp @@ -61,7 +61,8 @@ public: bool make_esmry_file(); - time_point startdate() const { return startdat; } + time_point startdate() const { return tp_startdat; } + std::vector start_v() const { return start_vect; } const std::vector& keywordList() const; std::vector keywordList(const std::string& pattern) const; @@ -110,7 +111,8 @@ private: std::vector summaryNodes; std::unordered_map kwunits; - time_point startdat; + time_point tp_startdat; + std::vector start_vect; mutable double m_io_opening; mutable double m_io_loading; diff --git a/opm/io/eclipse/ExtESmry.hpp b/opm/io/eclipse/ExtESmry.hpp index c03223c14..b90cc4723 100644 --- a/opm/io/eclipse/ExtESmry.hpp +++ b/opm/io/eclipse/ExtESmry.hpp @@ -54,6 +54,7 @@ public: void loadData(const std::vector& stringVect); time_point startdate() const { return m_startdat; } + std::vector start_v() const { return m_start_vect; } bool hasKey(const std::string& key) const; @@ -93,6 +94,7 @@ private: std::vector m_rstep_offset; time_point m_startdat; + std::vector m_start_vect; double m_io_opening; double m_io_loading; diff --git a/src/opm/io/eclipse/ESmry.cpp b/src/opm/io/eclipse/ESmry.cpp index f3733512d..c957d6ebd 100644 --- a/src/opm/io/eclipse/ESmry.cpp +++ b/src/opm/io/eclipse/ESmry.cpp @@ -180,7 +180,8 @@ ESmry::ESmry(const std::string &filename, bool loadBaseRunData) : std::vector combindKeyList; combindKeyList.reserve(dimens[0]); - this->startdat = make_date(smspecList.back().get("STARTDAT")); + start_vect = smspecList.back().get("STARTDAT"); + this->tp_startdat = make_date(start_vect); if ( have_lgr ) { for (unsigned int i=0; i combindKeyList; combindKeyList.reserve(dimens[0]); - this->startdat = make_date(smspecList.back().get("STARTDAT")); - if (have_lgr) { for (size_t i = 0; i < keywords.size(); i++) { Opm::EclIO::lgr_info lgr { lgrs[i], {numlx[i], numly[i], numlz[i]}}; @@ -375,7 +374,6 @@ ESmry::ESmry(const std::string &filename, bool loadBaseRunData) : for (int i = 0; i < nSpecFiles; i++) arrayPos.push_back({}); - // tskille: testing std::map keyIndex; { size_t m = 0; @@ -445,8 +443,6 @@ ESmry::ESmry(const std::string &filename, bool loadBaseRunData) : int step = 0; specInd = nSpecFiles - 1; - //nVect = keywList.size(); - int index = 0; for (const auto& keyw : keywList) { if (!keyw.empty()) { @@ -1044,10 +1040,13 @@ bool ESmry::make_esmry_file() this->loadData(); { - Opm::TimeStampUTC ts( std::chrono::system_clock::to_time_t( startdat )); + std::vector start_date_vect = start_vect; - std::vector start_date_vect = {ts.day(), ts.month(), ts.year(), ts.hour(), - ts.minutes(), ts.seconds(), 0 }; + int sec = start_date_vect[5] / 1000000; + int millisec = (start_date_vect[5] % 1000000) / 1000; + + start_date_vect[5] = sec; + start_date_vect.push_back(millisec); std::vector units; units.reserve(keyword.size()); @@ -1055,6 +1054,7 @@ bool ESmry::make_esmry_file() for (auto key : keyword) units.push_back(kwunits.at(key)); + Opm::EclIO::EclOutput outFile(smryDataFile, false, std::ios::out); outFile.write("START", start_date_vect); @@ -1363,7 +1363,7 @@ std::vector ESmry::dates() const { std::vector d; for (const auto& t : this->get("TIME")) - d.push_back( this->startdat + std::chrono::duration_cast( std::chrono::duration( t * time_unit))); + d.push_back( this->tp_startdat + std::chrono::duration_cast( std::chrono::duration( t * time_unit))); return d; } diff --git a/src/opm/io/eclipse/ExtESmry.cpp b/src/opm/io/eclipse/ExtESmry.cpp index c3b9eeddb..47f4cb5b8 100644 --- a/src/opm/io/eclipse/ExtESmry.cpp +++ b/src/opm/io/eclipse/ExtESmry.cpp @@ -51,7 +51,7 @@ Opm::time_point make_date(const std::vector& datetime) { auto minute = 0; auto second = 0; - if (datetime.size() == 6) { + if (datetime.size() == 7) { hour = datetime[3]; minute = datetime[4]; auto total_usec = datetime[5]; @@ -293,15 +293,15 @@ bool ExtESmry::open_esmry(const std::filesystem::path& inputFileName, ExtSmryHea if ((arrName != "START ") or (arrType != Opm::EclIO::INTE)) OPM_THROW(std::invalid_argument, "reading start, invalid esmry file " + inputFileName.string() ); - std::vector start_vect; + try { - start_vect = Opm::EclIO::readBinaryInteArray(fileH, arr_size); + m_start_vect = Opm::EclIO::readBinaryInteArray(fileH, arr_size); } catch (const std::runtime_error& error) { return false; } - auto startdat = make_date(start_vect); + auto startdat = make_date(m_start_vect); try { Opm::EclIO::readBinaryHeader(fileH, arrName, arr_size, arrType, sizeOfElement);