      SUBROUTINE yd2ymd(IYDD,IYMD)
      INTEGER *4 MONTHS(13),IYDD,IYMD,THIS_MON(13),IDAY,DAY,MON,I
      DATA MONTHS/0,31,59,90,120,151,181,212,243,273,304,334,365/
      IF (MOD(IYDD/1000,4).EQ.0) THEN
        THIS_MON(2) = 31
        DO 20 I=3,13
          THIS_MON(I) = MONTHS(I) + 1
   20   CONTINUE
      ELSE
        DO 40 I = 2,13
          THIS_MON(I) = MONTHS(I)
   40   CONTINUE
      ENDIF
      IDAY = MOD(IYDD,1000)
      DO 60 I = 2,13
        IF (IDAY.GT.THIS_MON(I-1) .AND. IDAY .LE. THIS_MON(I))THEN
          MON = I-1
          DAY = IDAY - THIS_MON(I-1)
         IYMD = IYDD/1000 * 10000 + MON * 100+ DAY
        ENDIF
   60 CONTINUE
 1001 FORMAT(1X,A20,I6,1X,I6)
      RETURN
      END

