Skip to content

Commit

Permalink
Bug fix: Prevent collection duration from being shorter than frequency
Browse files Browse the repository at this point in the history
History/history_mod.F90
- Added error trap to make sure that the collection duration (which
  specifies when it's time to write a new file) is never shorter than
  the collection frequency (which specifies the diagnostic time interval).
  This prevents an error that can result in empty diagnostic files.
- Updated error messages to use "YYYYMMDD hhmmss" notation

CHANGELOG.md
- UPdated accordingly

Signed-off-by: Bob Yantosca <[email protected]>
  • Loading branch information
yantosca committed Nov 25, 2024
1 parent 62f3db0 commit 5c8cf07
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Added `State_Diag%Archive_SatDiagnEdgeCount` field
- Added `State_Diag%Archive_SatDiagnEdge` field
- Added routine `SatDiagn_or_SatDiagnEdge` in `History/history_utils_mod.F90`
- Added error trap in `History/history_mod.F90` to ensure that collection duration is always shorter than frequency

### Changed
- Renamed `Emiss_Carbon_Gases` to `CO2_Production` in `carbon_gases_mod.F90`
Expand Down
37 changes: 32 additions & 5 deletions History/history_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1223,10 +1223,37 @@ SUBROUTINE History_ReadCollectionData( Input_Opt, State_Chm, State_Diag, &
ENDIF

!=================================================================
! At this point we are sure that the collection has been
! defined, so we can continue to populate it with fields.
! At this point We can assume that the collection is defined,
! and that everything following are diagnostic fields.
!=================================================================

!-----------------------------------------------------------------
! ERROR CHECK: Make sure that the length of the simulation is
! not shorter than the requested "File Write" interval. This
! will prevent simulations without diagnostic output.
!-----------------------------------------------------------------
IF ( CollectionDuration(C) < CollectionFrequency(C) ) THEN

! Construct error message
ErrMsg = &
'No diagnostic output will be created for collection: "' // &
TRIM( CollectionName(C) ) // '"! Make sure that the ' // &
'collection duration setting is not shorter than the ' // &
'collection frequency setting in HISTORY.rc! For ' // &
'example, if the frequency is "00000001 000000" (1 day) ' // &
'but the duration is "00000000 010000" (1 hour), then ' // &
'this error will occur.'

! Return error
WRITE( ErrorLine, 250 ) LineNum
CALL GC_Error( ErrMsg, RC, ThisLoc, ErrorLine )
RETURN
ENDIF

!-----------------------------------------------------------------
! Continue populating the collection with fields
!-----------------------------------------------------------------

! Zero the counter of items
ItemCount = 0

Expand Down Expand Up @@ -1535,9 +1562,9 @@ SUBROUTINE History_ReadCollectionData( Input_Opt, State_Chm, State_Diag, &
'length of the simulation as specified in ' // &
'geoschem_config.yml (check the start and end dates) is ' // &
'not shorter than the frequency setting in HISTORY.rc! ' // &
'For example, if the frequency is 010000 (1 hour) but ' // &
'the simulation is set up to run for only 20 minutes, ' // &
'then this error will occur.'
'For example, if the frequency is "00000000 010000" ' // &
'(1 hour) but the simulation is set up to run for only ' // &
'20 minutes, then this error will occur.'

! Return error
WRITE( ErrorLine, 250 ) LineNum
Expand Down

0 comments on commit 5c8cf07

Please sign in to comment.