subroutine jd2yd( jd, yd ) ! ! Given Julian Day Number (and fraction), returns Gregorian ! calendar date of the form yyyyddd.dd. (Year "1 B.C." is ! Gregorian year 0, "2 B.C. is Gregorian year -1, etc.) ! ! B. Knapp, 95.09.25 ! ! Caution: This routine should not be used to obtain historical ! dates for historical events prior to the adoption of the ! Gregorian calendar (1582 to 1918, depending on country); ! instead, for such dates a JD #-to-*Julian*-calendar-date ! service should be used. ! C C RCS DATA C C $Header$ C C $Log$ C C implicit none ! ! Input: real*8 jd ! ! Output: real*8 yd ! ! Local: real*8 a,b,j,d integer*4 m,n,y ! ! ! Add 10000 years (to handle negative years) and subtract ! JDN for day 1.0, year 0, Gregorian proleptic calendar: j = jd + 3652425.0d0 - 1721059.5d0 ! ! What portion of a 400-year cycle do we have? a = mod( j, 146097.0d0 ) ! ! How many non-leap-year centuries have elapsed in this cycle? if ( a .lt. 36890.0d0 ) then m = 0 else m = int( (a-366.0d0)/36524.0d0 ) endif ! ! How many days in the current 4-year cycle have elapsed? b = mod( (a+m), 1461.0d0 ) ! ! How many years in the current 4-year cycle, and how many ! days in the current year? if ( b .lt. 366.0d0 ) then n = 0 d = b+1 else n = int( (b-1)/365.0d0 ) d = b-n*365.0d0 endif ! ! Compute the year (and take back the 10000-year offset) y = int( j/146097.0d0 )*400 + int( (a+m)/1461.0d0 )*4 + n - & 10000 ! ! Construct date of form yyyyddd.dd yd = sign( abs(y)*1000.0d0+d, dble(y) ) return end