#14309 Open summary case without UNSMRY data file as empty reader

A SMSPEC file without a UNSMRY data file is re-read on every request for a summary vector, since RifReaderEclipseSummary::open returns false and no reader is cached. For an ensemble with multiple realizations missing UNSMRY, this is a severe performance problem.

Guard RifReaderEclipseSummary::open so that when no ESMRY, h5 or resdata data file is present, it returns true and creates a valid but empty reader. Skip ESMRY conversion when no UNSMRY is present, and add RifEclipseSummaryTools::hasSummaryDataFiles to detect the missing data file.
This commit is contained in:
Magne Sjaastad committed 2026-06-24 15:35:07 +02:00
1 parent 1084684b3d
commit e3f7e3f1c7
5 files changed
+44 -2

No files matched your search

@@ -492,6 +492,18 @@ RiaDefines::EclipseUnitSystem RifEclipseSummaryTools::readUnitSystem( ecl_sum_ty
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RifEclipseSummaryTools::hasSummaryDataFiles( const QString& headerFileName )
{
QString foundHeaderFile;
QStringList dataFileNames;
findSummaryFiles( QDir::toNativeSeparators( headerFileName ), &foundHeaderFile, &dataFileNames );
return !dataFileNames.isEmpty();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -72,6 +72,8 @@ public:
static RifRestartFileInfo getFileInfoAndTimeSteps( const QString& headerFileName );
static bool hasSummaryDataFiles( const QString& headerFileName );
static void closeEclSum( ecl_sum_type* ecl_sum );
static ecl_sum_type* openEclSum( const QString& inHeaderFileName, bool includeRestartFiles );
static RiaDefines::EclipseUnitSystem readUnitSystem( ecl_sum_type* ecl_sum );
@@ -178,6 +178,11 @@ bool RifOpmSummaryTools::isEsmryConversionRequired( const QString& fileName )
auto candidateEsmryFileName = enhancedSummaryFilename( fileName );
auto smspecFileName = smspecSummaryFilename( fileName );
// Conversion reads the SMSPEC/UNSMRY pair. Without the UNSMRY data file there is nothing to convert.
QString unsmryFileName( smspecFileName );
unsmryFileName.replace( ".SMSPEC", ".UNSMRY" );
if ( !QFile::exists( unsmryFileName ) ) return false;
if ( !QFile::exists( candidateEsmryFileName ) && QFile::exists( smspecFileName ) )
{
return true;
@@ -23,6 +23,7 @@
#include "RiaStdStringTools.h"
#include "RifEclEclipseSummary.h"
#include "RifEclipseSummaryTools.h"
#include "RifOpmCommonSummary.h"
#ifdef USE_HDF5
@@ -90,6 +91,27 @@ bool RifReaderEclipseSummary::open( const QString& headerFileName, RiaThreadSafe
RiaPreferencesSummary* prefSummary = RiaPreferencesSummary::current();
// A realization that is still being simulated may have written only the SMSPEC header, without any
// summary data file. Some file readers (opm-common) throw when no data file is present. In this case,
// do not attempt to create a real file reader. Allow this reader to be created as a valid, but empty,
// summary reader. The query methods report empty data when no underlying reader has been created.
{
QFileInfo fi( headerFileName );
QString basenameNoExtension = fi.absolutePath() + "/" + fi.baseName();
bool hasEnhancedSummaryFile = QFile::exists( basenameNoExtension + ".ESMRY" );
bool hasHdf5File = QFile::exists( basenameNoExtension + ".h5" );
bool hasUnsmryDataFile = RifEclipseSummaryTools::hasSummaryDataFiles( headerFileName );
if ( !hasEnhancedSummaryFile && !hasHdf5File && !hasUnsmryDataFile )
{
QString txt = "No summary data file found for " + headerFileName + ". Creating an empty summary reader.";
if ( threadSafeLogger ) threadSafeLogger->info( txt );
return true;
}
}
if ( prefSummary->summaryDataReader() == RiaPreferencesSummary::SummaryReaderMode::HDF5_OPM_COMMON ||
prefSummary->summaryDataReader() == RiaPreferencesSummary::SummaryReaderMode::OPM_COMMON )
{