time_process_day Subroutine

public subroutine time_process_day(mo1, iday)

Uses

  • proc~~time_process_day~~UsesGraph proc~time_process_day time_process_day module~river river proc~time_process_day->module~river module~subbasin subbasin proc~time_process_day->module~subbasin module~vegetation vegetation proc~time_process_day->module~vegetation module~catchment catchment proc~time_process_day->module~catchment module~output output proc~time_process_day->module~output module~erosion erosion proc~time_process_day->module~erosion module~nutrient nutrient proc~time_process_day->module~nutrient module~crop crop proc~time_process_day->module~crop module~input input proc~time_process_day->module~input module~hydrotope hydrotope proc~time_process_day->module~hydrotope module~reservoir reservoir proc~time_process_day->module~reservoir module~soil soil proc~time_process_day->module~soil module~management management proc~time_process_day->module~management module~evapotranspiration evapotranspiration proc~time_process_day->module~evapotranspiration module~groundwater groundwater proc~time_process_day->module~groundwater module~snow snow proc~time_process_day->module~snow module~utilities utilities module~river->module~utilities module~subbasin->module~utilities module~vegetation->module~utilities module~catchment->module~subbasin module~catchment->module~input module~catchment->module~utilities module~output->module~utilities module~erosion->module~utilities module~nutrient->module~utilities module~crop->module~utilities module~input->module~utilities module~hydrotope->module~utilities module~reservoir->module~utilities module~soil->module~utilities module~management->module~utilities module~evapotranspiration->module~utilities module~groundwater->module~utilities module~snow->module~utilities

Arguments

Type IntentOptional AttributesName
integer, intent(in) :: mo1
integer, intent(in) :: iday

Calls

