subroutine reservoir_read_control_file(mb, mhyd) ! reservoir.ctrl
use input, only : read_logical_column, read_real_column, read_integer_column, read_string_column
use input, only : input_count_rows, input_open_file
integer, intent(in) :: mb
integer, intent(in) :: mhyd
integer :: i
integer, dimension(:), allocatable :: act
integer :: fid
fid = input_open_file(trim(reservoir_input_file))
rsv_nReservoirs = input_count_rows(fid, .true.)
allocate(rsv_ResSubbasins(rsv_nReservoirs))
allocate(act(rsv_nReservoirs))
rsv_ResSubbasins = 0
rewind(fid)
call read_integer_column(fid, "subbasins_id", rsv_ResSubbasins, 0)
call reservoir_allocate_reservoir(mb, mhyd)
call read_string_column(fid, "rsv_reservoir_name", rsv_ResNames, "")
call read_real_column(fid, "capac_max", rsv_Capac_Max, 0.0_dp)
rsv_Capac_Max = rsv_Capac_Max * 10 ** 6 ! convert [million m^3] into [m^3]
call read_real_column(fid, "dead_stor", rsv_dead_stor_capac, 0.0_dp)
rsv_dead_stor_capac = rsv_dead_stor_capac * 10 ** 6 ! convert [million m^3] into [m^3]
call read_real_column(fid, "start_fill", rsv_Start_Fill, 0.0_dp)
call read_logical_column(fid, "res_active", rsv_active, .true.)
call read_real_column(fid, "res_activate_thresh", rsv_activate_thresh, 0.0_dp)
call read_real_column(fid, "level_max", rsv_level_max, 0.0_dp)
call read_real_column(fid, "level_min", rsv_level_min, 0.0_dp)
call read_real_column(fid, "level_hpp", rsv_level_hpp, 0.0_dp)
call read_real_column(fid, "cap_hpp", rsv_cap_hpp, 0.0_dp)
call read_real_column(fid, "efficiency", rsv_eff_hpp, 0.0_dp)
call read_real_column(fid, "rsv_loss_seepage", rsv_loss_seepage, 0.0_dp)
call read_real_column(fid, "rsv_gwc", rsv_gwc, 0.0_dp)
call read_real_column(fid, "rsv_evapc", rsv_evapc, 0.0_dp)
call read_integer_column(fid, "rsv_start_year", rsv_start_year, 0)
call read_integer_column(fid, "rsv_start_day", rsv_start_day, 0)
call read_integer_column(fid, "rsv_mngmt", rsv_Mngmt, 0)
call read_real_column(fid, "rsv_shr_withdr", rsv_shr_withdr, 0.0_dp)
close(fid)
! assign rsv_active
do i = 1, rsv_nReservoirs
if (act(i) > 0 ) rsv_active(i) = .true.
end do
end subroutine reservoir_read_control_file