!$Header: /weru/cvs/weps/weps.src/util/date/julday.for,v 1.4 2005-07-18 16:49:56 fredfox Exp $ ! ! JULDAY is taken from _Numerical_Recipes:_The_Art_of_Scientific_Computing_ integer function julday (dd, mm, yyyy) ! + + + PURPOSE + + + ! In this routine JULDAY returns the Julian Day Number which begins at ! noon of the calendar date specified by day "dd", month "mm", & year "yyyy" ! All are integer variables. Positive year signifies A.D.; negative, B.C. ! Remember that the year after 1 B.C. was 1 A.D. ! The following invalid calendar dates are checked for and reported: ! 1. zero year ! 2. dates between 4/10/1582 and 15/10/1582 are specified. ! ! Additional checking for other invalid dates could be added ! in the future if necessary. ! ! + + + KEYWORDS + + + ! date, utility ! ! + + + ARGUMENT DECLARATIONS + + + integer dd, mm, yyyy integer igreg ! ! ! + + + ARGUMENT DEFINITIONS + + + ! dd - integer value of day in the range 1-31 ! mm - month in the range 1-12 ! yyyy - year (negative A.D., positive B.C.) ! ! + + + PARAMETERS + + + ! Gregorian Calendar was adopted on Oct. 15, 1582. parameter (igreg=15+31*(10+12*1582)) ! ! + + + LOCAL VARIABLES + + + integer jy, jm, ja, y_nw ! ! + + + END SPECIFICATIONS + + + ! if (yyyy.eq.0) write(*,*) 'There is no year zero' if ((yyyy.eq.1582) .and. (mm.eq.10) .and. (dd.lt.15) .and. & & (dd.gt.4)) write(*,*) 'This is an invalid date' if (yyyy.lt.0) then y_nw = yyyy + 1 else y_nw = yyyy end if if (mm.gt.2) then jy = y_nw jm=mm+1 else jy = y_nw - 1 jm=mm+13 endif julday=int(365.25*jy)+int(30.6001*jm)+dd+1720995 if (dd+31*(mm+12*y_nw).ge.igreg) then ja=jy/100 ! ja=int(dble(0.01)*dble(jy)) julday=julday+2-ja+int(dble(0.25)*dble(ja)) endif return end ! !$Log: not supported by cvs2svn $ !Revision 1.3 2005/06/21 15:17:06 fredfox !corrected date function to not modify passed year when given BC dates, only print warnings instead of pause and properly pass date to function in weps when doing initialization and year is zero, which is not allowed ! !Revision 1.2 2002/09/04 20:22:18 wagner !allow free format src compilation ! !Revision 1.1.1.1 1999/03/12 17:05:31 wagner !Baseline version of WEPS with Bill Rust's modifications ! ! Revision 1.2 1998/09/03 18:35:36 jt ! check in a full copy of WEPS - I hope ??? ! ! Revision 1.1.1.1 1995/01/18 04:20:07 wagner ! Initial checkin ! ! Revision 2.2 1992/04/03 23:04:07 wagner ! changed from multiplying by 0.01 to dividing by 100 ! to alleviate floating point roundoff problem that ! exists with Microsoft FORTRAN v5.1 compiler when ! the dates of 28/2/1900 - 28/2/1901 are input. ! Hopefully, this will fix that problem without ! others surfacing from this change. ! The line used to be: ! ja=int(dble(0.01)*dble(jy)) ! It is now: ! ja=jy/100 ! ! Revision 2.1 1992/03/27 17:22:53 wagner ! Fixed roundoff problems by adding some ! double precision casts (DBLE) to some ! constants and integer variables in a ! couple of intermediate computations. ! ! Also added some preliminary error checking ! for a zero year and the "missing" days ! between 4/10/1582 and 15/10/1582. ! ! Version 2 code. !