c$Header: /weru/cvs/weps/weps.src/util/date/caldat.for,v 1.3 2000-01-29 22:23:24 wjr Exp $ c c CALDAT is taken from _Numerical_Recipes:_The_Art_of_Scientific_Computing_ c subroutine caldat i (ijulian, o dd, mm, yyyy) include 'm1sim.inc' c c + + + PURPOSE + + + c Inverse of the function JULDAY. Here 'julian' is input as a Julian Day c Number, and the routine outputs the dd, mm, and yyyy on which the c specified Julian Day started at noon. c c + + + KEYWORDS + + + c date, utility c c + + + ARGUMENT DECLARATIONS + + + integer ijulian, dd, mm, yyyy integer igreg, julian c c c + + + ARGUMENT DEFINITIONS + + + c mm - integer value of mm in the range 1-12 c dd - dd in the range 1-31 c yyyy - yyyy (negative A.D., positive B.C.) c julian - integer value equal to Julian Day Number c c + + + PARAMETERS + + + c Gregorian Calendar was adopted on Oct. 15, 1582. parameter (igreg=2299161) c c + + + LOCAL VARIABLES + + + integer jalpha, ja, jb, jc, jd, je real c,e, alpha c c + + + END SPECIFICATIONS + + + c C if the date is -1 then use the simulation date. julian = ijulian if (julian.eq.-1) julian = am0jd if (julian.ge.igreg) then alpha = (dble(julian-1867216)-dble(0.25))/dble(36524.25) jalpha = int(alpha) ja = julian+1+jalpha - int (dble(0.25)*jalpha) else ja=julian endif jb=ja+1524 c = dble(6680.0)+((jb-2439870)-dble(122.1))/dble(365.25) jc = int(c) jd=365*jc+int (dble(0.25)*jc) e = (jb-jd)/dble(30.6001) je = int(e) dd=jb-jd-int (dble(30.6001)*je) mm=je-1 if (mm.gt.12) mm=mm-12 yyyy=jc-4715 if (mm.gt.2) yyyy=yyyy-1 if (yyyy.le.0) yyyy=yyyy-1 return end c c$Log: not supported by cvs2svn $ cRevision 1.2 1999/04/26 20:16:19 wagner cchanges due to combining include files ([cdb]1glob.inc), etc c cRevision 1.1.1.1 1999/03/12 17:05:31 wagner cBaseline version of WEPS with Bill Rust's modifications c c Revision 1.1.1.1 1995/01/18 04:20:06 wagner c Initial checkin c c Revision 2.3 1992/04/03 23:24:58 wagner c Removed extraneous test print statements. c c Revision 2.2 1992/04/03 23:15:54 wagner c Added some typecasts from floats to doubles (dble) c to hopefully eliminate some roundoff error problems c with the MS FORTRAN 5.1 compiler. c Later, we determined that the problem was occuring c in the julday function and not the caldat subroutine. c However, these changes should not bother anything c so the changes have been kept. c c Revision 2.1 1992/03/27 17:22:53 wagner c Version 2 code. c