Line data Source code
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
14 : MODULE mo_mhm_read_config
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 :
27 : CONTAINS
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 14 : subroutine mhm_read_config(file_namelist)
89 :
90 : use mo_namelists, only : &
91 : nml_optional_data, &
92 : nml_panEvapo, &
93 : nml_NLoutputResults, &
94 : nml_baseflow_config
95 : use mo_common_constants, only : maxNoDomains, nodata_i4
96 : use mo_common_mHM_mRM_read_config, only : common_check_resolution
97 : use mo_common_mhm_mrm_variables, only : opti_function, optimize
98 : use mo_common_variables, only : domainMeta, processMatrix
99 : use mo_file, only : file_defOutput
100 : use mo_global_variables, only : &
101 : L1_twsaObs, L1_etObs, L1_smObs, L1_neutronsObs, L1_spfObs, &
102 : evap_coeff, &
103 : nSoilHorizons_sm_input, outputFlxState, &
104 : timeStep_model_outputs, &
105 : output_deflate_level, output_double_precision, output_time_reference, &
106 : BFI_calc, BFI_obs, &
107 : wt_for_optional_data, swe_threshold_for_spf
108 : use mo_mpr_constants, only : maxNoSoilHorizons
109 : use mo_mpr_global_variables, only : nSoilHorizons_mHM
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 68 : allocate(L1_twsaObs(domainMeta%nDomains))
143 68 : allocate(L1_etObs(domainMeta%nDomains))
144 68 : allocate(L1_smObs(domainMeta%nDomains))
145 68 : allocate(L1_neutronsObs(domainMeta%nDomains))
146 68 : allocate(L1_spfObs(domainMeta%nDomains))
147 : ! observed baseflow indizes
148 42 : allocate(BFI_obs(domainMeta%nDomains))
149 :
150 : !===============================================================
151 : ! Read namelist of optional input data
152 : !===============================================================
153 : ! read optional optional data if necessary
154 14 : if (optimize) then
155 : ! read nml
156 4 : select case (opti_function)
157 : case(10 : 13, 15, 17, 27 : 30, 33, 35 : 47)
158 4 : call nml_optional_data%read(file_namelist)
159 4 : nSoilHorizons_sm_input = nml_optional_data%nSoilHorizons_sm_input
160 204 : dir_soil_moisture = nml_optional_data%dir_soil_moisture
161 204 : dir_neutrons = nml_optional_data%dir_neutrons
162 204 : dir_evapotranspiration = nml_optional_data%dir_evapotranspiration
163 204 : dir_TWS = nml_optional_data%dir_TWS
164 204 : dir_spf = nml_optional_data%dir_spf
165 4 : timeStep_sm_input = nml_optional_data%timeStep_sm_input
166 4 : timeStep_neutrons_input = nml_optional_data%timeStep_neutrons_input
167 4 : timeStep_et_input = nml_optional_data%timeStep_et_input
168 4 : timeStep_tws_input = nml_optional_data%timeStep_tws_input
169 4 : timeStep_spf_input = nml_optional_data%timeStep_spf_input
170 : case(34)
171 0 : call nml_baseflow_config%read(file_namelist)
172 0 : BFI_calc = nml_baseflow_config%BFI_calc
173 5 : BFI_obs = nml_baseflow_config%BFI_obs(1:size(BFI_obs))
174 : end select
175 :
176 1 : select case (opti_function)
177 : case(10 : 13, 28, 35, 38, 43)
178 : ! soil moisture
179 2 : do iDomain = 1, domainMeta%nDomains
180 1 : domainID = domainMeta%indices(iDomain)
181 1 : L1_smObs(iDomain)%dir = dir_Soil_moisture(domainID)
182 1 : L1_smObs(iDomain)%timeStepInput = timeStep_sm_input
183 2 : L1_smObs(iDomain)%varname = 'sm'
184 : end do
185 1 : if (nSoilHorizons_sm_input .GT. nSoilHorizons_mHM) then
186 0 : call error_message('***ERROR: Number of soil horizons representative for input soil moisture exceeded', raise=.false.)
187 0 : call error_message(' defined number of soil horizions: ', adjustl(trim(num2str(maxNoSoilHorizons))), '!')
188 : end if
189 : case(17)
190 : ! neutrons
191 2 : do iDomain = 1, domainMeta%nDomains
192 1 : domainID = domainMeta%indices(iDomain)
193 1 : L1_neutronsObs(iDomain)%dir = dir_neutrons(domainID)
194 1 : L1_neutronsObs(iDomain)%timeStepInput = timeStep_neutrons_input
195 1 : L1_neutronsObs(iDomain)%timeStepInput = -1 ! TODO: daily, hard-coded, to be flexibilized
196 2 : L1_neutronsObs(iDomain)%varname = 'neutrons'
197 : end do
198 : case(27, 29, 30, 36, 39, 41, 44)
199 : ! evapotranspiration
200 0 : do iDomain = 1, domainMeta%nDomains
201 0 : domainID = domainMeta%indices(iDomain)
202 0 : L1_etObs(iDomain)%dir = dir_evapotranspiration(domainID)
203 0 : L1_etObs(iDomain)%timeStepInput = timeStep_et_input
204 0 : L1_etObs(iDomain)%varname = 'et'
205 : end do
206 : case(15)
207 : ! domain average TWS data
208 2 : do iDomain = 1, domainMeta%nDomains
209 1 : domainID = domainMeta%indices(iDomain)
210 1 : L1_twsaObs(iDomain)%dir = dir_TWS(domainID)
211 1 : L1_twsaObs(iDomain)%timeStepInput = timeStep_tws_input
212 2 : L1_twsaObs(iDomain)%varname = 'twsa'
213 : end do
214 : case(33)
215 : ! evapotranspiration
216 7 : do iDomain = 1, domainMeta%nDomains
217 6 : domainID = domainMeta%indices(iDomain)
218 6 : L1_etObs(iDomain)%dir = dir_evapotranspiration(domainID)
219 6 : L1_etObs(iDomain)%timeStepInput = timeStep_et_input
220 7 : L1_etObs(iDomain)%varname = 'et'
221 : end do
222 : ! domain average TWS data
223 7 : do iDomain = 1, domainMeta%nDomains
224 6 : domainID = domainMeta%indices(iDomain)
225 6 : L1_twsaObs(iDomain)%dir = dir_TWS(domainID)
226 6 : L1_twsaObs(iDomain)%timeStepInput = timeStep_tws_input
227 7 : L1_twsaObs(iDomain)%varname = 'twsa'
228 : end do
229 : case(37, 40, 42, 45)
230 : ! soil moisture
231 0 : do iDomain = 1, domainMeta%nDomains
232 0 : domainID = domainMeta%indices(iDomain)
233 0 : L1_smObs(iDomain)%dir = dir_Soil_moisture(domainID)
234 0 : L1_smObs(iDomain)%timeStepInput = timeStep_sm_input
235 0 : L1_smObs(iDomain)%varname = 'sm'
236 : end do
237 0 : if (nSoilHorizons_sm_input .GT. nSoilHorizons_mHM) then
238 0 : call error_message('***ERROR: Number of soil horizons representative for input soil moisture exceeded', raise=.false.)
239 0 : call error_message(' defined number of soil horizions: ', adjustl(trim(num2str(maxNoSoilHorizons))), '!')
240 : end if
241 : ! evapotranspiration
242 0 : do iDomain = 1, domainMeta%nDomains
243 0 : domainID = domainMeta%indices(iDomain)
244 0 : L1_etObs(iDomain)%dir = dir_evapotranspiration(domainID)
245 0 : L1_etObs(iDomain)%timeStepInput = timeStep_et_input
246 0 : L1_etObs(iDomain)%varname = 'et'
247 : end do
248 0 : wt_for_optional_data = weight_for_optional_data
249 : case(46, 47)
250 : ! snow cover area
251 0 : do iDomain = 1, domainMeta%nDomains
252 0 : domainID = domainMeta%indices(iDomain)
253 0 : L1_spfObs(iDomain)%dir = dir_spf(domainID)
254 0 : L1_spfObs(iDomain)%timeStepInput = timeStep_spf_input
255 0 : L1_spfObs(iDomain)%varname = 'spf'
256 : end do
257 0 : wt_for_optional_data = weight_for_optional_data
258 5 : 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 14 : call nml_panEvapo%read(file_namelist)
268 182 : evap_coeff = nml_panEvapo%evap_coeff
269 :
270 14 : call common_check_resolution(.true., .false.)
271 :
272 : !===============================================================
273 : ! Read output specifications for mHM
274 : !===============================================================
275 14 : call nml_NLoutputResults%read(file_defOutput)
276 14 : output_deflate_level = nml_NLoutputResults%output_deflate_level
277 14 : output_double_precision = nml_NLoutputResults%output_double_precision
278 14 : timeStep_model_outputs = nml_NLoutputResults%timeStep_model_outputs
279 308 : outputFlxState = nml_NLoutputResults%outputFlxState
280 14 : output_time_reference = nml_NLoutputResults%output_time_reference
281 :
282 14 : call message('')
283 14 : call message('Following output will be written:')
284 14 : call message(' NetCDF deflate level: ', adjustl(trim(num2str(output_deflate_level))))
285 14 : if ( output_double_precision ) then
286 14 : call message(' NetCDF output precision: double')
287 : else
288 0 : call message(' NetCDF output precision: single')
289 : end if
290 14 : select case(output_time_reference)
291 : case(0)
292 14 : call message(' NetCDF output time reference point: start of time interval')
293 : case(1)
294 0 : call message(' NetCDF output time reference point: center of time interval')
295 : case(2)
296 14 : call message(' NetCDF output time reference point: end of time interval')
297 : end select
298 14 : call message(' STATES:')
299 14 : if (outputFlxState(1)) then
300 0 : call message(' interceptional storage (L1_inter) [mm]')
301 : end if
302 14 : if (outputFlxState(2)) then
303 0 : call message(' height of snowpack (L1_snowpack) [mm]')
304 : end if
305 14 : if (outputFlxState(3)) then
306 13 : call message(' soil water content in the single layers (L1_soilMoist) [mm]')
307 : end if
308 14 : if (outputFlxState(4)) then
309 0 : call message(' volumetric soil moisture in the single layers [mm/mm]')
310 : end if
311 14 : if (outputFlxState(5)) then
312 0 : call message(' mean volum. soil moisture averaged over all soil layers [mm/mm]')
313 : end if
314 14 : if (outputFlxState(6)) then
315 0 : call message(' waterdepth in reservoir of sealed areas (L1_sealSTW) [mm]')
316 : end if
317 14 : if (outputFlxState(7)) then
318 0 : call message(' waterdepth in reservoir of unsat. soil zone (L1_unsatSTW) [mm]')
319 : end if
320 14 : if (outputFlxState(8)) then
321 0 : call message(' waterdepth in reservoir of sat. soil zone (L1_satSTW) [mm]')
322 : end if
323 14 : if (processMatrix(10, 1) .eq. 0) outputFlxState(18) = .false. ! suppress output if process is off
324 14 : if (outputFlxState(18)) then
325 1 : call message(' ground albedo neutrons (L1_neutrons) [cph]')
326 : end if
327 :
328 14 : call message(' FLUXES:')
329 14 : if (outputFlxState(9)) then
330 2 : call message(' potential evapotranspiration PET (L1_pet) [mm/T]')
331 : end if
332 14 : if (outputFlxState(10)) then
333 3 : call message(' actual evapotranspiration aET (L1_aETCanopy) [mm/T]')
334 : end if
335 14 : if (outputFlxState(11)) then
336 13 : call message(' total discharge generated per cell (L1_total_runoff) [mm/T]')
337 : end if
338 14 : if (outputFlxState(12)) then
339 0 : call message(' direct runoff generated per cell (L1_runoffSeal) [mm/T]')
340 : end if
341 14 : if (outputFlxState(13)) then
342 0 : call message(' fast interflow generated per cell (L1_fastRunoff) [mm/T]')
343 : end if
344 14 : if (outputFlxState(14)) then
345 0 : call message(' slow interflow generated per cell (L1_slowRunoff) [mm/T]')
346 : end if
347 14 : if (outputFlxState(15)) then
348 0 : call message(' baseflow generated per cell (L1_baseflow) [mm/T]')
349 : end if
350 14 : if (outputFlxState(16)) then
351 2 : call message(' groundwater recharge (L1_percol) [mm/T]')
352 : end if
353 14 : if (outputFlxState(17)) then
354 0 : call message(' infiltration (L1_infilSoil) [mm/T]')
355 : end if
356 14 : if (outputFlxState(19)) then
357 0 : call message(' actual evapotranspiration from soil layers (L1_aETSoil) [mm/T]')
358 : end if
359 14 : if (outputFlxState(20)) then
360 0 : call message(' effective precipitation (L1_preEffect) [mm/T]')
361 : end if
362 14 : if (outputFlxState(21)) then
363 0 : call message(' snow melt (L1_melt) [mm/T]')
364 : end if
365 14 : call message('')
366 14 : call message('FINISHED reading config')
367 :
368 : ! warning message
369 61 : if (any(outputFlxState) .and. optimize) then
370 5 : call message('WARNING: FLUXES and STATES netCDF will be not written since optimization flag is TRUE ')
371 : end if
372 :
373 14 : end subroutine mhm_read_config
374 :
375 : END MODULE mo_mhm_read_config
|