From 1cddc8474d3f3621d49a1b8c45b4c3919eba8728 Mon Sep 17 00:00:00 2001 From: Mads Hvid Ribergaard <38077893+mhrib@users.noreply.github.com> Date: Tue, 20 Apr 2021 17:54:07 +0200 Subject: [PATCH] Remove hc_jday and replace with "compute_days_between" for HYCOM forcing (#597) * Remove hc_jday. Not used anymore after introducing of new ice_calendar * Calculate "hc_jday" inline using compute_days_between and _init fields from ice_calendar * Correct hcdate using "compute_days_between" * Remove unused variables from ice_calendar --- cicecore/cicedynB/general/ice_forcing.F90 | 6 +-- cicecore/shared/ice_calendar.F90 | 48 ----------------------- 2 files changed, 3 insertions(+), 51 deletions(-) mode change 100644 => 100755 cicecore/cicedynB/general/ice_forcing.F90 diff --git a/cicecore/cicedynB/general/ice_forcing.F90 b/cicecore/cicedynB/general/ice_forcing.F90 old mode 100644 new mode 100755 index d18b1ccd7..186e50f6c --- a/cicecore/cicedynB/general/ice_forcing.F90 +++ b/cicecore/cicedynB/general/ice_forcing.F90 @@ -24,7 +24,7 @@ module ice_forcing use ice_communicate, only: my_task, master_task use ice_calendar, only: istep, istep1, & msec, mday, mmonth, myear, yday, daycal, & - daymo, days_per_year, hc_jday + daymo, days_per_year, compute_days_between use ice_fileunits, only: nu_diag, nu_forcing use ice_exit, only: abort_ice use ice_read_write, only: ice_open, ice_read, & @@ -4607,8 +4607,8 @@ subroutine hycom_atm_data call icepack_query_parameters(Tffresh_out=Tffresh) call icepack_query_parameters(secday_out=secday) - ! current time in HYCOM jday units - hcdate = hc_jday(myear,0,0)+ yday+msec/secday + ! current time in HYCOM jday units (HYCOM ref year: 1900,12,31,000000) + hcdate = real(compute_days_between(1900,12,31,myear,mmonth,mday)) + msec/secday ! Init recnum try recnum=min(max(oldrecnum,1),Njday_atm-1) diff --git a/cicecore/shared/ice_calendar.F90 b/cicecore/shared/ice_calendar.F90 index 8158313d9..4d7ae378f 100644 --- a/cicecore/shared/ice_calendar.F90 +++ b/cicecore/shared/ice_calendar.F90 @@ -36,7 +36,6 @@ module ice_calendar public :: set_date_from_timesecs ! set model date from time in seconds ! (relative to init date) ! needed for binary restarts - public :: hc_jday ! converts "calendar" date to HYCOM julian day ! semi-private, only used directly by unit tester public :: compute_elapsed_days ! compute elapsed days since 0000-01-01 @@ -916,53 +915,6 @@ subroutine calendar_time2date(atimesecs,ayear,amon,aday,asec,year_ref,mon_ref,da end subroutine calendar_time2date -!======================================================================= - - real(kind=dbl_kind) function hc_jday(iyear,imm,idd,ihour) -!-------------------------------------------------------------------- -! converts "calendar" date to HYCOM julian day: -! 1) year,month,day,hour (4 arguments) -! 2) year,doy,hour (3 arguments) -! -! HYCOM model day is calendar days since 31/12/1900 -!-------------------------------------------------------------------- - real(kind=dbl_kind) :: dtime - integer(kind=int_kind) :: iyear,iyr,imm,idd,idoy,ihr - integer(kind=int_kind), optional :: ihour - integer (kind=int_kind) :: n - - if (present(ihour)) then - !----------------- - ! yyyy mm dd HH - !----------------- - iyr=iyear-1901 - dtime = floor(365.25_dbl_kind*iyr)*c1 + idd*c1 + ihour/24._dbl_kind - if (mod(iyr,4)==3) then - do n = 1,imm-1 - dtime = dtime + daymo366(n) - enddo - else - do n = 1,imm-1 - dtime = dtime + daymo365(n) - enddo - endif - - else - !----------------- - ! yyyy DOY HH - !----------------- - ihr = idd ! redefine input - idoy = imm ! redefine input - iyr = iyear - 1901 - dtime = floor(365.25_dbl_kind*iyr)*c1 + idoy*c1 + ihr/24._dbl_kind - - endif - - hc_jday=dtime - - return - end function hc_jday - !======================================================================= end module ice_calendar