      SUBROUTINE JULDAY(JDAY,IYEAR,IMONTH,IDAY)
C
C**********************************************************************
C
C   NAME- JULDAY
C
C   LANGUAGE- FORTRAN 77    TYPE- SUBROUTINE   COMPUTER- CRAY
C
C   VERSION- 1.0  DATE- 10/25/85  PROGRAMMER- KRISHNA TADEPALLI (SMSRC)
C   VERSION- 3.0  DATE- 04/16/96  PROGRAMMER- ALEX POZDNYAK (FDC)  
C      MODIFIED TO RUN ON THE CRAY.  REPLACED I*4 WITH INT.
C  
C   FUNCTION- TO CONVERT A GIVEN JULIAN DAY (DAY OF THE YEAR)
C             TO A MONTH AND DAY(DAY OF THE MONTH)
C
C   CALLING
C   PARAMETERS-
C      VARIABLE    TYPE   I/O   FUNCTION
C      --------    ----   ---   --------
C      JDAY         INT    I    DAY OF YEAR(I.E., 1-366)
C      IYEAR        INT    I    YEAR (YEAR MAY BE IN 4-DIGIT
C                               FORMAT, I.E. 1991, OR IN 2-DIGIT
C                               FORMAT, I.E. 91)
C      IMONTH       INT    O    MONTH (I.E., 1-12)
C      IDAY         INT    O    DAY OF MONTH(I.E., 1-31)
C
      INTEGER  JDAY, IYEAR, IMONTH, IDAY
C
C   LOCAL PARAMETERS-
C      VARIABLE                TYPE     FUNCTION
C      --------                ----     --------
C      JDTBL1(12)               INT     NON-LEAP YEAR JULIAN TABLE
C                                       BY MONTHLY INCREMENTS
C      JDTBL2(12)               INT     LEAP YEAR JULIAN TABLE BY MONTH
C      K                        INT     LOOP CONTROL
C
      INTEGER  JDTBL1(12), JDTBL2(12), K
C
C   COMMENTS- THIS SUBROUTINE IS VALID ONLY FOR DATES IN THE YEARS
C             1901 - 2099.
C
C**********************************************************************
C
      DATA JDTBL2/31,60,91,121,152,182,213,244,274,305,335,366/
      DATA JDTBL1/31,59,90,120,151,181,212,243,273,304,334,365/
C
C   IF JDAY IS BLANK RETURN TO CALLING PROGRAM
C
      IF(JDAY.EQ.0) GO TO 50
C
C   THE FOLLOWING IS FOR A NON-LEAP YEAR
C
      IF (MOD(IYEAR,4).NE.0) THEN
         DO 10 K=1,12
            IF (JDAY-JDTBL1(K) .LE. 0 ) GO TO 20
C
   10    CONTINUE
   20    CONTINUE
         IMONTH = K
         IF(K.EQ.1) THEN
            IDAY = JDAY
         ELSE
            IDAY = JDAY-JDTBL1(K-1)
         ENDIF
C
C   THE FOLLOWING IS USED FOR A LEAP YEAR
C
      ELSE
         DO 30 K=1,12
            IF (JDAY-JDTBL2(K) .LE. 0 ) GO TO 40
C
   30    CONTINUE
   40    CONTINUE
         IMONTH = K
         IF(K.EQ.1) THEN
            IDAY = JDAY
         ELSE
            IDAY = JDAY-JDTBL2(K-1)
         ENDIF
      ENDIF
   50 CONTINUE
      RETURN
      END
