Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | nval | |||
real(kind=dp), | intent(inout), | dimension(nDaysSim + 1) | :: | dailyArray | ||
real(kind=dp), | intent(in), | dimension(nval) | :: | val | ||
integer, | intent(in) | :: | wu_id | |||
integer, | intent(in) | :: | iyr | |||
integer, | intent(in) | :: | nDaysSim | |||
integer, | intent(in) | :: | nbyr |
subroutine management_convert_to_daily(nval, dailyarray, val, wu_id, iyr, ndayssim, nbyr)
use utilities, only: days_in_month
integer, intent(in) :: iyr
integer, intent(in) :: nDaysSim
integer, intent(in) :: nbyr
! converts constant monthly or monthly input time series to daily times series (dimension: nDaysSim)
! number of input values in "val"
integer, intent(in) :: nval
! input values
real(dp), dimension(nval), intent(in) :: val
integer, intent(in) :: wu_id
real(dp), dimension(nDaysSim + 1), intent(inout) :: dailyArray
integer :: y, d, ndays
integer, TARGET :: dc, m, mc
integer, POINTER :: pCounter
dc = 0 ! if nval = nDaysSim ( day counter)
m = 0 ! if nval = 12 (month counter)
mc = 0 ! if nval = 12 * nbyr (month counter)
if (nval == 12) pCounter => m
if (nval == nbyr * 12) pCounter => mc
if (nval == nDaysSim) pCounter => dc
! convert monthly time series to daily
do y = 1, nbyr ! loop over years
do m = 1, 12 ! loop over months
ndays = days_in_month(m, y - 1 + iyr) ! function defined in common.f90
mc = mc + 1
do d = 1, ndays
dc = dc + 1
! check if current year is within water users' operational mode period
if (y + iyr - 1 >= TWU(wu_id) % fyr .AND. y + iyr - 1 <= TWU(wu_id) % lyr) then
dailyArray(dc) = val(pCounter)
else
dailyArray(dc) = 0.
end if
end do
end do
end do
end subroutine management_convert_to_daily