c c **************************** c *** Subroutine GRcMJL *** c *** 1984/12/06/15-47 *** c **************************** c Subroutine GRcMJL(iyear,imon,iday,ihr,imin,seci, mjl,fmjl) *********************************************************************** * * * Purpose: Given a Gregorian date (i.e., a present day calendar * * date) by iyear, imon, iday, ihr, imin, seci. * * * * Return the modified Julian date in days and * * fractional parts of days (mjl, fmjl). * * * * 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. * * The modified Julian date is obtained from the * * Julian date by computing * * (mjl, fmjl) = (jl-2400000, fjl-0.5) * * * * 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 * * * * mjl i*4 O days of modified Julian date * * fmjl r*8 O fractional part of days of * * modified 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: mjl = 45699, fmjl = 0.9999898548239470 * * * * Input: iyear = 84, imon = 1, iday = 1, ihr = 0, imin = 0, * * seci = 0.0 * * Represents: 1984/01/01/00/00/00.0 * * Output: mjl = 45700, fmjl = 0.0000000000000000 * * * * Input: iyear = 84, imon = 1, iday = 1, ihr = 0, imin = 0, * * seci = 1.00000000000000 * * Represents: 1984/01/01/00/00/01.00000000000000 * * Output: mjl = 45700, fmjl = 0.0000115740740740 * * * * Input: iyear = 84, imon = 10, iday = 7, ihr = 15, imin = 30, * * seci = 12.123456789012341 * * Represents: 1984/10/07/15/30/12.12345678901234 * * Output: mjl = 45980, fjl = 0.6459736511202432 * * * * * * 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 ' GRcMJL: "iyear" must be 1 <= iyear <= 199' if(imon .lt. 1 .or. imon .gt. 12) + stop ' GRcMJL: "imon" must be 1 <= imon <= 12' if(iday .lt. 1 .or. iday .gt. 31) + stop ' GRcMJL: "iday" must be 1 <= iday <= 31' if(iday .le. idaymo(imon)) goto 3000 if(imon .ne. 2) + stop ' GRcMJL: 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 ' GRcMJL: 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 +' GRcMJL: "iyear" no leap year, thus february has only 28 days' 3000 continue if(ihr .lt. 0 .or. ihr .gt. 23) + stop ' GRcMJL: "ihr" must be 0 <= ihr <= 23' if(imin .lt. 0 .or. imin .gt. 59) + stop ' GRcMJL: "imin" must be 0 <= imin <= 59' if(seci .lt. 0.d0 .or. seci .ge. 60.d0) + stop ' GRcMJL: "seci" must be 0.0 <= seci < 60.0' c call GRcJL(iyear,imon,iday,ihr,imin,seci, jl,fjl) call JLcMJL(jl,fjl, mjl,fmjl) return c c End of Subroutine GRcMJL c c ***************************************************************** end