diff --git a/CHANGELOG.md b/CHANGELOG.md index d3e9fd54bac2..6b956e0c7a20 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Deprecated +## [2.39.4] - 2023-06-23 + +### Fixed + +- Added bug fix when using climatology option in ExtData2G under certain scenarios + ## [2.39.3] - 2023-06-12 ### Fixed diff --git a/CMakeLists.txt b/CMakeLists.txt index d796c3a52b95..3481b0063d0d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,7 +8,7 @@ endif () project ( MAPL - VERSION 2.39.3 + VERSION 2.39.4 LANGUAGES Fortran CXX C) # Note - CXX is required for ESMF # Set the possible values of build type for cmake-gui diff --git a/gridcomps/ExtData2G/ExtDataClimFileHandler.F90 b/gridcomps/ExtData2G/ExtDataClimFileHandler.F90 index d6121adade33..86f3c6c629bb 100644 --- a/gridcomps/ExtData2G/ExtDataClimFileHandler.F90 +++ b/gridcomps/ExtData2G/ExtDataClimFileHandler.F90 @@ -13,6 +13,7 @@ module MAPL_ExtdataClimFileHandler use MAPL_StringTemplate use MAPL_ExtDataBracket use MAPL_ExtDataConstants + use MAPL_CommsMod implicit none private public ExtDataClimFileHandler @@ -44,9 +45,9 @@ subroutine get_file_bracket(this, input_time, source_time, bracket, fail_on_miss integer :: target_year, original_year,clim_shift,valid_years(2) integer, allocatable :: source_years(:) - - - _ASSERT(fail_on_missing_file,"Failure on missing file not allowed when rule is climatology") + + + _ASSERT(fail_on_missing_file,"Failure on missing file not allowed when rule is climatology") if (bracket%time_in_bracket(input_time)) then _RETURN(_SUCCESS) end if @@ -59,10 +60,10 @@ subroutine get_file_bracket(this, input_time, source_time, bracket, fail_on_miss allocate(source_years(2)) call ESMF_TimeGet(source_time(1),yy=source_years(1),_RC) call ESMF_TimeGet(source_time(2),yy=source_years(2),_RC) - _ASSERT(source_years(1) >= valid_years(1),'source time outide valid range') - _ASSERT(source_years(1) <= valid_years(2),'source time outide valid range') - _ASSERT(source_years(2) >= valid_years(1),'source time outide valid range') - _ASSERT(source_years(2) <= valid_years(2),'source time outide valid range') + _ASSERT(source_time(1) >= this%valid_range(1),'source time outside valid range') + _ASSERT(source_time(1) <= this%valid_range(2),'source time outside valid range') + _ASSERT(source_time(2) >= this%valid_range(1),'source time outside valid range') + _ASSERT(source_time(2) <= this%valid_range(2),'source time outside valid range') end if ! shift target year to request source time if specified @@ -72,31 +73,31 @@ subroutine get_file_bracket(this, input_time, source_time, bracket, fail_on_miss !if (size(source_years)>0) then if (allocated(source_years)) then - if (target_year < source_years(1)) then + if (input_time < source_time(1)) then target_year = source_years(1) - this%clim_year = target_year - else if (target_year >= source_years(2)) then + this%clim_year = target_year + else if (input_time >= source_time(2)) then target_year = source_years(2) - this%clim_year = target_year + this%clim_year = target_year end if call swap_year(target_time,target_year,_RC) else - if (target_year < valid_years(1)) then + if (input_time <= this%valid_range(1)) then target_year = valid_years(1) this%clim_year = target_year call swap_year(target_time,target_year,_RC) - else if (target_year >= valid_years(2)) then + else if (input_time >= this%valid_range(2)) then target_year = valid_years(2) this%clim_year = target_year call swap_year(target_time,target_year,_RC) - end if + end if end if clim_target_time = target_time ! the target time is contained in the dataset and we are not extrapolating outside of source time selection based on available data if (this%clim_year == CLIM_NULL) then - call ESMF_TimeIntervalSet(zero,_RC) + call ESMF_TimeIntervalSet(zero,_RC) if (this%frequency == zero) then current_file = this%file_template call this%get_time_on_file(current_file,input_time,'L',time_index,time,_RC) @@ -140,12 +141,12 @@ subroutine get_file_bracket(this, input_time, source_time, bracket, fail_on_miss bracket%new_file_right=.true. end if - ! the target time has been specified to be a climatology for the year; either we + ! the target time has been specified to be a climatology for the year; either we ! are outside the dataset or we have requested a source time range and are on ! or outside either end else - call ESMF_TimeIntervalSet(zero,_RC) + call ESMF_TimeIntervalSet(zero,_RC) if (this%frequency == zero) then current_file = this%file_template clim_shift=0 @@ -178,9 +179,9 @@ subroutine get_file_bracket(this, input_time, source_time, bracket, fail_on_miss call ESMF_TimeGet(target_time,yy=target_year,_RC) if (target_year > this%clim_year) then call swap_year(time,original_year-1,_RC) - else + else call swap_year(time,original_year,_RC) - end if + end if else call swap_year(time,original_year,_RC) end if @@ -202,9 +203,9 @@ subroutine get_file_bracket(this, input_time, source_time, bracket, fail_on_miss call ESMF_TimeGet(target_time,yy=target_year,_RC) if (target_year < this%clim_year) then call swap_year(time,original_year+1,_RC) - else + else call swap_year(time,original_year,_RC) - end if + end if else call swap_year(time,original_year,_RC) end if @@ -216,7 +217,7 @@ subroutine get_file_bracket(this, input_time, source_time, bracket, fail_on_miss end if _RETURN(_SUCCESS) - + end subroutine get_file_bracket subroutine get_file(this,filename,target_time,shift,rc) @@ -235,7 +236,7 @@ subroutine get_file(this,filename,target_time,shift,rc) call ESMF_TimeIntervalGet(this%frequency,s_i8=interval_seconds) if (interval_seconds==0) then - ! time is not representable as absolute time interval (month, year etc...) do this + ! time is not representable as absolute time interval (month, year etc...) do this ! brute force way. Not good but ESMF leaves no choice ftime=this%reff_time do while (ftime <= target_time) @@ -243,7 +244,7 @@ subroutine get_file(this,filename,target_time,shift,rc) enddo ftime=ftime -this%frequency + shift*this%frequency else - n = (target_time-this%reff_time)/this%frequency + n = (target_time-this%reff_time)/this%frequency ftime = this%reff_time+(n+shift)*this%frequency end if if (this%clim_year /= CLIM_NULL) then @@ -270,8 +271,8 @@ subroutine swap_year(time,year,rc) logical :: is_leap_year type(ESMF_Calendar) :: calendar integer :: status, month, day, hour, minute, second - - is_leap_year=.false. + + is_leap_year=.false. call ESMF_TimeGet(time,mm=month,dd=day,h=hour,m=minute,s=second,calendar=calendar,_RC) if (day==29 .and. month==2) then is_leap_year = ESMF_CalendarIsLeapYear(calendar,year,_RC)