proc~~time_process_day~~CallsGraph proc~time_process_day time_process_day proc~management_total_demand management_total_demand proc~time_process_day->proc~management_total_demand proc~reservoir_subbasin reservoir_subbasin proc~time_process_day->proc~reservoir_subbasin proc~log_progress log_progress proc~time_process_day->proc~log_progress proc~subbasin_initialise_subbasin subbasin_initialise_subbasin proc~time_process_day->proc~subbasin_initialise_subbasin proc~evapotranspiration_radiation evapotranspiration_radiation proc~time_process_day->proc~evapotranspiration_radiation proc~management_external_supply management_external_supply proc~time_process_day->proc~management_external_supply proc~time_day_length time_day_length proc~time_process_day->proc~time_day_length proc~river_route river_route proc~time_process_day->proc~river_route proc~runsubbasin runsubbasin proc~time_process_day->proc~runsubbasin proc~output_day output_day proc~time_process_day->proc~output_day proc~input_nc_read_climate input_nc_read_climate proc~time_process_day->proc~input_nc_read_climate proc~log_debug log_debug proc~time_process_day->proc~log_debug proc~subbasin_read_climate subbasin_read_climate proc~time_process_day->proc~subbasin_read_climate proc~management_is_transfer_subbasin management_is_transfer_subbasin proc~time_process_day->proc~management_is_transfer_subbasin proc~reservoir_is_operational reservoir_is_operational proc~time_process_day->proc~reservoir_is_operational proc~reservoir_process reservoir_process proc~time_process_day->proc~reservoir_process proc~river_transfer river_transfer proc~time_process_day->proc~river_transfer proc~river_route_add river_route_add proc~time_process_day->proc~river_route_add proc~management_total_demand->proc~management_is_transfer_subbasin proc~management_user_pointer management_user_pointer proc~management_total_demand->proc~management_user_pointer proc~management_subbasin_pointer management_subbasin_pointer proc~management_total_demand->proc~management_subbasin_pointer proc~log_warn log_warn proc~management_total_demand->proc~log_warn proc~management_is_active_period management_is_active_period proc~management_total_demand->proc~management_is_active_period proc~rsv_pol rsv_pol proc~reservoir_subbasin->proc~rsv_pol proc~output_store_subbasin_value output_store_subbasin_value proc~reservoir_subbasin->proc~output_store_subbasin_value proc~output_store_hydrotope_value output_store_hydrotope_value proc~reservoir_subbasin->proc~output_store_hydrotope_value proc~reservoir_get reservoir_get proc~reservoir_subbasin->proc~reservoir_get proc~log_format_message log_format_message proc~log_progress->proc~log_format_message proc~log_write log_write proc~log_progress->proc~log_write proc~evapotranspiration_radiation->proc~log_warn proc~management_external_supply->proc~management_is_transfer_subbasin proc~management_external_supply->proc~management_user_pointer proc~management_external_supply->proc~management_subbasin_pointer proc~management_external_supply->proc~log_warn proc~management_external_supply->proc~management_is_active_period proc~river_route_phosphorus river_route_phosphorus proc~river_route->proc~river_route_phosphorus proc~river_route_nitrate river_route_nitrate proc~river_route->proc~river_route_nitrate proc~river_erosion_enritchment_ratio river_erosion_enritchment_ratio proc~river_route->proc~river_erosion_enritchment_ratio proc~river_route_erosion river_route_erosion proc~river_route->proc~river_route_erosion proc~river_transmission_loss river_transmission_loss proc~river_route->proc~river_transmission_loss proc~river_muskingum_routing river_muskingum_routing proc~river_route->proc~river_muskingum_routing proc~runsubbasin->proc~subbasin_initialise_subbasin proc~runsubbasin->proc~management_is_transfer_subbasin proc~soil_curve_number_peak_runoff soil_curve_number_peak_runoff proc~runsubbasin->proc~soil_curve_number_peak_runoff proc~erosion_organic_nitrate_loss erosion_organic_nitrate_loss proc~runsubbasin->proc~erosion_organic_nitrate_loss proc~soil_curve_number_alpha soil_curve_number_alpha proc~runsubbasin->proc~soil_curve_number_alpha proc~erosion_phosphorus_loss erosion_phosphorus_loss proc~runsubbasin->proc~erosion_phosphorus_loss proc~snow_degree_day_melting snow_degree_day_melting proc~runsubbasin->proc~snow_degree_day_melting proc~subbasin_flow_travel_time subbasin_flow_travel_time proc~runsubbasin->proc~subbasin_flow_travel_time proc~runsubbasin->proc~output_store_subbasin_value proc~erosion_enritchment_ratio erosion_enritchment_ratio proc~runsubbasin->proc~erosion_enritchment_ratio proc~groundwater_process groundwater_process proc~runsubbasin->proc~groundwater_process proc~landuse_is_forest landuse_is_forest proc~runsubbasin->proc~landuse_is_forest proc~runsubbasin->proc~management_subbasin_pointer proc~snow_process snow_process proc~runsubbasin->proc~snow_process proc~management_transfer_out management_transfer_out proc~runsubbasin->proc~management_transfer_out proc~soil_curve_transmission_losses soil_curve_transmission_losses proc~runsubbasin->proc~soil_curve_transmission_losses proc~hydrotope_process hydrotope_process proc~runsubbasin->proc~hydrotope_process proc~runsubbasin->proc~output_store_hydrotope_value proc~landuse_is_cropland landuse_is_cropland proc~runsubbasin->proc~landuse_is_cropland proc~snow_initialise_subbasin snow_initialise_subbasin proc~runsubbasin->proc~snow_initialise_subbasin proc~crop_yield_output crop_yield_output proc~runsubbasin->proc~crop_yield_output proc~erosion_soil_loss erosion_soil_loss proc~runsubbasin->proc~erosion_soil_loss proc~output_write_daily output_write_daily proc~output_day->proc~output_write_daily proc~output_hydrotope_to_catchment output_hydrotope_to_catchment proc~output_day->proc~output_hydrotope_to_catchment proc~output_hydrotope_to_subbasin output_hydrotope_to_subbasin proc~output_day->proc~output_hydrotope_to_subbasin proc~output_subbasin_to_catchment output_subbasin_to_catchment proc~output_day->proc~output_subbasin_to_catchment proc~input_nc_read_climate->proc~log_debug proc~input_nc_weighted_mean input_nc_weighted_mean proc~input_nc_read_climate->proc~input_nc_weighted_mean proc~log_message log_message proc~log_debug->proc~log_message proc~read_real_column read_real_column proc~subbasin_read_climate->proc~read_real_column proc~reservoir_is_operational->proc~reservoir_get proc~log_error log_error proc~reservoir_process->proc~log_error proc~et_turc et_turc proc~reservoir_process->proc~et_turc proc~reservoir_process->proc~rsv_pol proc~reservoir_is_full_dead_storage reservoir_is_full_dead_storage proc~reservoir_process->proc~reservoir_is_full_dead_storage proc~reservoir_process->proc~reservoir_get proc~river_route_add->proc~management_is_transfer_subbasin proc~output_store_subbasin_values output_store_subbasin_values proc~river_route_add->proc~output_store_subbasin_values proc~river_route_add->proc~management_subbasin_pointer proc~river_route_add->proc~management_transfer_out proc~log_error->proc~log_message proc~colourise colourise proc~log_format_message->proc~colourise proc~date_time_str date_time_str proc~log_format_message->proc~date_time_str proc~output_write_time output_write_time proc~output_write_daily->proc~output_write_time proc~gamma_distribution gamma_distribution proc~soil_curve_number_alpha->proc~gamma_distribution proc~management_user_pointer->proc~log_error proc~log_message->proc~log_format_message proc~log_message->proc~log_write proc~to_string to_string proc~log_write->proc~to_string proc~read_real_column->proc~log_error proc~input_error_column_not_found input_error_column_not_found proc~read_real_column->proc~input_error_column_not_found proc~input_type_conversion_error input_type_conversion_error proc~read_real_column->proc~input_type_conversion_error proc~check_range check_range proc~read_real_column->proc~check_range proc~read_csv_item read_csv_item proc~read_real_column->proc~read_csv_item proc~move_lines move_lines proc~read_real_column->proc~move_lines proc~header_column_index header_column_index proc~read_real_column->proc~header_column_index proc~landuse_index landuse_index proc~landuse_is_forest->proc~landuse_index proc~snow_process->proc~output_store_hydrotope_value proc~snow_glacier_melt snow_glacier_melt proc~snow_process->proc~snow_glacier_melt proc~snow_melting snow_melting proc~snow_process->proc~snow_melting proc~log_warn->proc~log_message proc~management_transfer_out->proc~management_user_pointer proc~management_transfer_out->proc~management_subbasin_pointer proc~management_transfer_out->proc~log_warn proc~management_transfer_out->proc~management_is_active_period proc~hydrotope_process->proc~management_is_transfer_subbasin proc~hydrotope_process->proc~management_user_pointer proc~hydrotope_process->proc~landuse_is_forest proc~hydrotope_process->proc~management_subbasin_pointer proc~hydrotope_process->proc~landuse_is_cropland proc~hydrotope_process->proc~management_is_active_period proc~soil_process soil_process proc~hydrotope_process->proc~soil_process proc~soil_curve_number soil_curve_number proc~hydrotope_process->proc~soil_curve_number proc~landuse_is_natural_vegetation landuse_is_natural_vegetation proc~hydrotope_process->proc~landuse_is_natural_vegetation proc~soil_temperature soil_temperature proc~hydrotope_process->proc~soil_temperature proc~nutrient_fertilisation nutrient_fertilisation proc~hydrotope_process->proc~nutrient_fertilisation proc~soil_curve_number_runoff soil_curve_number_runoff proc~hydrotope_process->proc~soil_curve_number_runoff proc~vegetation_store_output vegetation_store_output proc~hydrotope_process->proc~vegetation_store_output proc~nutrient_leaching nutrient_leaching proc~hydrotope_process->proc~nutrient_leaching amax1 amax1 proc~hydrotope_process->amax1 proc~evapotranspiration_process evapotranspiration_process proc~hydrotope_process->proc~evapotranspiration_process proc~vegetation_process vegetation_process proc~hydrotope_process->proc~vegetation_process proc~crop_initialise_hydrotope crop_initialise_hydrotope proc~hydrotope_process->proc~crop_initialise_hydrotope proc~hydrotope_process->proc~landuse_index proc~erosion_cklsp_factor erosion_cklsp_factor proc~hydrotope_process->proc~erosion_cklsp_factor proc~crop_process crop_process proc~hydrotope_process->proc~crop_process proc~river_mannings_discharge river_mannings_discharge proc~river_transmission_loss->proc~river_mannings_discharge proc~landuse_is_cropland->proc~landuse_index proc~river_muskingum_routing->proc~log_warn proc~input_nc_check_error input_nc_check_error proc~input_nc_weighted_mean->proc~input_nc_check_error nf90_get_var nf90_get_var proc~input_nc_weighted_mean->nf90_get_var proc~soil_percolation soil_percolation proc~soil_process->proc~soil_percolation proc~input_error_column_not_found->proc~log_error proc~input_nc_check_error->proc~log_error nf90_strerror nf90_strerror proc~input_nc_check_error->nf90_strerror proc~input_type_conversion_error->proc~log_error proc~string_index string_index proc~colourise->proc~string_index proc~landuse_is_natural_vegetation->proc~landuse_index proc~check_range->proc~log_error proc~check_range->proc~log_warn proc~out_of_range_error out_of_range_error proc~check_range->proc~out_of_range_error proc~random_n random_n proc~gamma_distribution->proc~random_n proc~vegetation_store_output->proc~output_store_hydrotope_value proc~nutrient_nitrate_cycle nutrient_nitrate_cycle proc~nutrient_leaching->proc~nutrient_nitrate_cycle proc~nutrient_nitrate_leaching nutrient_nitrate_leaching proc~nutrient_leaching->proc~nutrient_nitrate_leaching proc~nutrient_phosphorus_cycle nutrient_phosphorus_cycle proc~nutrient_leaching->proc~nutrient_phosphorus_cycle proc~nutrient_phosphorus_loss nutrient_phosphorus_loss proc~nutrient_leaching->proc~nutrient_phosphorus_loss proc~vegetation_water_stress vegetation_water_stress proc~vegetation_process->proc~vegetation_water_stress amin1 amin1 proc~vegetation_process->amin1 proc~nutrient_phosphorus_uptake nutrient_phosphorus_uptake proc~vegetation_process->proc~nutrient_phosphorus_uptake proc~nutrient_nitrate_uptake nutrient_nitrate_uptake proc~vegetation_process->proc~nutrient_nitrate_uptake proc~vegetation_temperature_stress vegetation_temperature_stress proc~vegetation_process->proc~vegetation_temperature_stress proc~output_write_space_time_csv output_write_space_time_csv proc~output_write_time->proc~output_write_space_time_csv proc~output_array_to_bin output_array_to_bin proc~output_write_time->proc~output_array_to_bin proc~landuse_index->proc~log_error proc~header_column_index->proc~input_error_column_not_found proc~header_column_index->proc~move_lines proc~crop_operation crop_operation proc~crop_process->proc~crop_operation proc~crop_process->proc~vegetation_water_stress proc~crop_growth crop_growth proc~crop_process->proc~crop_growth proc~nutrient_nitrate_cycle->amin1 proc~crop_operation->proc~output_store_hydrotope_value proc~vegetation_water_stress->proc~management_is_transfer_subbasin proc~vegetation_water_stress->proc~management_user_pointer proc~vegetation_water_stress->proc~management_subbasin_pointer proc~vegetation_water_stress->proc~landuse_is_cropland proc~vegetation_water_stress->proc~management_is_active_period proc~wam_correct_irrigationdemand wam_correct_irrigationdemand proc~vegetation_water_stress->proc~wam_correct_irrigationdemand proc~out_of_range_error->proc~log_error proc~out_of_range_error->proc~to_string proc~crop_growth->amin1 proc~crop_growth->proc~nutrient_phosphorus_uptake proc~crop_growth->proc~nutrient_nitrate_uptake proc~crop_growth->proc~vegetation_temperature_stress proc~vegetation_s_curve vegetation_s_curve proc~crop_growth->proc~vegetation_s_curve proc~vegetation_adjust_energy_ratio vegetation_adjust_energy_ratio proc~crop_growth->proc~vegetation_adjust_energy_ratio proc~nutrient_phosphorus_cycle->amin1 proc~output_write_space_time_csv->proc~log_error proc~output_array_to_csv output_array_to_csv proc~output_write_space_time_csv->proc~output_array_to_csv proc~vegetation_nutrient_stress vegetation_nutrient_stress proc~nutrient_phosphorus_uptake->proc~vegetation_nutrient_stress float float proc~random_n->float proc~nutrient_nitrate_uptake->proc~vegetation_nutrient_stress proc~vegetation_temperature_stress->proc~landuse_is_cropland proc~output_array_to_csv->proc~log_error

