From 5c8cf07541eba2b693e72156adf3da9d265c3877 Mon Sep 17 00:00:00 2001 From: Bob Yantosca Date: Mon, 25 Nov 2024 11:41:27 -0500 Subject: [PATCH] Bug fix: Prevent collection duration from being shorter than frequency 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 --- CHANGELOG.md | 1 + History/history_mod.F90 | 37 ++++++++++++++++++++++++++++++++----- 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b046068ce..9c9ea9096 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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` diff --git a/History/history_mod.F90 b/History/history_mod.F90 index 7f11d419b..782dbfb0c 100644 --- a/History/history_mod.F90 +++ b/History/history_mod.F90 @@ -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 @@ -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