5.13.3-dev0
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, &
109 use mo_string_utils, only : num2str
110
111 implicit none
112
113 character(*), intent(in) :: file_namelist
114
115 integer(i4) :: idomain, domainid
116
117 ! soil moisture input
118 character(256), dimension(maxNoDomains) :: dir_soil_moisture
119
120 ! ground albedo neutron input
121 character(256), dimension(maxNoDomains) :: dir_neutrons
122
123 ! evapotranspiration input
124 character(256), dimension(maxNoDomains) :: dir_evapotranspiration
125
126 ! tws input
127 character(256), dimension(maxNoDomains) :: dir_tws
128
129 integer(i4) :: timestep_tws_input ! time step of optional data: tws
130 integer(i4) :: timestep_et_input ! time step of optional data: et
131 integer(i4) :: timestep_sm_input ! time step of optional data: sm
132 integer(i4) :: timestep_neutrons_input ! time step of optional data: neutrons
133
134
135 allocate(l1_twsaobs(domainmeta%nDomains))
136 allocate(l1_etobs(domainmeta%nDomains))
137 allocate(l1_smobs(domainmeta%nDomains))
138 allocate(l1_neutronsobs(domainmeta%nDomains))
139 ! observed baseflow indizes
140 allocate(bfi_obs(domainmeta%nDomains))
141
142 !===============================================================
143 ! Read namelist of optional input data
144 !===============================================================
145 ! read optional optional data if necessary
146 if (optimize) then
147 ! read nml
148 select case (opti_function)
149 case(10 : 13, 15, 17, 27 : 30, 33)
150 call nml_optional_data%read(file_namelist)
151 nsoilhorizons_sm_input = nml_optional_data%nSoilHorizons_sm_input
152 dir_soil_moisture = nml_optional_data%dir_soil_moisture
153 dir_neutrons = nml_optional_data%dir_neutrons
154 dir_evapotranspiration = nml_optional_data%dir_evapotranspiration
155 dir_tws = nml_optional_data%dir_TWS
156 timestep_sm_input = nml_optional_data%timeStep_sm_input
157 timestep_neutrons_input = nml_optional_data%timeStep_neutrons_input
158 timestep_et_input = nml_optional_data%timeStep_et_input
159 timestep_tws_input = nml_optional_data%timeStep_tws_input
160 case(34)
161 call nml_baseflow_config%read(file_namelist)
163 bfi_obs = nml_baseflow_config%BFI_obs(1:size(bfi_obs))
164 end select
165
166 select case (opti_function)
167 case(10 : 13, 28)
168 ! soil moisture
169 do idomain = 1, domainmeta%nDomains
170 domainid = domainmeta%indices(idomain)
171 l1_smobs(idomain)%dir = dir_soil_moisture(domainid)
172 l1_smobs(idomain)%timeStepInput = timestep_sm_input
173 l1_smobs(idomain)%varname = 'sm'
174 end do
176 call error_message('***ERROR: Number of soil horizons representative for input soil moisture exceeded', raise=.false.)
177 call error_message(' defined number of soil horizions: ', adjustl(trim(num2str(maxnosoilhorizons))), '!')
178 end if
179 case(17)
180 ! neutrons
181 do idomain = 1, domainmeta%nDomains
182 domainid = domainmeta%indices(idomain)
183 l1_neutronsobs(idomain)%dir = dir_neutrons(domainid)
184 l1_neutronsobs(idomain)%timeStepInput = timestep_neutrons_input
185 l1_neutronsobs(idomain)%timeStepInput = -1 ! TODO: daily, hard-coded, to be flexibilized
186 l1_neutronsobs(idomain)%varname = 'neutrons'
187 end do
188 case(27, 29, 30)
189 ! evapotranspiration
190 do idomain = 1, domainmeta%nDomains
191 domainid = domainmeta%indices(idomain)
192 l1_etobs(idomain)%dir = dir_evapotranspiration(domainid)
193 l1_etobs(idomain)%timeStepInput = timestep_et_input
194 l1_etobs(idomain)%varname = 'et'
195 end do
196 case(15)
197 ! domain average TWS data
198 do idomain = 1, domainmeta%nDomains
199 domainid = domainmeta%indices(idomain)
200 l1_twsaobs(idomain)%dir = dir_tws(domainid)
201 l1_twsaobs(idomain)%timeStepInput = timestep_tws_input
202 l1_twsaobs(idomain)%varname = 'twsa'
203 end do
204 case(33)
205 ! evapotranspiration
206 do idomain = 1, domainmeta%nDomains
207 domainid = domainmeta%indices(idomain)
208 l1_etobs(idomain)%dir = dir_evapotranspiration(domainid)
209 l1_etobs(idomain)%timeStepInput = timestep_et_input
210 l1_etobs(idomain)%varname = 'et'
211 end do
212 ! domain average TWS data
213 do idomain = 1, domainmeta%nDomains
214 domainid = domainmeta%indices(idomain)
215 l1_twsaobs(idomain)%dir = dir_tws(domainid)
216 l1_twsaobs(idomain)%timeStepInput = timestep_tws_input
217 l1_twsaobs(idomain)%varname = 'twsa'
218 end do
219
220 end select
221 end if
222
223 !===============================================================
224 ! Read pan evaporation
225 !===============================================================
226 ! Evap. coef. for free-water surfaces
227 call nml_panevapo%read(file_namelist)
228 evap_coeff = nml_panevapo%evap_coeff
229
230 call common_check_resolution(.true., .false.)
231
232 !===============================================================
233 ! Read output specifications for mHM
234 !===============================================================
236 output_deflate_level = nml_nloutputresults%output_deflate_level
237 output_double_precision = nml_nloutputresults%output_double_precision
238 timestep_model_outputs = nml_nloutputresults%timeStep_model_outputs
239 outputflxstate = nml_nloutputresults%outputFlxState
240 output_time_reference = nml_nloutputresults%output_time_reference
241
242 call message('')
243 call message('Following output will be written:')
244 call message(' NetCDF deflate level: ', adjustl(trim(num2str(output_deflate_level))))
245 if ( output_double_precision ) then
246 call message(' NetCDF output precision: double')
247 else
248 call message(' NetCDF output precision: single')
249 end if
250 select case(output_time_reference)
251 case(0)
252 call message(' NetCDF output time reference point: start of time interval')
253 case(1)
254 call message(' NetCDF output time reference point: center of time interval')
255 case(2)
256 call message(' NetCDF output time reference point: end of time interval')
257 end select
258 call message(' STATES:')
259 if (outputflxstate(1)) then
260 call message(' interceptional storage (L1_inter) [mm]')
261 end if
262 if (outputflxstate(2)) then
263 call message(' height of snowpack (L1_snowpack) [mm]')
264 end if
265 if (outputflxstate(3)) then
266 call message(' soil water content in the single layers (L1_soilMoist) [mm]')
267 end if
268 if (outputflxstate(4)) then
269 call message(' volumetric soil moisture in the single layers [mm/mm]')
270 end if
271 if (outputflxstate(5)) then
272 call message(' mean volum. soil moisture averaged over all soil layers [mm/mm]')
273 end if
274 if (outputflxstate(6)) then
275 call message(' waterdepth in reservoir of sealed areas (L1_sealSTW) [mm]')
276 end if
277 if (outputflxstate(7)) then
278 call message(' waterdepth in reservoir of unsat. soil zone (L1_unsatSTW) [mm]')
279 end if
280 if (outputflxstate(8)) then
281 call message(' waterdepth in reservoir of sat. soil zone (L1_satSTW) [mm]')
282 end if
283 if (processmatrix(10, 1) .eq. 0) outputflxstate(18) = .false. ! suppress output if process is off
284 if (outputflxstate(18)) then
285 call message(' ground albedo neutrons (L1_neutrons) [cph]')
286 end if
287
288 call message(' FLUXES:')
289 if (outputflxstate(9)) then
290 call message(' potential evapotranspiration PET (L1_pet) [mm/T]')
291 end if
292 if (outputflxstate(10)) then
293 call message(' actual evapotranspiration aET (L1_aETCanopy) [mm/T]')
294 end if
295 if (outputflxstate(11)) then
296 call message(' total discharge generated per cell (L1_total_runoff) [mm/T]')
297 end if
298 if (outputflxstate(12)) then
299 call message(' direct runoff generated per cell (L1_runoffSeal) [mm/T]')
300 end if
301 if (outputflxstate(13)) then
302 call message(' fast interflow generated per cell (L1_fastRunoff) [mm/T]')
303 end if
304 if (outputflxstate(14)) then
305 call message(' slow interflow generated per cell (L1_slowRunoff) [mm/T]')
306 end if
307 if (outputflxstate(15)) then
308 call message(' baseflow generated per cell (L1_baseflow) [mm/T]')
309 end if
310 if (outputflxstate(16)) then
311 call message(' groundwater recharge (L1_percol) [mm/T]')
312 end if
313 if (outputflxstate(17)) then
314 call message(' infiltration (L1_infilSoil) [mm/T]')
315 end if
316 if (outputflxstate(19)) then
317 call message(' actual evapotranspiration from soil layers (L1_aETSoil) [mm/T]')
318 end if
319 if (outputflxstate(20)) then
320 call message(' effective precipitation (L1_preEffect) [mm/T]')
321 end if
322 if (outputflxstate(21)) then
323 call message(' snow melt (L1_melt) [mm/T]')
324 end if
325 call message('')
326 call message('FINISHED reading config')
327
328 ! warning message
329 if (any(outputflxstate) .and. optimize) then
330 call message('WARNING: FLUXES and STATES netCDF will be not written since optimization flag is TRUE ')
331 end if
332
333 end subroutine mhm_read_config
334
335END 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_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