Skip to content

Commit

Permalink
Remove array-based Gregorian calendar methods in time_manager (#834)
Browse files Browse the repository at this point in the history
Removes deprecated Gregorian calendar code and it's test from time_manager.F90
  • Loading branch information
mlee03 authored Oct 7, 2021
1 parent 39762d1 commit 042fff3
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 219 deletions.
60 changes: 1 addition & 59 deletions test_fms/time_manager/test_time_manager.F90
Original file line number Diff line number Diff line change
Expand Up @@ -614,64 +614,6 @@ program test_time_manager
call set_calendar_type(GREGORIAN)
call get_coded_date( coded_date, date_to_day ) ! assign coded_date and date_to_day used by get/set_date_gregorian_old

! Check that the get/set_date_gregorian_old here are the same as in time_manager
! This part of the test will be deleted when the old methods are removed from time_manager
do year=1, 3200
leap = mod(year,4) == 0
leap = leap .and. .not.mod(year,100) == 0
leap = leap .or. mod(year,400) == 0
do month=1,12
days_this_month = days_per_month(month)
if(leap .and. month == 2) days_this_month = 29
do dday=1,days_this_month
! test set_date_gregorian
Time = set_date(year, month, dday, 0, 0, 0, old_method=.true.)
Time0 = set_date_gregorian_old(year, month, dday, 0, 0, 0, 0, date_to_day)
if( .not. (Time==Time0) ) then
write(outunit,'("ERROR with year",i5,"mo",i5,"dday",i5)') year, month, dday
call mpp_error(FATAL, 'ERROR testing set_date_gregorian_old: Time!=Time0')
end if
! test #1 get_date
call get_date(Time0, yr, mo, day, hr, min, sec, old_method=.true.)
call get_date_gregorian_old(Time0, coded_date, yr0, mo0, day0, hr0, min0, sec0, ticks0)
if( yr0.ne.yr .or. mo0.ne.mo .or. day0.ne.day ) then
write(outunit,"('expected year ',i5,'but got year ',i5)") yr0, yr
write(outunit,"('expected month',i5,'but got month',i5)") mo0, mo
write(outunit,"('expected day ',i5,'but got day ',i5)") day0, day
call mpp_error(FATAl,'Error testing get_date_gregorian_old 1')
end if
! test #2 get_date
call get_date(Time, yr, mo, day, hr, min, sec, old_method=.true.)
call get_date_gregorian_old(Time, coded_date, yr0, mo0, day0, hr0, min0, sec0, ticks0)
if( yr0.ne.yr .or. mo0.ne.mo .or. day0.ne.day ) then
write(outunit,"('expected year ',i5,'but got year ',i5)") yr0, yr
write(outunit,"('expected month',i5,'but got month',i5)") mo0, mo
write(outunit,"('expected day ',i5,'but got day ',i5)") day0, day
call mpp_error(FATAl,'Error testing get_date_gregorian 2')
end if
! test #3 get_date
call get_date(Time, yr, mo, day, hr, min, sec, old_method=.true.)
call get_date_gregorian_old(Time0, coded_date, yr0, mo0, day0, hr0, min0, sec0, ticks0)
if( yr0.ne.yr .or. mo0.ne.mo .or. day0.ne.day ) then
write(outunit,"('expected year ',i5,'but got year ',i5)") yr0, yr
write(outunit,"('expected month',i5,'but got month',i5)") mo0, mo
write(outunit,"('expected day ',i5,'but got day ',i5)") day0, day
call mpp_error(FATAl,'Error testing get_date_gregorian 3')
end if
! test #4 get_date
call get_date(Time0, yr, mo, day, hr, min, sec, old_method=.true.)
call get_date_gregorian_old(Time, coded_date, yr0, mo0, day0, hr0, min0, sec0, ticks0)
if( yr0.ne.yr .or. mo0.ne.mo .or. day0.ne.day ) then
write(outunit,"('expected year ',i5,'but got year ',i5)") yr0, yr
write(outunit,"('expected month',i5,'but got month',i5)") mo0, mo
write(outunit,"('expected day ',i5,'but got day ',i5)") day0, day
call mpp_error(FATAl,'Error testing get_date_gregorian 4')
end if
enddo
enddo
enddo
write(outunit,'(a)') 'set_date_gregorian_old and get_date_gregorian_old tests successful'

! test the new Gregorian methods and compare with the old methods
do year=1, 3200
leap = mod(year,4) == 0
Expand Down Expand Up @@ -824,7 +766,7 @@ function set_date_gregorian_old(year, month, day, hour, minute, second, tick, da
day1 = day1 + days_in_400_year_period*((year-1)/400)

set_date_gregorian_old = set_time(seconds=second1, days=day1, ticks=tick)

end function set_date_gregorian_old

end program test_time_manager
Loading

0 comments on commit 042fff3

Please sign in to comment.