Skip to content

Commit

Permalink
Remove hc_jday and replace with "compute_days_between" for HYCOM forc…
Browse files Browse the repository at this point in the history
…ing (CICE-Consortium#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
  • Loading branch information
mhrib authored Apr 20, 2021
1 parent f462721 commit 1cddc84
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 51 deletions.
6 changes: 3 additions & 3 deletions cicecore/cicedynB/general/ice_forcing.F90
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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, &
Expand Down Expand Up @@ -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)
Expand Down
48 changes: 0 additions & 48 deletions cicecore/shared/ice_calendar.F90
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 1cddc84

Please sign in to comment.