5.13.3
mHM
The mesoscale Hydrological Model
Loading...
Searching...
No Matches
mo_mhm_read_config.f90
Go to the documentation of this file.
1!> \file mo_mhm_read_config.f90
2!> \brief \copybrief mo_mhm_read_config
3!> \details \copydetails mo_mhm_read_config
4
5!> \brief Reading of main model configurations.
6!> \details This routine reads the configurations of mHM including, input and
7!! output directories, module usage specification, simulation time periods,
8!! global parameters, ...
9!> \authors Matthias Zink
10!> \date Dec 2012
11!> \copyright Copyright 2005-\today, the mHM Developers, Luis Samaniego, Sabine Attinger: All rights reserved.
12!! mHM is released under the LGPLv3+ license \license_note
13!> \ingroup f_mhm
15
16 USE mo_kind, ONLY : i4, dp
17 use mo_message, only: message, error_message
18
19 IMPLICIT NONE
20
21 PRIVATE
22
23 PUBLIC :: mhm_read_config ! read main directories
24
25 ! ------------------------------------------------------------------
26
27CONTAINS
28
29 ! ------------------------------------------------------------------
30
31 ! NAME
32 ! mhm_read_config
33
34 ! PURPOSE
35 !> \brief Read main configurations for mHM
36
37 !> \details The main configurations in mHM are read from three files:
38 !> <ol>
39 !> <li> mhm.nml
40 !> <li> mhm_parameters.nml
41 !> <li> mhm_outputs.nml
42 !> </ol>
43 !> For details please refer to the above mentioned namelist files.
44
45 ! INTENT(IN)
46 !> \param[in] "character(*) :: file_namelist"
47
48 ! HISTORY
49 !> \authors Matthias Zink
50
51 !> \date Dec 2012
52
53 ! Modifications:
54 ! Luis Samaniego Jan 2013 - messages Rohini Kumar
55 ! Matthias Cuntz Jan 2013 - namelist consolidation and positioning
56 ! Matthias Zink Jan 2013 - bug fix, added gaugeinfo reading
57 ! Rohini Kumar Jun 2013 - added restart flags
58 ! R. Kumar & S. Thober Aug 2013 - code change to incorporate output timestep during
59 ! writing of the netcdf file
60 ! Rohini Kumar Aug 2013 - name changed from "inputFormat" to inputFormat_meteo_forcings
61 ! Rohini Kumar Aug 2013 - added dirSoil_LUT and dirGeology_LUT, and changed
62 ! in namelist made accordingly
63 ! Rohini Kumar Aug 2013 - added new namelist for LAI related datasets, and changed in within
64 ! the code made accordingly
65 ! Matthias Zink Aug 2013 - changed read in for land cover period
66 ! Juliane Mai Oct 2013 - adding global_parameters_name
67 ! Matthias Zink Nov 2013 - edited documentation and included DEFAULT cases for ptocess Matrix
68 ! Stephan Thober Nov 2013 - added read of directories where latitude longitude fields are located
69 ! Matthias Zink Feb 2014 - added multiple options for PET process
70 ! Matthias Zink Mar 2014 - added inflow from upstream areas and gauge information as namelist
71 ! Rohini Kumar May 2014 - added options for the model run coordinate system
72 ! Stephan Thober May 2014 - added switch for chunk read in
73 ! Stephan Thober Jun 2014 - added option for switching off mpr
74 ! Matthias Cuntz & Juliane Mai Nov 2014 - LAI input from daily, monthly or yearly files
75 ! Matthias Zink Dec 2014 - adopted inflow gauges to ignore headwater cells
76 ! Matthias Zink Mar 2015 - added optional soil moisture read in for calibration
77 ! Matthias Cuntz Jul 2015 - removed adjustl from trim(adjustl()) of Geoparams for PGI compatibilty
78 ! Stephan Thober Aug 2015 - added read_config_routing and read_routing_params from mRM
79 ! Oldrich Rakovec Oct 2015 - added reading of the domain average TWS data
80 ! Rohini Kumar Mar 2016 - options to handle different soil databases
81 ! Stephan Thober Nov 2016 - moved nProcesses and processMatrix to common variables
82 ! Rohini Kumar Dec 2016 - option to handle monthly mean gridded fields of LAI
83 ! M.Zink & M. Cuneyd Demirel Mar 2017 - Added Jarvis soil water stress function at SM process(3)
84 ! M.C. Demirel & Simon Stisen Apr 2017 - Added FC dependency on root fraction coefficient (ET) at SM process(3)
85 ! Robert Schweppe Dec 2017 - switched from fractional julian day to integer
86 ! Robert Schweppe Jun 2018 - refactoring and reformatting
87
88 subroutine mhm_read_config(file_namelist)
89
90 use mo_namelists, only : &
99 use mo_file, only : file_defoutput
100 use mo_global_variables, only : &
102 evap_coeff, &
106 bfi_calc, bfi_obs, &
110 use mo_string_utils, only : num2str
111
112 implicit none
113
114 character(*), intent(in) :: file_namelist
115
116 integer(i4) :: idomain, domainid
117
118 ! soil moisture input
119 character(256), dimension(maxNoDomains) :: dir_soil_moisture
120
121 ! ground albedo neutron input
122 character(256), dimension(maxNoDomains) :: dir_neutrons
123
124 ! evapotranspiration input
125 character(256), dimension(maxNoDomains) :: dir_evapotranspiration
126
127 ! tws input
128 character(256), dimension(maxNoDomains) :: dir_tws
129
130 ! SPF input
131 character(256), dimension(maxNoDomains) :: dir_spf
132
133 integer(i4) :: timestep_tws_input ! time step of optional data: tws
134 integer(i4) :: timestep_et_input ! time step of optional data: et
135 integer(i4) :: timestep_sm_input ! time step of optional data: sm
136 integer(i4) :: timestep_neutrons_input ! time step of optional data: neutrons
137 integer(i4) :: timestep_spf_input ! time step of optional data: spf
138 integer(i4) :: weight_for_optional_data ! weight of optional data in OF 39-41, 43-45 & 47
139 integer(i4) :: snow_water_equivalent_threshold_for_spf ! threshold swe to convert to spf for OF 46 & 47
140
141
142 allocate(l1_twsaobs(domainmeta%nDomains))
143 allocate(l1_etobs(domainmeta%nDomains))
144 allocate(l1_smobs(domainmeta%nDomains))
145 allocate(l1_neutronsobs(domainmeta%nDomains))
146 allocate(l1_spfobs(domainmeta%nDomains))
147 ! observed baseflow indizes
148 allocate(bfi_obs(domainmeta%nDomains))
149
150 !===============================================================
151 ! Read namelist of optional input data
152 !===============================================================
153 ! read optional optional data if necessary
154 if (optimize) then
155 ! read nml
156 select case (opti_function)
157 case(10 : 13, 15, 17, 27 : 30, 33, 35 : 47)
158 call nml_optional_data%read(file_namelist)
159 nsoilhorizons_sm_input = nml_optional_data%nSoilHorizons_sm_input
160 dir_soil_moisture = nml_optional_data%dir_soil_moisture
161 dir_neutrons = nml_optional_data%dir_neutrons
162 dir_evapotranspiration = nml_optional_data%dir_evapotranspiration
163 dir_tws = nml_optional_data%dir_TWS
164 dir_spf = nml_optional_data%dir_spf
165 timestep_sm_input = nml_optional_data%timeStep_sm_input
166 timestep_neutrons_input = nml_optional_data%timeStep_neutrons_input
167 timestep_et_input = nml_optional_data%timeStep_et_input
168 timestep_tws_input = nml_optional_data%timeStep_tws_input
169 timestep_spf_input = nml_optional_data%timeStep_spf_input
170 case(34)
171 call nml_baseflow_config%read(file_namelist)
173 bfi_obs = nml_baseflow_config%BFI_obs(1:size(bfi_obs))
174 end select
175
176 select case (opti_function)
177 case(10 : 13, 28, 35, 38, 43)
178 ! soil moisture
179 do idomain = 1, domainmeta%nDomains
180 domainid = domainmeta%indices(idomain)
181 l1_smobs(idomain)%dir = dir_soil_moisture(domainid)
182 l1_smobs(idomain)%timeStepInput = timestep_sm_input
183 l1_smobs(idomain)%varname = 'sm'
184 end do
186 call error_message('***ERROR: Number of soil horizons representative for input soil moisture exceeded', raise=.false.)
187 call error_message(' defined number of soil horizions: ', adjustl(trim(num2str(maxnosoilhorizons))), '!')
188 end if
189 case(17)
190 ! neutrons
191 do idomain = 1, domainmeta%nDomains
192 domainid = domainmeta%indices(idomain)
193 l1_neutronsobs(idomain)%dir = dir_neutrons(domainid)
194 l1_neutronsobs(idomain)%timeStepInput = timestep_neutrons_input
195 l1_neutronsobs(idomain)%timeStepInput = -1 ! TODO: daily, hard-coded, to be flexibilized
196 l1_neutronsobs(idomain)%varname = 'neutrons'
197 end do
198 case(27, 29, 30, 36, 39, 41, 44)
199 ! evapotranspiration
200 do idomain = 1, domainmeta%nDomains
201 domainid = domainmeta%indices(idomain)
202 l1_etobs(idomain)%dir = dir_evapotranspiration(domainid)
203 l1_etobs(idomain)%timeStepInput = timestep_et_input
204 l1_etobs(idomain)%varname = 'et'
205 end do
206 case(15)
207 ! domain average TWS data
208 do idomain = 1, domainmeta%nDomains
209 domainid = domainmeta%indices(idomain)
210 l1_twsaobs(idomain)%dir = dir_tws(domainid)
211 l1_twsaobs(idomain)%timeStepInput = timestep_tws_input
212 l1_twsaobs(idomain)%varname = 'twsa'
213 end do
214 case(33)
215 ! evapotranspiration
216 do idomain = 1, domainmeta%nDomains
217 domainid = domainmeta%indices(idomain)
218 l1_etobs(idomain)%dir = dir_evapotranspiration(domainid)
219 l1_etobs(idomain)%timeStepInput = timestep_et_input
220 l1_etobs(idomain)%varname = 'et'
221 end do
222 ! domain average TWS data
223 do idomain = 1, domainmeta%nDomains
224 domainid = domainmeta%indices(idomain)
225 l1_twsaobs(idomain)%dir = dir_tws(domainid)
226 l1_twsaobs(idomain)%timeStepInput = timestep_tws_input
227 l1_twsaobs(idomain)%varname = 'twsa'
228 end do
229 case(37, 40, 42, 45)
230 ! soil moisture
231 do idomain = 1, domainmeta%nDomains
232 domainid = domainmeta%indices(idomain)
233 l1_smobs(idomain)%dir = dir_soil_moisture(domainid)
234 l1_smobs(idomain)%timeStepInput = timestep_sm_input
235 l1_smobs(idomain)%varname = 'sm'
236 end do
238 call error_message('***ERROR: Number of soil horizons representative for input soil moisture exceeded', raise=.false.)
239 call error_message(' defined number of soil horizions: ', adjustl(trim(num2str(maxnosoilhorizons))), '!')
240 end if
241 ! evapotranspiration
242 do idomain = 1, domainmeta%nDomains
243 domainid = domainmeta%indices(idomain)
244 l1_etobs(idomain)%dir = dir_evapotranspiration(domainid)
245 l1_etobs(idomain)%timeStepInput = timestep_et_input
246 l1_etobs(idomain)%varname = 'et'
247 end do
248 wt_for_optional_data = weight_for_optional_data
249 case(46, 47)
250 ! snow cover area
251 do idomain = 1, domainmeta%nDomains
252 domainid = domainmeta%indices(idomain)
253 l1_spfobs(idomain)%dir = dir_spf(domainid)
254 l1_spfobs(idomain)%timeStepInput = timestep_spf_input
255 l1_spfobs(idomain)%varname = 'spf'
256 end do
257 wt_for_optional_data = weight_for_optional_data
258 swe_threshold_for_spf = snow_water_equivalent_threshold_for_spf
259
260 end select
261 end if
262
263 !===============================================================
264 ! Read pan evaporation
265 !===============================================================
266 ! Evap. coef. for free-water surfaces
267 call nml_panevapo%read(file_namelist)
268 evap_coeff = nml_panevapo%evap_coeff
269
270 call common_check_resolution(.true., .false.)
271
272 !===============================================================
273 ! Read output specifications for mHM
274 !===============================================================
276 output_deflate_level = nml_nloutputresults%output_deflate_level
277 output_double_precision = nml_nloutputresults%output_double_precision
278 timestep_model_outputs = nml_nloutputresults%timeStep_model_outputs
279 outputflxstate = nml_nloutputresults%outputFlxState
280 output_time_reference = nml_nloutputresults%output_time_reference
281
282 call message('')
283 call message('Following output will be written:')
284 call message(' NetCDF deflate level: ', adjustl(trim(num2str(output_deflate_level))))
285 if ( output_double_precision ) then
286 call message(' NetCDF output precision: double')
287 else
288 call message(' NetCDF output precision: single')
289 end if
290 select case(output_time_reference)
291 case(0)
292 call message(' NetCDF output time reference point: start of time interval')
293 case(1)
294 call message(' NetCDF output time reference point: center of time interval')
295 case(2)
296 call message(' NetCDF output time reference point: end of time interval')
297 end select
298 call message(' STATES:')
299 if (outputflxstate(1)) then
300 call message(' interceptional storage (L1_inter) [mm]')
301 end if
302 if (outputflxstate(2)) then
303 call message(' height of snowpack (L1_snowpack) [mm]')
304 end if
305 if (outputflxstate(3)) then
306 call message(' soil water content in the single layers (L1_soilMoist) [mm]')
307 end if
308 if (outputflxstate(4)) then
309 call message(' volumetric soil moisture in the single layers [mm/mm]')
310 end if
311 if (outputflxstate(5)) then
312 call message(' mean volum. soil moisture averaged over all soil layers [mm/mm]')
313 end if
314 if (outputflxstate(6)) then
315 call message(' waterdepth in reservoir of sealed areas (L1_sealSTW) [mm]')
316 end if
317 if (outputflxstate(7)) then
318 call message(' waterdepth in reservoir of unsat. soil zone (L1_unsatSTW) [mm]')
319 end if
320 if (outputflxstate(8)) then
321 call message(' waterdepth in reservoir of sat. soil zone (L1_satSTW) [mm]')
322 end if
323 if (processmatrix(10, 1) .eq. 0) outputflxstate(18) = .false. ! suppress output if process is off
324 if (outputflxstate(18)) then
325 call message(' ground albedo neutrons (L1_neutrons) [cph]')
326 end if
327
328 call message(' FLUXES:')
329 if (outputflxstate(9)) then
330 call message(' potential evapotranspiration PET (L1_pet) [mm/T]')
331 end if
332 if (outputflxstate(10)) then
333 call message(' actual evapotranspiration aET (L1_aETCanopy) [mm/T]')
334 end if
335 if (outputflxstate(11)) then
336 call message(' total discharge generated per cell (L1_total_runoff) [mm/T]')
337 end if
338 if (outputflxstate(12)) then
339 call message(' direct runoff generated per cell (L1_runoffSeal) [mm/T]')
340 end if
341 if (outputflxstate(13)) then
342 call message(' fast interflow generated per cell (L1_fastRunoff) [mm/T]')
343 end if
344 if (outputflxstate(14)) then
345 call message(' slow interflow generated per cell (L1_slowRunoff) [mm/T]')
346 end if
347 if (outputflxstate(15)) then
348 call message(' baseflow generated per cell (L1_baseflow) [mm/T]')
349 end if
350 if (outputflxstate(16)) then
351 call message(' groundwater recharge (L1_percol) [mm/T]')
352 end if
353 if (outputflxstate(17)) then
354 call message(' infiltration (L1_infilSoil) [mm/T]')
355 end if
356 if (outputflxstate(19)) then
357 call message(' actual evapotranspiration from soil layers (L1_aETSoil) [mm/T]')
358 end if
359 if (outputflxstate(20)) then
360 call message(' effective precipitation (L1_preEffect) [mm/T]')
361 end if
362 if (outputflxstate(21)) then
363 call message(' snow melt (L1_melt) [mm/T]')
364 end if
365 call message('')
366 call message('FINISHED reading config')
367
368 ! warning message
369 if (any(outputflxstate) .and. optimize) then
370 call message('WARNING: FLUXES and STATES netCDF will be not written since optimization flag is TRUE ')
371 end if
372
373 end subroutine mhm_read_config
374
375END MODULE mo_mhm_read_config
Provides constants commonly used by mHM, mRM and MPR.
integer(i4), parameter, public maxnodomains
integer(i4), parameter, public nodata_i4
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.
Provides structures needed by mHM, mRM and/or mpr.
type(domain_meta), public domainmeta
integer(i4), dimension(nprocesses, 3), public processmatrix
Provides file names and units for mHM.
Definition mo_file.F90:29
character(:), allocatable file_defoutput
file defining mHM's outputs
Definition mo_file.F90:46
Main global variables for mHM.
logical, dimension(noutflxstate) outputflxstate
Define model outputs see "mhm_outputs.nml" dim1 = number of output variables to be written.
type(optidata), dimension(:), allocatable, public l1_twsaobs
this stores L1_tws, the mask, the directory of the observerd data, and the timestepInput of the simul...
logical, public bfi_calc
calculate observed BFI from gauges with Eckhardt filter
type(optidata), dimension(:), allocatable, public l1_neutronsobs
type(optidata), dimension(:), allocatable, public l1_spfobs
type(optidata), dimension(:), allocatable, public l1_smobs
integer(i4) timestep_model_outputs
timestep for writing model outputs
integer(i4) output_deflate_level
deflate level in nc files
logical output_double_precision
output precision in nc files
integer(i4) output_time_reference
time reference point location in output nc files
real(dp), dimension(int(yearmonths, i4)), public evap_coeff
[-] Evap.
type(optidata), dimension(:), allocatable, public l1_etobs
real(dp), dimension(:), allocatable, public bfi_obs
given base-flow index per domain
Reading of main model configurations.
subroutine, public mhm_read_config(file_namelist)
Read main configurations for mHM.
Provides MPR specific constants.
integer(i4), parameter, public maxnosoilhorizons
Global variables for mpr only.
integer(i4), public nsoilhorizons_mhm
Module containing all namelists representations.
type(nml_baseflow_config_t), public nml_baseflow_config
'baseflow_config' namelist content
type(nml_panevapo_t), public nml_panevapo
'panevapo' namelist content
type(nml_optional_data_t), public nml_optional_data
'optional_data' namelist content
type(nml_nloutputresults_t), public nml_nloutputresults
'nloutputresults' namelist content