!
! use time_manager_mod
! implicit none
! type(time_type) :: dt, init_date, astro_base_date, time, final_date
! type(time_type) :: next_rad_time, mid_date
! type(time_type) :: repeat_alarm_freq, repeat_alarm_length
! integer :: num_steps, i, days, months, years, seconds, minutes, hours
! integer :: months2, length
! real :: astro_days
!
! !Set calendar type
! ! call set_calendar_type(THIRTY_DAY_MONTHS)
! call set_calendar_type(JULIAN)
! ! call set_calendar_type(NOLEAP)
!
! ! Set timestep
! dt = set_time(1100, 0)
!
! ! Set initial date
! init_date = set_date(1992, 1, 1)
!
! ! Set date for astronomy delta calculation
! astro_base_date = set_date(1970, 1, 1, 12, 0, 0)
!
! ! Copy initial time to model current time
! time = init_date
!
! ! Determine how many steps to do to run one year
! final_date = increment_date(init_date, years = 1)
! num_steps = (final_date - init_date) / dt
! write(*, *) 'Number of steps is' , num_steps
!
! ! Want to compute radiation at initial step, then every two hours
! next_rad_time = time + set_time(7200, 0)
!
! ! Test repeat alarm
! repeat_alarm_freq = set_time(0, 1)
! repeat_alarm_length = set_time(7200, 0)
!
! ! Loop through a year
! do i = 1, num_steps
!
! ! Increment time
! time = time + dt
!
! ! Test repeat alarm
! if(repeat_alarm(time, repeat_alarm_freq, repeat_alarm_length)) &
! write(*, *) 'REPEAT ALARM IS TRUE'
!
! ! Should radiation be computed? Three possible tests.
! ! First test assumes exact interval; just ask if times are equal
! ! if(time == next_rad_time) then
! ! Second test computes rad on last time step that is <= radiation time
! ! if((next_rad_time - time) < dt .and. time < next_rad) then
! ! Third test computes rad on time step closest to radiation time
! if(interval_alarm(time, dt, next_rad_time, set_time(7200, 0))) then
! call get_date(time, years, months, days, hours, minutes, seconds)
! write(*, *) days, month_name(months), years, hours, minutes, seconds
!
! ! Need to compute real number of days between current time and astro_base
! call get_time(time - astro_base_date, seconds, days)
! astro_days = days + seconds / 86400.
! ! write(*, *) 'astro offset ', astro_days
! end if
!
! ! Can compute daily, monthly, yearly, hourly, etc. diagnostics as for rad
!
! ! Example: do diagnostics on last time step of this month
! call get_date(time + dt, years, months2, days, hours, minutes, seconds)
! call get_date(time, years, months, days, hours, minutes, seconds)
! if(months /= months2) then
! write(*, *) 'last timestep of month'
! write(*, *) days, months, years, hours, minutes, seconds
! endif
!
! ! Example: mid-month diagnostics; inefficient to make things clear
! length = days_in_month(time)
! call get_date(time, years, months, days, hours, minutes, seconds)
! mid_date = set_date(years, months, 1) + set_time(0, length) / 2
!
! if(time < mid_date .and. (mid_date - time) < dt) then
! write(*, *) 'mid-month time'
! write(*, *) days, months, years, hours, minutes, seconds
! endif
!
! end do
!
!
! end program time_main2
!
!