Called by

proc~~time_process_day~~CalledByGraph proc~time_process_day time_process_day proc~time_process_month time_process_month proc~time_process_month->proc~time_process_day proc~time_process_years time_process_years proc~time_process_years->proc~time_process_month program~swim swim program~swim->proc~time_process_years

Contents

Source Code


Source Code

  subroutine time_process_day(mo1, iday)
    !**** CALLED IN MAIN
    !**** THIS SUBROUTINE COMPUTES ONE DAY
    !****
    !**** CALLED: IN MAIN
    !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    !     PARAMETERS & VARIABLES
    !
    !     ida - current day
    !     ieap - index for GRASS output in subbasin (yield)
    !     ieapu - index for GRASS output in subbasin (annual sums)
    !     xxswind - soil water index for basin
    !     xwysb - water yield for basin
    !     xnflow() - N flows for a chosen hydrotop
    !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    use catchment, only : bSubcatch, da, da9, subcatch_id, wy
    use crop, only : icc, mfe
    use erosion, only : &
      chc, &
      chxk, &
      conn, &
      cpp, &
      er, &
      xcklsp, &
      xnorg, &
      xnorgp, &
      xporg, &
      xpsedp
    use evapotranspiration, only : &
      canev, &
      ecal, &
      evapotranspiration_radiation, &
      humi, &
      omega, &
      pit, &
      ra, &
      radiation_switch, &
      snoev, &
      tmn, &
      ylc, &
      yls
    use groundwater, only : &
      additionalGwUptake, &
      revapst, &
      xet
    use hydrotope, only : smm
