#5847 Eclipse Ascii Case: Import of properties with comment in header fails

This commit is contained in:
Magne Sjaastad 2020-04-27 09:42:15 +02:00
parent 4d98a8d502
commit 5de98ea7b0

View File

@ -846,24 +846,50 @@ bool RifEclipseInputFileTools::readProperty( const QString& fileName,
return false;
}
ecl_kw_type* eclipseKeywordData = ecl_kw_fscanf_alloc_grdecl_dynamic__( filePointer,
eclipseKeyWord.toLatin1().data(),
false,
ecl_type_create_from_type( ECL_FLOAT_TYPE ) );
bool isOk = false;
if ( eclipseKeywordData )
qint64 filePos = -1;
{
QString errMsg;
isOk = readDataFromKeyword( eclipseKeywordData, caseData, resultName, &errMsg );
if ( !isOk )
std::vector<RifKeywordAndFilePos> keywordsAndFilePos;
findKeywordsOnFile( fileName, &keywordsAndFilePos );
for ( auto kwAndPos : keywordsAndFilePos )
{
RiaLogging::error( QString( "Failed to read property: %1" ).arg( errMsg ) );
if ( kwAndPos.keyword == eclipseKeyWord )
{
filePos = kwAndPos.filePos;
}
}
ecl_kw_free( eclipseKeywordData );
}
bool isOk = false;
if ( filePos == -1 )
{
RiaLogging::error( QString( "Failed to load keyword %1 from file: %2" ).arg( eclipseKeyWord ).arg( fileName ) );
}
else
{
RiaLogging::error( QString( "Failed to load keyword %1 from file: %2" ).arg( eclipseKeyWord ).arg( fileName ) );
fseek( filePointer, filePos, SEEK_SET );
ecl_kw_type* eclipseKeywordData =
ecl_kw_fscanf_alloc_grdecl_dynamic__( filePointer,
eclipseKeyWord.toLatin1().data(),
false,
ecl_type_create_from_type( ECL_FLOAT_TYPE ) );
if ( eclipseKeywordData )
{
QString errMsg;
isOk = readDataFromKeyword( eclipseKeywordData, caseData, resultName, &errMsg );
if ( !isOk )
{
RiaLogging::error( QString( "Failed to read property: %1" ).arg( errMsg ) );
}
ecl_kw_free( eclipseKeywordData );
}
else
{
RiaLogging::error( QString( "Failed to load keyword %1 from file: %2" ).arg( eclipseKeyWord ).arg( fileName ) );
}
}
fclose( filePointer );