14 use mo_kind,
only : i4, dp
15 use mo_message,
only: message, error_message
52 subroutine mrm_read_config(file_namelist, unamelist, file_namelist_param, unamelist_param, do_message)
66 use mo_nml,
only : close_nml, open_nml, position_nml
67 use mo_string_utils,
only : num2str
71 character(*),
intent(in) :: file_namelist, file_namelist_param
73 integer,
intent(in) :: unamelist, unamelist_param
76 logical,
intent(in) :: do_message
78 integer(i4),
dimension(maxNoDomains) :: nogauges_domain
80 integer(i4),
dimension(maxNoDomains, maxNoGauges) :: gauge_id
82 character(256),
dimension(maxNoDomains, maxNoGauges) :: gauge_filename
84 integer(i4),
dimension(maxNoDomains) :: noinflowgauges_domain
86 integer(i4),
dimension(maxNoDomains, maxNoGauges) :: inflowgauge_id
88 character(256),
dimension(maxNoDomains, maxNoGauges) :: inflowgauge_filename
90 logical,
dimension(maxNoDomains, maxNoGauges) :: inflowgauge_headwater
92 integer(i4) :: domainid, idomain
98 character(256),
dimension(maxNoDomains) :: dir_gauges
100 character(256),
dimension(maxNoDomains) :: dir_total_runoff
102 character(256),
dimension(maxNoDomains) :: dir_bankfull_runoff
104 logical :: file_exists
113 namelist /directories_mrm/ dir_gauges, dir_total_runoff, dir_bankfull_runoff
114 namelist /evaluation_gauges/
ngaugestotal, nogauges_domain, gauge_id, gauge_filename
117 inflowgauge_filename, inflowgauge_headwater
119 namelist /nloutputresults/ &
144 call open_nml(file_namelist, unamelist, quiet = .true.)
149 call position_nml(
'mainconfig_mrm', unamelist)
150 read(unamelist, nml = mainconfig_mrm)
155 call position_nml(
'directories_mRM', unamelist)
156 read(unamelist, nml = directories_mrm)
161 dirgauges(idomain) = dir_gauges(domainid)
169 call position_nml(
'evaluation_gauges', unamelist)
170 read(unamelist, nml = evaluation_gauges)
173 call error_message(
'***ERROR: ', trim(file_namelist),
': Total number of evaluation gauges is restricted to', &
175 call error_message(
' Error occured in namlist: evaluation_gauges')
200 allocate(domain_mrm_idomain%gaugeIdList(maxval(nogauges_domain(:))))
201 domain_mrm_idomain%gaugeIdList =
nodata_i4
202 allocate(domain_mrm_idomain%gaugeIndexList(maxval(nogauges_domain(:))))
203 domain_mrm_idomain%gaugeIndexList =
nodata_i4
204 allocate(domain_mrm_idomain%gaugeNodeList(maxval(nogauges_domain(:))))
205 domain_mrm_idomain%gaugeNodeList =
nodata_i4
207 if (nogauges_domain(domainid) .EQ.
nodata_i4)
then
208 call error_message(
'***ERROR: ', trim(file_namelist),
': Number of evaluation gauges for subdomain ', &
209 trim(adjustl(num2str(domainid))),
' is not defined!', raise=.false.)
210 call error_message(
' Error occured in namelist: evaluation_gauges')
213 domain_mrm_idomain%nGauges = nogauges_domain(domainid)
215 do igauge = 1, nogauges_domain(domainid)
217 if (gauge_id(domainid, igauge) .EQ.
nodata_i4)
then
218 call error_message(
'***ERROR: ', trim(file_namelist),
': ID ', &
219 trim(adjustl(num2str(gauge_id(domainid, igauge)))),
' of evaluation gauge ', &
220 trim(adjustl(num2str(igauge))),
' for subdomain ', &
221 trim(adjustl(num2str(idomain))),
' is not defined!', raise=.false.)
222 call error_message(
' Error occured in namelist: evaluation_gauges')
223 else if (trim(gauge_filename(domainid, igauge)) .EQ. trim(num2str(
nodata_i4)))
then
224 call error_message(
'***ERROR: ', trim(file_namelist),
': Filename of evaluation gauge ', &
225 trim(adjustl(num2str(igauge))),
' for subdomain ', &
226 trim(adjustl(num2str(idomain))),
' is not defined!', raise=.false.)
227 call error_message(
' Error occured in namelist: evaluation_gauges')
231 gauge%domainId(idx) = idomain
232 gauge%gaugeId(idx) = gauge_id(domainid, igauge)
233 gauge%fname(idx) = trim(
dirgauges(idomain)) // trim(gauge_filename(domainid, igauge))
234 domain_mrm_idomain%gaugeIdList(igauge) = gauge_id(domainid, igauge)
235 domain_mrm_idomain%gaugeIndexList(igauge) = idx
240 call error_message(
'***ERROR: ', trim(file_namelist),
': Total number of evaluation gauges (', &
242 ') different from sum of gauges in subdomains (', trim(adjustl(num2str(idx))),
')!', raise=.false.)
243 call error_message(
' Error occured in namelist: evaluation_gauges')
251 noinflowgauges_domain = 0
253 inflowgauge_filename = num2str(
nodata_i4)
255 call position_nml(
'inflow_gauges', unamelist)
256 read(unamelist, nml = inflow_gauges)
259 call error_message(
'***ERROR: ', trim(file_namelist), &
260 ':read_gauge_lut: Total number of inflow gauges is restricted to', num2str(
maxnogauges), raise=.false.)
261 call error_message(
' Error occured in namlist: inflow_gauges')
278 allocate(domain_mrm_idomain%InflowGaugeIdList (max(1, maxval(noinflowgauges_domain(:)))))
279 allocate(domain_mrm_idomain%InflowGaugeHeadwater (max(1, maxval(noinflowgauges_domain(:)))))
280 allocate(domain_mrm_idomain%InflowGaugeIndexList (max(1, maxval(noinflowgauges_domain(:)))))
281 allocate(domain_mrm_idomain%InflowGaugeNodeList (max(1, maxval(noinflowgauges_domain(:)))))
283 domain_mrm_idomain%nInflowGauges = 0
284 domain_mrm_idomain%InflowGaugeIdList =
nodata_i4
285 domain_mrm_idomain%InflowGaugeHeadwater = .false.
286 domain_mrm_idomain%InflowGaugeIndexList =
nodata_i4
287 domain_mrm_idomain%InflowGaugeNodeList =
nodata_i4
289 if (noinflowgauges_domain(domainid) .EQ.
nodata_i4)
then
290 noinflowgauges_domain(domainid) = 0
293 domain_mrm_idomain%nInflowGauges = noinflowgauges_domain(domainid)
295 do igauge = 1, noinflowgauges_domain(domainid)
297 if (inflowgauge_id(domainid, igauge) .EQ.
nodata_i4)
then
298 call error_message(
'***ERROR: ', trim(file_namelist),
':ID of inflow gauge ', &
299 trim(adjustl(num2str(igauge))),
' for subdomain ', &
300 trim(adjustl(num2str(idomain))),
' is not defined!', raise=.false.)
301 call error_message(
' Error occured in namlist: inflow_gauges')
302 else if (trim(inflowgauge_filename(domainid, igauge)) .EQ. trim(num2str(
nodata_i4)))
then
303 call error_message(
'***ERROR: ', trim(file_namelist),
':Filename of inflow gauge ', &
304 trim(adjustl(num2str(igauge))),
' for subdomain ', &
305 trim(adjustl(num2str(idomain))),
' is not defined!', raise=.false.)
306 call error_message(
' Error occured in namlist: inflow_gauges')
311 inflowgauge%gaugeId(idx) = inflowgauge_id(domainid, igauge)
312 inflowgauge%fname(idx) = trim(
dirgauges(domainid)) // trim(inflowgauge_filename(domainid, igauge))
313 domain_mrm_idomain%InflowGaugeIdList(igauge) = inflowgauge_id(domainid, igauge)
314 domain_mrm_idomain%InflowGaugeHeadwater(igauge) = inflowgauge_headwater(domainid, igauge)
315 domain_mrm_idomain%InflowGaugeIndexList(igauge) = idx
320 call error_message(
'***ERROR: ', trim(file_namelist),
': Total number of inflow gauges (', &
322 ') different from sum of inflow gauges in subdomains (', trim(adjustl(num2str(idx))),
')!', raise=.false.)
323 call error_message(
' Error occured in namlist: inflow_gauges')
328 call close_nml(unamelist)
344 if (file_exists)
then
347 call position_nml(
'NLoutputResults',
udefoutput)
352 call message(
'No file specifying mRM output fluxes exists')
358 call message(
' Following output will be written:')
361 call message(
' NetCDF output precision: double')
363 call message(
' NetCDF output precision: single')
367 call message(
' NetCDF output time reference point: start of time interval')
369 call message(
' NetCDF output time reference point: center of time interval')
371 call message(
' NetCDF output time reference point: end of time interval')
373 call message(
' FLUXES:')
375 call message(
' routed streamflow (L11_qMod) [m3 s-1]')
378 call message(
' river temperature (RivTemp) [deg C]')
381 call message(
' river head (river_head) [m]')
386 call message(
' FINISHED reading config')
419 use mo_nml,
only : close_nml, open_nml, position_nml
424 integer(i4),
intent(in) :: processCase
427 character(*),
intent(in) :: file_namelist_param
430 integer(i4),
intent(in) :: unamelist_param
433 integer(i4) :: start_index
435 real(dp),
dimension(nColPars) :: muskingumTravelTime_constant
437 real(dp),
dimension(nColPars) :: muskingumTravelTime_riverLength
439 real(dp),
dimension(nColPars) :: muskingumTravelTime_riverSlope
441 real(dp),
dimension(nColPars) :: muskingumTravelTime_impervious
443 real(dp),
dimension(nColPars) :: muskingumAttenuation_riverSlope
445 real(dp),
dimension(nColPars) :: streamflow_celerity
446 real(dp),
dimension(nColPars) :: slope_factor
448 namelist /routing1/ muskingumtraveltime_constant, muskingumtraveltime_riverlength, &
449 muskingumtraveltime_riverslope, muskingumtraveltime_impervious, muskingumattenuation_riverslope
450 namelist /routing2/ streamflow_celerity
451 namelist /routing3/ slope_factor
453 call open_nml(file_namelist_param, unamelist_param, quiet = .true.)
455 if (processcase .eq. 1_i4)
then
456 call position_nml(
'routing1', unamelist_param)
457 read(unamelist_param, nml = routing1)
458 else if (processcase .eq. 2_i4)
then
459 call position_nml(
'routing2', unamelist_param)
460 read(unamelist_param, nml = routing2)
461 else if (processcase .eq. 3_i4)
then
462 call position_nml(
'routing3', unamelist_param)
463 read(unamelist_param, nml = routing3)
470 if (processcase .eq. 1_i4)
then
483 'muskingumTravelTime_constant ', &
484 'muskingumTravelTime_riverLength', &
485 'muskingumTravelTime_riverSlope ', &
486 'muskingumTravelTime_impervious ', &
487 'muskingumAttenuation_riverSlope'/)
489 else if (processcase .eq. 2_i4)
then
497 'streamflow_celerity'/)
499 else if (processcase .eq. 3_i4)
then
513 call error_message(
'***ERROR: parameter in routing namelist out of bound in ', &
514 trim(adjustl(file_namelist_param)))
517 call close_nml(unamelist_param)
Provides constants commonly used by mHM, mRM and MPR.
integer(i4), parameter, public ncolpars
integer(i4), parameter, public maxnodomains
integer(i4), parameter, public nodata_i4
Provides small utility functions used by multiple parts of the code (mHM, mRM, MPR)
logical function, public in_bound(params)
TODO: add description.
Reading of main model configurations.
subroutine, public common_check_resolution(do_message, allow_subgrid_routing)
check resolution
Provides structures needed by mHM, mRM and/or mpr.
real(dp), dimension(:, :), allocatable, target, public global_parameters
character(256), dimension(:), allocatable, public global_parameters_name
type(domain_meta), public domainmeta
integer(i4), dimension(nprocesses, 3), public processmatrix
Provides mRM specific constants.
integer(i4), parameter, public maxnogauges
Provides file names and units for mRM.
character(:), allocatable file_defoutput
file defining mRM's outputs
integer, parameter udefoutput
Unit for file defining mRM's outputs.
Global variables for mRM only.
type(gaugingstation), public inflowgauge
logical output_double_precision_mrm
float precision in output nc files
character(256), dimension(:), allocatable, public dirbankfullrunoff
character(256), dimension(:), allocatable, public dirgauges
integer(i4) output_time_reference_mrm
time reference point location in output nc files
type(gaugingstation), public gauge
logical, dimension(noutflxstate) outputflxstate_mrm
Define model outputs see "mhm_outputs.nml".
type(domaininfo_mrm), dimension(:), allocatable, target, public domain_mrm
integer(i4), public ngaugeslocal
character(256), public varnametotalrunoff
integer(i4) timestep_model_outputs_mrm
timestep for writing model outputs
character(256), dimension(:), allocatable, public dirtotalrunoff
integer(i4), public ninflowgaugestotal
integer(i4) output_deflate_level_mrm
compression of output nc files
integer(i4), public ngaugestotal
character(256), public filenametotalrunoff
subroutine read_mrm_routing_params(processcase, file_namelist_param, unamelist_param)
TODO: add description.
subroutine, public mrm_read_config(file_namelist, unamelist, file_namelist_param, unamelist_param, do_message)
Read the general config of mRM.