Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Routing fails when end date is in the month of February of a leap year. #92

Closed
SanchitMinocha opened this issue Feb 21, 2024 · 0 comments · Fixed by #93
Closed

Routing fails when end date is in the month of February of a leap year. #92

SanchitMinocha opened this issue Feb 21, 2024 · 0 comments · Fixed by #93
Assignees
Labels
bug Something isn't working

Comments

@SanchitMinocha
Copy link
Member

VIC-Routing fails to work when end date is in the month of February of a leap year. It is due to the wrong calculation of number of days for which a user wants to run routing using start and end date. This is the below mentioned lines of the routing fortran code:

c     calculate number of days & months in simulation
      M=START_MO
      Y=START_YEAR
      NMONTHS = 0
      NDAY=0
      DO J=START_MO,12*(STOP_YEAR-START_YEAR)+STOP_MO
        IF(M.EQ.2) THEN
           LP=isaleap(Y)
        ELSE 
           LP=0
        ENDIF
        NDAY = NDAY+DAYS_IN_MONTH(M)+LP
        NMONTHS = NMONTHS + 1
        MO(NMONTHS) = M
        YR(NMONTHS) = Y
        M = M + 1
        IF (M .GT. 12) THEN
            M = 1
            Y  = Y + 1
        ENDIF
      END DO
      IF(NDAY.GT.DAYS) THEN
         PRINT*, 'IN ROUT.F RESET DAYS TO ', NDAY
         STOP
      ENDIF
	  NDAY = NDAY-(START_DAY-1)-(DAYS_IN_MONTH(STOP_MO)-STOP_DAY)
      PRINT*,'NDAY = ',NDAY, ' NMONTHS = ',NMONTHS

You can see that DAYS_IN_MONTH(STOP_MO) in second last line of the above snippet should be 29 for leap year of February but it is a constant 28 in the code.

@SanchitMinocha SanchitMinocha self-assigned this Feb 21, 2024
@SanchitMinocha SanchitMinocha added the bug Something isn't working label Feb 21, 2024
pritamd47 added a commit that referenced this issue Feb 21, 2024
Added RAT Tutorial & Bug Fixed (#92) in Routing Code & download link updated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant