      SUBROUTINE JULCAL(MONTH,IDAY,IYEAR,JDAY)
!     JULCAL CALCULATES AND RETURNS THE CALENDAR DATE GIVEN THE JULIAN DAY AND
!  YEAR.  LEAP YEARS ARE ACCOUNTED FOR.
!
!  ARGUMENTS:
!    MONTH  - THE MONTH OF THE YEAR CALCULATED (AND RETURNED) BY JULCAL.
!    IDAY   - THE DAY OF THE MONTH CALCULATED (AND RETURNED) BY JULCAL.
!    IYEAR  - THE YEAR OF THE JULIAN DAY TO BE CONVERTED.
!    JDAY   - THE JULIAN DAY TO BE CONVERTED.
!
!  CONVERTED FROM THE IBM1800 SYSTEM BY PAUL HENKART, SCRIPPS INSTITUTION OF
!  OCEANOGRAPHY, 28 OCTOBER 1980
!
      DIMENSION MTHDY(12)
      DATA MTHDY/31,28,31,30,31,30,31,31,30,31,30,31/
!
      ISUM=0
!
!     CHECK FOR LEAP YEAR
!
!      IF(IYEAR-IYEAR/4*4)2,1,2
      IF(IYEAR-IYEAR/4*4 .EQ. 0 ) MTHDY(2)=29
!
!     SUM DAYS/ MONTH
!
2     DO 3 I=1,12
      ISUM=ISUM+MTHDY(I)
      ii = i
!
!     COMPARE AGAINST JULIAN DAY
!
!      IF(ISUM-JDAY) 3,4,4
      IF(ISUM-JDAY .GE. 0 ) GOTO 4
3     CONTINUE
!
!     JULIAN DAY FALLS WITHIN MONTH I, SO SUBTRACT OUT MONTH I FOR DATE
!
4     MONTH=II
      IDAY=JDAY+MTHDY(II)-ISUM
!
!     RESET LEAP YEAR COUNT
!
      MTHDY(2)=28
      RETURN
      END