#ifdef with_netcdf
    use input, only : input_nc_read_climate
#endif
    use management, only : &
      bWAM_Module, &
      management_external_supply, &
      management_is_transfer_subbasin, &
      management_total_demand, &
      wam_d, &
      wam_y
    use nutrient, only : &
      degNgrw, &
      degNsub, &
      degNsur, &
      degPsur, &
      retNgrw, &
      retNsub, &
      retNsur, &
      retPsur, &
      xnflow, &
      yon, &
      yph
    use output, only : &
      area_tot_glacier, &
      area_tot_snow, &
      depth_ave_glacier, &
      depth_ave_snow, &
      ieapu, &
      nsb, &
      nvsub, &
      output_day
    use reservoir, only : &
      bRsvModule, &
      bRsvHydrograph, &
      reservoir_is_operational, &
      reservoir_process, &
      reservoir_subbasin, &
      rsvSubbasin, &
      xwysb, &
      xxswind
    use river, only : &
      accf, &
      river_route, &
      river_route_add, &
      river_transfer, &
      varoute
    use snow, only : &
      bSnowModule, &
      sml, &
      snowVal, &
      tmx, &
      ieapg
    use soil, only : pr, psp, rtn, xqd
    use subbasin, only : &
      aff, &
      dart, &
      flu, &
      icodes, &
      ihouts, &
      inum1s, &
      inum2s, &
      mb, &
      mhyd, &
      neap, &
      nqobs, &
      obs_discharge, &
      obssb, &
      precip, &
      qtl, &
      runs, &
      runsubbasin, &
      sbar, &
      sbp, &
      sda, &
      smq, &
      smsq, &
      sub, &
      subbasin_initialise_subbasin, &
      subbasin_read_climate, &
      subouthyd, &
      subp, &
      sumcn, &
      susb, &
      tx, &
      wysb, &
      xeo, &
      xpercn, &
      xqi, &
      xsep, &
      xssf, &
      xssfn, &
      xswind, &
      xyno3
    use subbasin, only : &
      xysp, &
      yd, &
      bRunoffdat
    use vegetation, only : daylen

    integer, intent(in) :: mo1, iday

    integer ii, iik, k
    integer inum1, inum2
    integer idum
    integer icode, icodep, ihout
    logical :: bRoute = .true. !#### RESERVOIR MODULE ####


    !ls** compute day number in the year
    if (mo1 .gt. 2) then
      ida = iday + nc(mo1) - nt
    else
      ida = iday + nc(mo1)
    endif

    daycounter = daycounter + 1

    area_tot_snow = 0.
    depth_ave_snow = 0.
    !###########################
    !#### SNOW MODULE ####
    !###########################
    if (bSnowModule) then
      ieapg = 1
      area_tot_glacier = 0.
      depth_ave_glacier = 0.
    end if
    !###########################

    xxswind = 0.
    xwysb = 0.
    ieap = 1
    ieapu = 1
    do ii = 1, 20
      xnflow(ii) = 0.
    end do
    do k = 1, nsb
      sub(k) = 0.
    end do

