c *************************** c *** Subroutine GRcJL *** c *** 1984/12/06/15-47 *** c *************************** c Subroutine GRcJL(iyear,imon,iday,ihr,imin,seci, jl,fjl) *********************************************************************** * * * Purpose: Given a Gregorian date (i.e., a present day calendar * * date) by iyear, imon, iday, ihr, imin, seci. * * * * Return the Julian date in days and fractional parts * * of days (jl, fjl). * * * * The Julian date is a continuous count of days and * * fractional days from -4712 b.C. january 1 at * * 0.5 hours UT. If the user wants the time elapsed * * in days from january 0 at 0 hours UT, he has * * to call this program a second time at 12-31-0 hours * * of the previous year and difference the Julian * * dates. * * * * Program is valid for 1 <= iyear <= 199 * * This corresponds to 1901 <= Year <= 2099 * * * * * * Parameters Type I/O Function * * * * iyear i*4 I year * * imon i*4 I month * * iday i*4 I day * * ihr i*4 I hours * * imin i*4 I minutes * * seci r*8 I seconds * * * * jl i*4 O days of Julian date * * fjl r*8 O fractional part of days of * * Julian date * * * * * * Examples * * * * Input: iyear = 83, imon = 12, iday = 31, ihr = 23, imin = 59, * * seci = 59.12345678901234 * * Represents: 1983/12/31/23/59/59.12345678901234 * * Output: jl = 2445700, fjl = 0.4999898548239470 * * * * Input: iyear = 84, imon = 1, iday = 1, ihr = 0, imin = 0, * * seci = 0.0 * * Represents: 1984/01/01/00/00/00.0 * * Output: jl = 2445700, fjl = 0.5000000000000000 * * * * Input: iyear = 84, imon = 1, iday = 1, ihr = 0, imin = 0, * * seci = 1.00000000000000 * * Represents: 1984/01/01/00/00/01.00000000000000 * * Output: jl = 2445700, fjl = 0.5000115740740741 * * * * Input: iyear = 84, imon = 10, iday = 7, ihr = 15, imin = 30, * * seci = 12.123456789012341 * * Represents: 1984/10/07/15/30/12.12345678901234 * * Output: jl = 2445981, fjl = 0.1459736511202432 * * * * * * B. Hofmann-Wellenhof, B. Remondi * * * *********************************************************************** implicit real*8(a-h,o-z) dimension idaymo(12) data idaymo/31,28,31,30,31,30,31,31,30,31,30,31/ c c Input data test. c if(iyear .lt. 1 .or. iyear .gt. 199) + stop ' GRcJL: "iyear" must be 1 <= iyear <= 199' if(imon .lt. 1 .or. imon .gt. 12) + stop ' GRcJL: "imon" must be 1 <= imon <= 12' if(iday .lt. 1 .or. iday .gt. 31) + stop ' GRcJL: "iday" must be 1 <= iday <= 31' if(iday .le. idaymo(imon)) goto 3000 if(imon .ne. 2) + stop ' GRcJL: The input month has only 30 days' c c The input month is february. If iday .gt. 29 the answer c is in any case wrong. c if(iday .gt. 29) + stop ' GRcJL: February can never have more than 29 days!' c c At this level it is known, that iday = 29 and the chosen c month is february. The input is correct, if the input c year is a leap year. Prove for leap year. c leap = 0 iy19 = iyear + 1900 if(mod(iy19, 4) .ne. 0) goto 3020 leap = 1 if(mod(iy19, 100) .ne. 0) goto 3020 if(mod(iy19, 400) .ne. 0) leap = 0 3020 continue c c If leap = 0 it is no leap year and the answer is wrong. c if(leap .eq. 1) goto 3000 stop + ' GRcJL: "iyear" no leap year, thus february has only 28 days' 3000 continue if(ihr .lt. 0 .or. ihr .gt. 23) + stop ' GRcJL: "ihr" must be 0 <= ihr <= 23' if(imin .lt. 0 .or. imin .gt. 59) + stop ' GRcJL: "imin" must be 0 <= imin <= 59' if(seci .lt. 0.d0 .or. seci .ge. 60.d0) + stop ' GRcJL: "seci" must be 0.0 <= seci < 60.0' c i10 = (imon+9)/12 iy19 = iyear + 1900 i10 = ((i10+iy19)*7)/4 i11 = (275*imon)/9 jl = 367*iy19 + iday + i11 - i10 jl = jl + 1721013 fjl = 0.5d0 + ((seci/60.d0 + imin)/60.d0 + ihr)/24.d0 if(fjl .lt. 1.d0) goto 3030 jl = jl + 1 fjl = fjl - 1.d0 3030 continue return c c End of Subroutine GRcJL c c ***************************************************************** end