Skip to content

Commit

Permalink
add invalid date error message
Browse files Browse the repository at this point in the history
  • Loading branch information
mlee03 committed Apr 9, 2021
1 parent 6b5b220 commit 96df280
Show file tree
Hide file tree
Showing 4 changed files with 3,461 additions and 240 deletions.
7 changes: 5 additions & 2 deletions test_fms/time_manager/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
# uramirez, Ed Hartnett

# Find the fms_mod.mod file.
AM_CPPFLAGS = -I$(MODDIR)
AM_CPPFLAGS = -I$(MODDIR) -I../../include

# Link to the FMS library.
LDADD = $(top_builddir)/libFMS/libFMS.la
Expand All @@ -32,7 +32,10 @@ LDADD = $(top_builddir)/libFMS/libFMS.la
check_PROGRAMS = test_time_manager

# This is the source code for the test.
test_time_manager_SOURCES = test_time_manager.F90
test_time_manager_SOURCES = test_time_manager.F90 time_manager0.F90

time_manager0_mod.mod : time_manager0.$(OBJEXT)
test_time_manager.$(OBJEXT): time_manager0_mod.mod

# Run the test program.
TESTS = test_time_manager2.sh
Expand Down
41 changes: 3 additions & 38 deletions test_fms/time_manager/test_time_manager.F90
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@ program test_time_manager
use fms_mod, only: open_namelist_file, check_nml_error, close_file, open_file
use constants_mod, only: constants_init, rseconds_per_day=>seconds_per_day
use fms_io_mod, only: fms_io_exit
use time_manager_mod, only: time_type, set_date, set_date2, get_date, get_date2, set_time, set_calendar_type, real_to_time_type
use time_manager_mod, only: time_type, set_date, get_date, set_time, set_calendar_type, real_to_time_type
use time_manager_mod, only: length_of_year, leap_year, days_in_month, days_in_year, print_time
use time_manager_mod, only: set_ticks_per_second, get_ticks_per_second
use time_manager_mod, only: decrement_date, increment_date, get_time, increment_time, decrement_time
use time_manager_mod, only: JULIAN, GREGORIAN, THIRTY_DAY_MONTHS, NOLEAP
use time_manager_mod, only: operator(-), operator(+), operator(*), operator(/), &
operator(>), operator(>=), operator(==), operator(/=), &
operator(<), operator(<=), operator(//), assignment(=)
use time_manager0_mod, only: time_type0 => time_type

implicit none

Expand Down Expand Up @@ -570,14 +571,7 @@ program test_time_manager
do dday=1,days_this_month
Time = set_date(year, month, dday, 0, 0, 0)
call get_date(Time, yr, mo, day, hr, min, sec)
call get_date2(Time, yr2, mo2, day2, hr2, min2, sec2)
if( yr.ne.yr2 .or. mo.ne.mo2 .or. day.ne.day2 ) then
write(outunit,*) 'YEAR', yr, 'YEAR2', yr2
write(outunit,*) 'MONTH', mo, 'MONTH2', mo2
write(outunit,*) 'DAY', day, 'DAY2', day2
call mpp_error(FATAL,'Error in get_date2')
end if
!write(outunit,100) yr, mo, day, leap_year(Time), days_in_month(Time), days_in_year(Time)
write(outunit,100) yr, mo, day, leap_year(Time), days_in_month(Time), days_in_year(Time)
enddo
enddo
enddo
Expand Down Expand Up @@ -615,35 +609,6 @@ program test_time_manager
write(outunit,'(a,i6)') ' ticks_per_second=',get_ticks_per_second()

!==============================================================================================
! Tests Gregorian calendar set_date
! This test loops through every day of an 400 year period and writes a line to the output file for each day.

write(outunit,'(/,a)') '################################# test set_date #################################'
call set_calendar_type(GREGORIAN)
do year=1601,2200
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
Time = set_date(year, month, dday, 0, 0, 0)
Time22 = set_date2(year, month, dday, 0, 0, 0,chooseme=.True.)
call get_date(Time, yr, mo, day, hr, min, sec)
call get_date(Time22, yr2, mo2, day2, hr2, min2, sec2)
if( yr.ne.yr2 .or. mo.ne.mo2 .or. day.ne.day2 ) then
write(outunit,*) 'YEAR', yr, 'YEAR2', yr2
write(outunit,*) 'MONTH', mo, 'MONTH2', mo2
write(outunit,*) 'DAY', day, 'DAY2', day2
call mpp_error(FATAL,'Error in get_date2')
end if
!write(outunit,100) yr, mo, day, leap_year(Time), days_in_month(Time), days_in_year(Time)
enddo
enddo
enddo
write(outunit,*) 'done'
!==============================================================================================


call fms_io_exit
Expand Down
Loading

0 comments on commit 96df280

Please sign in to comment.