! $Id: augmentutc.f90 5714 2019-02-13 15:51:08Z idculv $ !****s* Datetime/AugmentUTC * ! ! NAME ! AugmentUTC (augmentutc.f90) ! ! SYNOPSIS ! Subroutine to add specified time in days to given UTC datetime, expressed ! as length-8 integer arrays (/ YYYY, MM, DD, Zone, hh, mm, ss, msec /). ! CALL AugmentUTC (UTC, JDF) ! ! INPUTS ! UTC int(8) UTC datetime ! jdf (dp) time to add in years ! ! OUTPUTS ! UTC int(8) UTC datetime (updated) ! ! DESCRIPTION ! Adds JDF to UTC properly, taking account of leap seconds. ! ! NOTES ! The conversion is carried out by adding or subtracting leapseconds ! to the given Julian days. ! ! SEE ALSO ! CalToJul() ! LeapSeconds() ! GPStoUTC() ! ! AUTHOR ! Met Office, Exeter, UK. ! Any comments on this software should be given via the ROM SAF ! Helpdesk at http://www.romsaf.org ! ! COPYRIGHT ! (c) EUMETSAT. All rights reserved. ! For further details please refer to the file COPYRIGHT ! which you should have received as part of this distribution. ! !**** SUBROUTINE AugmentUTC ( CDT, & ! (inout) JDF ) ! (in) USE datetimetypes, ONLY: dp USE datetimeprogs, not_this => AugmentUTC IMPLICIT NONE ! Argument list parameters INTEGER, INTENT(INOUT) :: CDT(8) ! UTC datetime REAL(dp), INTENT(IN) :: JDF ! Number of days to add ! Local variables INTEGER :: CDT2(8) INTEGER :: leapsec_start, leapsec_end REAL(dp), PARAMETER :: sec2day=1.0_dp/86400.0_dp REAL(dp) :: jdf2 !--------------------------------------------------------------- ! 1. Add JDF to CDT, adding or subtracting the right number of leap seconds !--------------------------------------------------------------- leapsec_start = leapseconds(CDT) ! Number of leapsecs up to CDT CALL CalToJul(CDT, JDF2, 1) ! JDF2 = days up to CDT, not including leap seconds jdf2 = jdf2 + jdf ! Days up to final time, not including leap seconds CALL CalToJul(CDT, JDF2, -1) ! CDT = 'GPS' datetime of final time, not including leap seconds CALL GPStoUTC(CDT, CDT2, 1) ! CDT2 = UTC datetime of final time, including leap seconds leapsec_end = leapseconds(CDT2) ! Number of leapsecs up to CDT2 jdf2 = jdf2 - (leapsec_end - leapsec_start) * sec2day ! Days up to final time, including leap seconds CALL CalToJul(CDT, JDF2, -1) ! CDT = UTC of final time, including leap seconds END SUBROUTINE AugmentUTC