NM = MOD(NYMD,10000) / 100
NM = NM - 1
IF (NM.EQ.0) THEN
NM = 12
ND = NDPM(NM)
IF (NM.EQ.2 .AND. LEAP(NY)) ND = 29
IF (ND.EQ.29 .AND. NM.EQ.2 .AND. LEAP(NY)) GO TO 20
IF (ND.GT.NDPM(NM)) THEN
NM = NM + 1
IF (NM.GT.12) THEN
NM = 1
INCYMD = NY*10000 + NM*100 + ND
IF (NM.LE.1) GO TO 60
ND = ND + NDPM(NM)
IF (NM.EQ.2 .AND. LEAP(NY)) ND = ND + 1