subroutine addtm2 (iyd1, it1, inc, iyd2, it2) c c----------------------------------------------------------------------- c c Adds a positive increment inc (in ms) to the time in iyd1, it1 c c----------------------------------------------------------------------- c integer*4 idy2, inc, it1, it2, iyd1, iyd2, iyr2, leap c c----------------------------------------------------------------------- c *** parse the year and day of year *** c----------------------------------------------------------------------- c iyr2 = iyd1 / 1000 idy2 = iyd1 - (iyr2 * 1000) c c----------------------------------------------------------------------- c *** check for leap year, RIMS requires only the simple test *** c----------------------------------------------------------------------- c leap = 0 if (mod(iyr2, 4) .eq. 0) leap = 1 c c----------------------------------------------------------------------- c *** increment the time *** c----------------------------------------------------------------------- c it2 = it1 + inc c c----------------------------------------------------------------------- c *** check for day crossing and year crossing *** c----------------------------------------------------------------------- c if (it2 .ge. 86400000) then it2 = it2 - 86400000 idy2 = idy2 + 1 if (leap .eq. 0) then if (idy2 .gt. 365) then idy2 = idy2 - 365 iyr2 = iyr2 + 1 end if else if (idy2 .gt. 366) then idy2 = idy2 - 366 iyr2 = iyr2 + 1 end if end if end if c c----------------------------------------------------------------------- c *** rebuild year and day of year combined variable *** c----------------------------------------------------------------------- c iyd2 = (iyr2 * 1000) + idy2 c c----------------------------------------------------------------------- c----------------------------------------------------------------------- c return end