calendar_date_realsec Subroutine

private pure subroutine calendar_date_realsec(julian_date, year, month, day, hrs, min, sec)

Returns the year, month, day, hr, min, sec for the specified Julian date.

See also

  • https://aa.usno.navy.mil/faq/JD_formula.html
  • http://www.davidgsimpson.com/software/jd2greg_f90.txt

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: julian_date

julian date

integer, intent(out) :: year
integer, intent(out) :: month
integer, intent(out) :: day
integer, intent(out) :: hrs
integer, intent(out) :: min
real(kind=wp), intent(out) :: sec

Called by

proc~~calendar_date_realsec~~CalledByGraph proc~calendar_date_realsec time_module::calendar_date_realsec interface~julian_date_to_calendar_date time_module::julian_date_to_calendar_date interface~julian_date_to_calendar_date->proc~calendar_date_realsec proc~time_module_test time_module::time_module_test proc~time_module_test->proc~calendar_date_realsec

Source Code

    pure subroutine calendar_date_realsec(julian_date,year,month,day,hrs,min,sec)

    implicit none

    real(wp),intent(in)  :: julian_date !! julian date
    integer,intent(out)  :: year
    integer,intent(out)  :: month
    integer,intent(out)  :: day
    integer,intent(out)  :: hrs
    integer,intent(out)  :: min
    real(wp),intent(out) :: sec

    integer :: i,j,k,l,n,jd
    real(wp) :: frac_day

    jd = int(julian_date)

    l = jd+68569
    n = 4*l/146097
    l = l-(146097*n+3)/4
    i = 4000*(l+1)/1461001
    l = l-1461*i/4+31
    j = 80*l/2447
    k = l-2447*j/80
    l = j/11
    j = j+2-12*l
    i = 100*(n-49)+i+l

    year  = i
    month = j
    day   = k

    frac_day = julian_date - real(jd,wp) + 0.5_wp

    hrs = int(frac_day*24.0_wp)
    min = int((frac_day - hrs/24.0_wp) * 1440.0_wp)
    sec = (frac_day - hrs/24.0_wp - min/1440.0_wp) * 86400.0_wp

    if (sec == 60.0_wp) then
        sec = 0.0_wp
        min = min + 1
     end if

     if (min == 60) then
        min = 0
        hrs = hrs + 1
     end if

    end subroutine calendar_date_realsec