!#### CALL (NC_) READCLI - to read climate data daily
#ifdef with_netcdf
    call input_nc_read_climate(flu, humi, mb, ra, subp, tmn, tmx, tx)
#else
    call subbasin_read_climate(humi, mb, ra, subp, tmn, tmx, tx)
#endif
    call time_day_length(daylen, ida, mb, pit, ylc, yls)
    !### VA
    !*********** For Radiation Data generated by Hargreaves Samani
    if (radiation_switch > 0) then
      call evapotranspiration_radiation(ida, mb, tmx)
    end if
    !### VA

    !ls ndmo(mo) = ndmo(mo) + 1
    !ls dtot = dtot + 1.
    snoev = 0.
    pr = 0.

    !########################################################### START ROUTING
    !#### CALL subbasin, route, transfer, add
    do idum = 1, mhyd
      icode = icodes(idum)
      ihout = ihouts(idum)
      inum1 = inum1s(idum)
      inum2 = inum2s(idum)
      if (icode .gt. 0) then
        select case (icode)
          case (1) ! SUBBASIN command

            !#################################
            !#### WATER MANAGEMENT MODULE ####
            !#################################
            if (bWAM_Module) then
              if (ihout == 1) then
                wam_y(daycounter) = iyr
                wam_d(daycounter) = ida
              end if

              if (management_is_transfer_subbasin(inum1) ) then

                ! Summarise total inflow only from external sources and transmission losses
                ! Current day inflows from external sources are added to subbasins %inflow
                ! NOTE: Adding to routing variables sda(2, j) takes place in subroutine subbasin
                call management_external_supply(inum1, daycounter, ida, iyr)

                ! calculate total water demand of water user(s)
                ! NOTE: nothing is removed here, just computation of total demand
                call management_total_demand(inum1, daycounter, ida, iyr)

                ! Depending on whether the subbasin is a headwater or not
                ! inputs and outputs are added/removed in subroutines:
                ! 'subbasin' or 'add'

              end if
            end if
            !###########################

            !###########################
            !#### RESERVOIR MODULE ####
            !###########################
            if (bRsvModule) then
              ! if actual subbasin is reservoir skip subbasin call
              ! TODO: include res_active function
              if (rsvSubbasin(inum1) == 0 ) then
                if (subcatch_id(inum1) .ne. 0) then
                  !write(*,*) 'Inside swim.f95::: olai(1, 1) = ', olai(1, 1)
                  call runsubbasin(ihout, inum1, bSubcatch, da, da9, daycounter, ida, ieap, iy, iyr, mo, nbyr, nd)
                  !write(*,*) 'Inside swim.f95::: olai(1, 1) After = ', olai(1,1)
                end if
              else
                if (reservoir_is_operational(iyr, ida, inum1) ) then
                  call subbasin_initialise_subbasin(canev, sml, xcklsp, xet, xnorg, xnorgp, xporg, xpsedp, xqd, yon, yph)
                  call reservoir_subbasin(inum1, da, aff, dart, flu, neap, precip, qtl, sbp, sda, smq, smsq, snowval, sub, subp, sumcn, susb, tx, varoute, wysb, xeo, xpercn, xqi, xsep, xssf, xssfn, xswind, xyno3, xysp, yd, yon, yph)
                else if (subcatch_id(inum1) .ne. 0) then
                  call runsubbasin(ihout, inum1, bSubcatch, da, da9, daycounter, ida, ieap, iy, iyr, mo, nbyr, nd)
                end if
              end if
            ! calculate subbasin but only if subbasin is listed in subcatch.def
            ! for convenient subsetting of model eg. by subcatchment
            else if (subcatch_id(inum1) .ne. 0) then
              call runsubbasin(ihout, inum1, bSubcatch, da, da9, daycounter, ida, ieap, iy, iyr, mo, nbyr, nd)
            end if
            !###########################

          case (2) ! ROUTE command
            bRoute = .true.
            !###########################
            !#### RESERVOIR MODULE ####
            !###########################
            if (bRsvModule) then
              ! If inum1 is a reservoir subbasin then...
              if (bRsvHydrograph(ihout) ) then
                ! reservoir input is stored in varoute(2, inum2) and varoute(8, inum2)
                ! skip routing
                ! modify varoute(2, inum1), varoute(8, inum1) in reservoir functions
                ! DO NOT call route(icode, ihout, inum1, inum2)
                if (reservoir_is_operational(iyr, ida, inum1) ) then
                  call reservoir_process(ihout, inum1, inum2, ecal, humi, ida, iyr, mo, nc, omega, ra, subp, tx, varoute)
                  bRoute = .false.
                end if
              else
                bRoute = .true.
                !call route(icode, ihout, inum1, inum2)
              end if
            end if
            !###########################

            if (bRoute) then
              call river_route(ihout, inum1, inum2, chc, chxk, conn, cpp, da9, dart, er, flu, ida, iy, iyr, revapst, runs, sbar, sub, susb, xysp, yd, yon, yph)
            end if

          case (3) ! not implemented
            ! do nothing

          case (4) ! not implemented
            ihout = ihouts (idum - 1)
            icodep = icodes (idum - 1)
            call river_transfer() ! not implemented

          case (5) ! ADD command
            call river_route_add(bRunoffdat, ihout, inum1, inum2, additionalGwUptake, bWAM_Module, daycounter, ida, iyr, mb, nqobs, obssb, obs_discharge, runs, subouthyd, inum1s, bRsvModule, reservoir_is_operational(iyr, ida, inum2), rsvSubbasin)

          case default ! do nothing
        end select
      end if ! (icode .gt. 0)
    end do ! do idum = 1, mhyd
    !########################################################### END ROUTING

    !**** Calc wy - water yield
    wy = sub(8) + sub(9) - sub(10) + sub(15) + 1.e-20

    !**** Correction - sediment yield
    sub(21) = sub(21) / da9

    !**** Calculation of monthly sums
    do iik = 1, nvsub
      smm(iik) = smm(iik) + sub(iik)
    end do

    !**** Calc monthly water discharge
    if (bRunoffdat) accf(7) = accf(7) + obs_discharge(ida, 1)
    accf(8) = accf(8) + runs(ida)

    call output_day(iyr, mo1, iday)

    call log_progress('time_process_day', ida, nd)

    call log_debug("time_process_day", "Completed day =", int=iday)
    return
  end subroutine time_process_day