@@ -602,7 +602,8 @@ def flush(self):
602602 pass
603603
604604
605- def update_time_bounds_from_file_names (config , section , componentName ):
605+ def update_time_bounds_from_file_names (config , section , componentName ,
606+ allow_cache = True ):
606607 """
607608 Update the start and end years and dates for time series, climatologies or
608609 climate indices based on the years actually available in the list of files.
@@ -680,12 +681,16 @@ def update_time_bounds_from_file_names(config, section, componentName):
680681 endYear = years [lastIndex ]
681682
682683 if startYear != requestedStartYear or endYear != requestedEndYear :
683- print ("Warning:"
684- "{} start and/or end year different from requested\n "
685- "requested: {:04d}-{:04d}\n "
686- "actual: {:04d}-{:04d}\n " .format (
687- section , requestedStartYear , requestedEndYear , startYear ,
688- endYear ))
684+ message = ("{} start and/or end year different from requested\n "
685+ "requested: {:04d}-{:04d}\n "
686+ "actual: {:04d}-{:04d}\n " .format (
687+ section , requestedStartYear , requestedEndYear , startYear ,
688+ endYear )
689+ )
690+ if allow_cache :
691+ print (f'Warning: { message } ' )
692+ else :
693+ raise ValueError (message )
689694
690695 startDate = '{:04d}-01-01_00:00:00' .format (startYear )
691696 config .set (section , 'startDate' , startDate )
0 commit comments