management_convert_to_daily Subroutine

public subroutine management_convert_to_daily(nval, dailyArray, val, wu_id, iyr, nDaysSim, nbyr)

Uses

  • proc~~management_convert_to_daily~~UsesGraph proc~management_convert_to_daily management_convert_to_daily module~utilities utilities proc~management_convert_to_daily->module~utilities

Arguments

Type IntentOptional AttributesName
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

Calls

proc~~management_convert_to_daily~~CallsGraph proc~management_convert_to_daily management_convert_to_daily proc~days_in_month days_in_month proc~management_convert_to_daily->proc~days_in_month proc~is_leap_year is_leap_year proc~days_in_month->proc~is_leap_year

Called by

proc~~management_convert_to_daily~~CalledByGraph proc~management_convert_to_daily management_convert_to_daily proc~management_read_time_series management_read_time_series proc~management_read_time_series->proc~management_convert_to_daily proc~management_read_wu_inout management_read_wu_inout proc~management_read_wu_inout->proc~management_read_time_series proc~management_initialise management_initialise proc~management_initialise->proc~management_read_wu_inout proc~initialise initialise proc~initialise->proc~management_initialise program~swim swim program~swim->proc~initialise

Contents


Source Code

  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