LEAP(NY) = MOD(NY,4).EQ.0 .AND. (NY.NE.0 .OR. MOD(NY00,400).EQ.0)
NY = NYMD / 10000
NY = NY - 1
IF (NM.EQ.2 .AND. LEAP(NY)) ND = 29
IF (ND.EQ.29 .AND. NM.EQ.2 .AND. LEAP(NY)) GO TO 20
NY = NY + 1
INCYMD = NY*10000 + NM*100 + ND
IF (NM.EQ.2 .AND. LEAP(NY)) ND = ND + 1