#14829: Emit insert-date event comment above DATES keyword

Fixes #14829.
This commit is contained in:
Kristian Bendiksen committed 2026-10-02 12:36:54 +02:00
1 parent b6704429cd
commit 3046c7e09d
2 files changed
+16 -13

No files matched your search

@@ -278,6 +278,18 @@ std::expected<QString, QString> RicScheduleDataGenerator::generateDateSection( c
auto serializeKeyword = [&]( const Opm::DeckKeyword& kw )
{ return alignColumns ? RimKeywordFactory::deckKeywordToAlignedString( kw ) : RimKeywordFactory::deckKeywordToString( kw ); };
// Comments from insert-date events describe the date itself, and are emitted directly above it.
for ( const auto* event : events )
{
if ( event->eventType() != RimWellEvent::EventType::INSERT_DATE ) continue;
if ( event->comment().isEmpty() ) continue;
for ( QString line : event->comment().split( '\n' ) )
{
line.remove( '\r' );
result += line.isEmpty() ? "--\n" : QString( "-- %1\n" ).arg( line );
}
}
// Generate DATES keyword, or a date comment when requested (e.g. for the first date, which
// equals the simulation start date and is rejected as a DATES entry by some simulators).
if ( dateAsComment )
@@ -300,18 +312,6 @@ std::expected<QString, QString> RicScheduleDataGenerator::generateDateSection( c
result += serializeKeyword( RimKeywordFactory::datesKeyword( date ) ) + "\n";
}
// Comments from insert-date events describe the date itself, and are emitted directly below it.
for ( const auto* event : events )
{
if ( event->eventType() != RimWellEvent::EventType::INSERT_DATE ) continue;
if ( event->comment().isEmpty() ) continue;
for ( QString line : event->comment().split( '\n' ) )
{
line.remove( '\r' );
result += line.isEmpty() ? "--\n" : QString( "-- %1\n" ).arg( line );
}
}
appendRawText( RimWellEventRawText::Placement::AFTER_DATE );
// Records for each keyword name are accumulated across wells, then serialised once below.
@@ -488,8 +488,11 @@ class TestScheduleGeneration:
"Inserted date 2024-06-01 should be emitted as a DATES entry"
)
assert "-- Mid-year summary report" in schedule_text, (
"The comment of an insert-date event should be emitted below its date"
"The comment of an insert-date event should be emitted above its date"
)
assert schedule_text.index("-- Mid-year summary report") < schedule_text.index(
"1 'JUN' 2024"
), "The comment must precede the DATES keyword of its insert-date event"
# Dates must appear in chronological order: JAN (event), FEB, MAR (event), JUN
positions = [
schedule_text.index(date_str)