subroutine management_read_time_series(nval, fname, n, wu_id, iyr, ndayssim, nbyr)
use input, only : read_real_column
use utilities, only : open_file
integer, intent(in) :: iyr
integer, intent(in) :: nDaysSim
integer, intent(in) :: nbyr
! number of values in InOut and Q_min
integer, intent(in) :: nval
! length of file name and transfer user ID
integer, intent(in) :: n, wu_id
! number of columns in input files
! file name
character(len = n) :: fname
! first column of input file (indicates the month)
! number of years * 12 monthly values m3 / s
real(dp), dimension(nval) :: InOut, Q_min
integer :: fid
! subbasin number
integer :: sub
sub = TWU(wu_id) % subs
fid = open_file(trim(management_users_input_dir)//'/'//trim(fname))
call read_real_column(fid, "Q_in_out_m3s", InOut)
call read_real_column(fid, "Qmin_m3s", Q_min)
close(fid)
! Assign water user data to: TWU(i)%data and convert to daily if necessary.
call management_convert_to_daily(nval, TWU(wu_id) % data, InOut, wu_id, iyr, nDaysSim, nbyr)
! Assign subbasin's minimal flow data to: (TSub)%Q_min and convert to daily if necessary.
! NOTE: Subbasin (TSub)%Q_min values might be overwritten if the number of water users in a subbasin > 1
! In this case, the values of the last water user are considered!
if (TWU(wu_id) % wu_opt <= 2 .OR. TWU(wu_id) % wu_opt == 4 .AND. sub > 0 ) &
call management_convert_to_daily(nval, wamTSub(sub) % pSub % Q_min, Q_min, wu_id, iyr, nDaysSim, nbyr)
! in case WU is of type irrigation .AND. demand is calculated from plant demand,
! overwrite values of data with 0.
if (TWU(wu_id) % wu_opt == 4 .AND. TWU(wu_id) % irr_opt > 1 ) TWU(wu_id) % data = 0.
RETURN
end subroutine management_read_time_series