From c50e7cdd51c8464d222e6e945550b67287eb4a2a Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 13 Apr 2021 09:26:58 +0200 Subject: [PATCH] Summary HDF : Make sure all summary data is loaded before export to HDF --- .../FileInterface/RifHdf5SummaryExporter.cpp | 8 ++++++++ ApplicationLibCode/UnitTests/HDF5FileWriter-Test.cpp | 4 +--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/ApplicationLibCode/FileInterface/RifHdf5SummaryExporter.cpp b/ApplicationLibCode/FileInterface/RifHdf5SummaryExporter.cpp index 663b62fa69..a5871f068e 100644 --- a/ApplicationLibCode/FileInterface/RifHdf5SummaryExporter.cpp +++ b/ApplicationLibCode/FileInterface/RifHdf5SummaryExporter.cpp @@ -41,6 +41,10 @@ bool RifHdf5SummaryExporter::ensureHdf5FileIsCreated( const std::string& smspecF { Opm::EclIO::ESmry sourceSummaryData( smspecFileName ); + // Read all data summary data before starting export to HDF. Loading one and one summary vector causes huge + // performance penalty + sourceSummaryData.LoadData(); + RifHdf5Exporter exporter( h5FileName ); writeGeneralSection( exporter, sourceSummaryData ); @@ -155,7 +159,11 @@ bool RifHdf5SummaryExporter::writeSummaryVectors( RifHdf5Exporter& exporter, Opm const std::vector& values = sourceSummaryData.get( summaryNode ); exporter.writeDataset( dataValuesGroup, datasetName, values ); + + dataValuesGroup.close(); } + + keywordGroup.close(); } return true; diff --git a/ApplicationLibCode/UnitTests/HDF5FileWriter-Test.cpp b/ApplicationLibCode/UnitTests/HDF5FileWriter-Test.cpp index 6bdcb2b1f0..e2b478bedf 100644 --- a/ApplicationLibCode/UnitTests/HDF5FileWriter-Test.cpp +++ b/ApplicationLibCode/UnitTests/HDF5FileWriter-Test.cpp @@ -25,12 +25,10 @@ TEST( DISABLED_HDFTests, WriteToHdf5SummaryExporter ) { QString file_path = H5_TEST_DATA_DIRECTORY_2 + "NORNE_ATW2013_RFTPLT_V2.SMSPEC"; - Opm::EclIO::ESmry esmry( file_path.toStdString() ); - RifHdf5SummaryExporter exporter; std::string exportFileName = "e:/project/scratch_export/hdf_complete.h5"; - exporter.ensureHdf5FileIsCreated( exportFileName, exportFileName ); + exporter.ensureHdf5FileIsCreated( file_path.toStdString(), exportFileName ); } //--------------------------------------------------------------------------------------------------