13 use mo_kind,
only : i4, dp
14 use mo_message,
only: message, error_message
53 use mo_append,
only : append
64 use mo_string_utils,
only : num2str
68 logical,
intent(in) :: do_reinit
70 logical,
intent(in) :: do_readlatlon
72 logical,
intent(in) :: do_readlcover
74 integer(i4) ::domainid, idomain
80 character(256) :: fname
84 integer(i4),
dimension(:, :),
allocatable :: data_i4_2d
86 integer(i4),
dimension(:, :),
allocatable :: datamatrix_i4
88 logical,
dimension(:, :),
allocatable :: mask_2d
90 logical,
dimension(:, :),
allocatable :: mask_global
92 type(
grid),
pointer :: level0_idomain => null()
105 allocate(datamatrix_i4(count(mask_global), 1))
109 deallocate(datamatrix_i4)
119 if (
domainmeta%L0DataFrom(idomain) < idomain)
then
121 call message(
' Using data of domain ', &
123 trim(adjustl(num2str(domainid))),
'...')
128 call message(
' Reading data for domain: ', trim(adjustl(num2str(domainid))),
' ...')
130 if (do_readlatlon)
then
132 call read_latlon(idomain,
"lon_l0",
"lat_l0",
"level0", level0_idomain)
152 if (ivar .le. 2)
then
156 level0_idomain%nrows, level0_idomain%ncols, level0_idomain%xllcorner, &
157 level0_idomain%yllcorner, level0_idomain%cellsize, data_i4_2d, mask_2d)
160 data_i4_2d = merge(data_i4_2d,
nodata_i4, mask_2d)
163 if (ivar .eq. 3)
then
164 if (
domain_mrm(idomain)%nGauges .ge. 1_i4)
then
168 level0_idomain%nrows, level0_idomain%ncols, level0_idomain%xllcorner, &
169 level0_idomain%yllcorner, level0_idomain%cellsize, data_i4_2d, mask_2d)
172 data_i4_2d = merge(data_i4_2d,
nodata_i4, mask_2d)
183 call append(
l0_facc, pack(data_i4_2d, level0_idomain%mask))
189 call append(
l0_fdir, pack(data_i4_2d, level0_idomain%mask))
195 if (.not. any(data_i4_2d .EQ.
domain_mrm(idomain)%gaugeIdList(igauge)))
then
196 call error_message(
'***ERROR: Gauge ID "', trim(adjustl(num2str(
domain_mrm(idomain)%gaugeIdList(igauge)))), &
197 '" not found in ', raise=.false.)
198 call error_message(
' Gauge location input file: ', &
203 call append(
l0_gaugeloc, pack(data_i4_2d, level0_idomain%mask))
207 if (
domain_mrm(idomain)%nInflowGauges .GT. 0_i4)
then
209 do igauge = 1,
domain_mrm(idomain)%nInflowGauges
211 if (.not. any(data_i4_2d .EQ.
domain_mrm(idomain)%InflowGaugeIdList(igauge)))
then
212 call error_message(
'***ERROR: Inflow Gauge ID "', &
213 trim(adjustl(num2str(
domain_mrm(idomain)%InflowGaugeIdList(igauge)))), &
214 '" not found in ', raise=.false.)
215 call error_message(
' Gauge location input file: ', &
226 if (
allocated(data_i4_2d))
deallocate(data_i4_2d)
227 if (
allocated(mask_2d))
deallocate(mask_2d)
255 use mo_append,
only : paste
264 use mo_string_utils,
only : num2str
268 integer(i4) :: igauge
270 integer(i4) :: idomain
272 integer(i4) :: maxtimesteps
275 character(256) :: fname
277 integer(i4),
dimension(3) :: start_tmp, end_tmp
279 real(dp),
dimension(:),
allocatable :: data_dp_1d
281 logical,
dimension(:),
allocatable :: mask_1d
294 idomain =
gauge%domainId(igauge)
299 fname = trim(adjustl(
gauge%fname(igauge)))
303 data_dp_1d = merge(data_dp_1d,
nodata_dp, mask_1d)
305 deallocate (data_dp_1d)
313 allocate(data_dp_1d(maxval(
simper(:)%julEnd -
simper(:)%julStart + 1)))
321 start_tmp = (/
simper(idomain)%yStart,
simper(idomain)%mStart,
simper(idomain)%dStart/)
328 if (.NOT. (all(mask_1d)))
then
329 call error_message(
'***ERROR: Nodata values in inflow gauge time series. File: ', trim(fname), raise=.false.)
330 call error_message(
' During simulation period from ', num2str(
simper(idomain)%yStart) &
331 ,
' to ', num2str(
simper(idomain)%yEnd))
333 data_dp_1d = merge(data_dp_1d,
nodata_dp, mask_1d)
335 deallocate (data_dp_1d)
369 use mo_append,
only : append
370 use mo_constants,
only : hoursecs
381 integer(i4),
intent(in) :: idomain
385 integer(i4) :: ntimesteps
388 integer(i4) :: nctimestep
391 real(dp),
dimension(:, :, :),
allocatable :: l1_data
393 real(dp),
dimension(:, :),
allocatable :: l1_data_packed
396 if (
timestep .eq. 1) nctimestep = -4
397 if (
timestep .eq. 24) nctimestep = -1
402 ntimesteps =
size(l1_data, 3)
403 allocate(l1_data_packed(
level1(idomain)%nCells, ntimesteps))
404 do tt = 1, ntimesteps
405 l1_data_packed(:, tt) = pack(l1_data(:, :, tt), mask =
level1(idomain)%mask)
415 l1_data_packed = l1_data_packed *
timestep * hoursecs
422 deallocate(l1_data_packed)
481 integer(i4),
intent(in) :: idomain
484 real(dp),
dimension(:,:),
allocatable :: l11_data
485 real(dp),
dimension(:),
allocatable :: l11_data_packed
492 allocate(l11_data_packed(
level11(idomain)%nCells))
493 l11_data_packed(:) = pack(l11_data(:,:), mask=
level11(idomain)%mask)
504 deallocate(l11_data_packed)
533 integer(i4),
dimension(:, :),
intent(INOUT) :: x
579 select case (x(i, j))
Reads spatial data files of ASCII format.
Provides constants commonly used by mHM, mRM and MPR.
real(dp), parameter, public nodata_dp
integer(i4), parameter, public nodata_i4
Provides structures needed by mHM, mRM and/or mpr.
integer(i4), public ntstepday
integer(i4), public opti_function
type(period), dimension(:), allocatable, public simper
integer(i4), public timestep
type(period), dimension(:), allocatable, public evalper
subroutine, public read_lcover
TODO: add description.
subroutine, public read_dem
TODO: add description.
Provides common types needed by mHM, mRM and/or mpr.
Provides structures needed by mHM, mRM and/or mpr.
type(domain_meta), public domainmeta
character(256), dimension(:), allocatable, public dirmorpho
integer(i4), dimension(:, :), allocatable, public l0_lcover
integer(i4), dimension(nprocesses, 3), public processmatrix
type(grid), dimension(:), allocatable, target, public level1
type(grid), dimension(:), allocatable, target, public level0
Provides file names and units for mRM.
character(len=*), parameter file_slope
slope input data file
integer, parameter uslope
Unit for slope input data file.
Provides file names and units for mRM.
integer, parameter ufacc
Unit for flow accumulation input data file.
integer, parameter udischarge
unit for discharge time series
character(len=*), parameter file_gaugeloc
gauge location input data file
character(len=*), parameter file_facc
integer, parameter ufdir
Unit for flow direction input data file.
integer, parameter ugaugeloc
Unit for gauge location input data file.
character(len=*), parameter file_fdir
flow direction input data file
Global variables for mRM only.
type(gaugingstation), public inflowgauge
type(riv_temp_type), public riv_temp_pcs
This is a container for the river temperature routing process (pcs)
integer(i4), dimension(:), allocatable, public l0_fdir
character(256), dimension(:), allocatable, public dirbankfullrunoff
real(dp), dimension(:, :), allocatable, public mrm_runoff
type(gaugingstation), public gauge
type(domaininfo_mrm), dimension(:), allocatable, target, public domain_mrm
integer(i4), public ngaugeslocal
type(grid), dimension(:), allocatable, target, public level11
character(256), public varnametotalrunoff
integer(i4), dimension(:), allocatable, public l0_facc
integer(i4), dimension(:), allocatable, public l0_inflowgaugeloc
character(256), dimension(:), allocatable, public dirtotalrunoff
real(dp), dimension(:, :), allocatable, public l1_total_runoff_in
real(dp), dimension(:), allocatable, public l11_bankfull_runoff_in
integer(i4), public ninflowgaugestotal
integer(i4), dimension(:), allocatable, public l0_gaugeloc
integer(i4), public nmeasperday
character(256), public filenametotalrunoff
subroutine, public mrm_read_bankfull_runoff(idomain)
subroutine, public mrm_read_discharge
Read discharge timeseries from file.
subroutine, public mrm_read_l0_data(do_reinit, do_readlatlon, do_readlcover)
read L0 data from file
subroutine rotate_fdir_variable(x)
TODO: add description.
subroutine, public mrm_read_total_runoff(idomain)
read simulated runoff that is to be routed
reading latitude and longitude coordinates for each domain
subroutine, public read_latlon(ii, lon_var_name, lat_var_name, level_name, level)
reads latitude and longitude coordinates
Reads forcing input data.
subroutine, public read_const_nc(folder, nrows, ncols, varname, data, filename)
Reads time independent forcing input in NetCDF file format.
subroutine, public read_nc(folder, nrows, ncols, varname, mask, data, target_period, lower, upper, nctimestep, filename, nocheck, maskout, is_meteo, bound_error, ntstepforcingday)
Reads forcing input in NetCDF file format.
Reads spatial input data.
Routines to read files containing timeseries data.
subroutine, public read_timeseries(filename, fileunit, periodstart, periodend, optimize, opti_function, data, mask, nmeasperday)
Reads time series in ASCII format.