      SUBROUTINE DAYMON (IYEAR,IDAYNO,MON,IDAY)
C     ROUTINE TO COMPUTE MONTH DAY, GIVEN YEAR AND DAY OF YEAR (IDAYNO)
      DIMENSION NMON(4),K(4)
      DATA K/28,29,30,31/
      YEAR=IYEAR
      DO 10 I=1,4
   10 NMON(I)=0
      IDM=0
      IDT=0
C     NMON(I) COUNTS THE NUMBERS OF DIFFERENT-LENGTH MONTHS UP TO THAT I
C     WHICH IDAYNO OCCURS. I=1 FOR 28 DAY,2 FOR 29,3 FOR 30,4 FOR 31.
C     IDM IS SET TO THE NUMBER OF DAYS IN THE ITH MONTH. IDT IS THE TOTA
C     NUMBER OF DAYS, UP TO THE ITH MONTH, CONSIDERED SO FAR.
      DO 20 I=1,12
      IF ( I .NE. 2) GO TO 30
      ID=2
      IF (AMOD(YEAR,4.) .NE. 0.0) ID=1
C     IF ID=1, THIS IS NOT A LEAP YEAR.
      NMON(ID)=1
      IDM=K(ID)
      GO TO 60
   30 IF (I .EQ. 4 .OR. I .EQ. 6 .OR. I .EQ. 9 .OR. I .EQ. 11) GO TO 50
C     THIS MONTH HAS 31 DAYS.
      IDM=31
      NMON(4)=NMON(4)+1
      GO TO 60
C     THIS MONTH HAS 30 DAYS.
   50 IDM=30
      NMON(3)=NMON(3)+1
   60 IDT=IDT+IDM
      IF (IDAYNO-IDT) 70,70,20
   70 IDAY=IDAYNO
      MON=0
      DO 80 J=1,4
      IDAY=IDAY-NMON(J)*K(J)
   80 MON=MON+NMON(J)
      IDAY=IDAY+IDM
      RETURN
   20 CONTINUE
      RETURN
      END
