5.13.3-dev0
mHM
The mesoscale Hydrological Model
Loading...
Searching...
No Matches
mo_mrm_write.f90
Go to the documentation of this file.
1!> \file mo_mrm_write.f90
2!> \brief \copybrief mo_mrm_write
3!> \details \copydetails mo_mrm_write
4
5!> \brief write of discharge and restart files
6!> \details This module contains the subroutines for writing the discharge files and optionally the restart files.
7!> \authors Stephan Thober
8!> \date Aug 2015
9!> \copyright Copyright 2005-\today, the mHM Developers, Luis Samaniego, Sabine Attinger: All rights reserved.
10!! mHM is released under the LGPLv3+ license \license_note
11!> \ingroup f_mrm
13
14 use mo_kind, only : i4, dp
15 use mo_mrm_write_fluxes_states, only : outputdataset
17 use mo_message, only : message, error_message
18
19 implicit none
20
21 public :: mrm_write
23 public :: mrm_write_optifile
24
25 private
26
27contains
28
29 ! ------------------------------------------------------------------
30
31 ! NAME
32 ! mrm_write
33
34 ! PURPOSE
35 !> \brief write discharge and restart files
36
37 !> \details First, this subroutine calls the writing or restart files that only
38 !> succeeds if it happens after the write of mHM restart files because
39 !> mHM restart files must exist. Second, simulated discharge is aggregated to the daily
40 !> scale and then written to file jointly with observed discharge
41
42 ! HISTORY
43 !> \authors Juliane Mai, Rohini Kumar & Stephan Thober
44
45 !> \date Aug 2015
46
47 ! Modifications:
48 ! Robert Schweppe Jun 2018 - refactoring and reformatting
49 ! Pallav Shrestha, Husain Najafi Mar 2022 - refactoring for measured timestep output
50
51 subroutine mrm_write
52
59
60 implicit none
61
62 integer(i4) :: domainid, idomain
63
64 integer(i4) :: iday, isubday, is, ie
65
66 integer(i4) :: maxdailytimesteps, maxmeastimesteps
67
68 integer(i4) :: tt
69
70 integer(i4) :: gg
71
72 integer(i4) :: ntimesteps
73
74 real(dp), dimension(:, :), allocatable :: d_qmod, subd_qmod ! Sim discharge at daily and subdaily time step
75 real(dp), dimension(:, :), allocatable :: d_qobs, subd_qobs ! Obs discharge at daily and subdaily time step
76
77 ! between simulated and measured time scale
78 integer(i4) :: factor
79
80 ! simulated Timesteps per Day
81 integer(i4) :: tpd_sim
82
83 ! observed Timesteps per Day
84 integer(i4) :: tpd_obs
85
86 ! --------------------------------------------------------------------------
87 ! WRITE CONFIG FILE
88 ! --------------------------------------------------------------------------
89 if (mrm_coupling_mode .eq. 0_i4) call write_configfile()
90
91 ! --------------------------------------------------------------------------
92 ! WRITE RESTART
93 ! --------------------------------------------------------------------------
94 if (write_restart) then
95 do idomain = 1, domainmeta%nDomains
96 domainid = domainmeta%indices(idomain)
97 if (domainmeta%doRouting(idomain)) call mrm_write_restart(idomain, domainid, mrmfilerestartout)
98 end do
99 end if
100
101 ! --------------------------------------------------------------------------
102 ! STORE DAILY DISCHARGE TIMESERIES OF EACH GAUGING STATION
103 ! FOR SIMULATIONS DURING THE EVALUATION PERIOD
104 !
105 ! **** AT DAILY TIME STEPS ****
106 ! Note:: Observed Q are stored only for the evaluation period and not for
107 ! the warming days
108 ! --------------------------------------------------------------------------
109
110 ! copy time resolution to local variables
111 tpd_sim = ntstepday
112 tpd_obs = nmeasperday
113
114 ! check if modelled timestep is an integer multiple of measured timesteps
115 if (modulo(tpd_sim, tpd_obs) .eq. 0) then
116 factor = tpd_sim / tpd_obs
117 else
118 call error_message(' Error: Number of modelled datapoints is no multiple of measured datapoints per day')
119 end if
120
121
122 maxdailytimesteps = maxval(evalper(1 : domainmeta%nDomains)%julEnd - evalper(1 : domainmeta%nDomains)%julStart + 1)
123 maxmeastimesteps = maxval(evalper(1 : domainmeta%nDomains)%julEnd - evalper(1 : domainmeta%nDomains)%julStart + 1) * tpd_obs
124 allocate(d_qmod(maxdailytimesteps, ngaugestotal))
125 allocate(d_qobs(maxdailytimesteps, ngaugestotal))
126 allocate(subd_qmod( maxmeastimesteps, ngaugestotal))
127 allocate(subd_qobs( maxmeastimesteps, ngaugestotal))
128 d_qmod = nodata_dp
129 d_qobs = nodata_dp
130 subd_qmod = nodata_dp
131 subd_qobs = nodata_dp
132
133
134 ! loop over domains
135 do idomain = 1, domainmeta%nDomains
136 if (domainmeta%doRouting(idomain)) then
137 domainid = domainmeta%indices(idomain)
138
139 ! Convert simulated values to daily
140 ntimesteps = (simper(idomain)%julEnd - simper(idomain)%julStart + 1) * ntstepday
141 iday = 0
142 do tt = warmingdays(idomain) * ntstepday + 1, ntimesteps, ntstepday
143 is = tt
144 ie = tt + ntstepday - 1
145 iday = iday + 1
146 ! over gauges
147 do gg = 1, domain_mrm(idomain)%nGauges
148 ! simulation
149 d_qmod(iday, domain_mrm(idomain)%gaugeIndexList(gg)) = &
150 sum(mrm_runoff(is : ie, domain_mrm(idomain)%gaugeIndexList(gg))) / real(ntstepday, dp)
151 end do
152 end do
153
154 dailycheck: if (nmeasperday > 1) then
155 ! Convert observed values to daily
156 ntimesteps = (simper(idomain)%julEnd - simper(idomain)%julStart + 1) * nmeasperday
157 iday = 0
158 do tt = 1, ntimesteps, nmeasperday
159 is = tt
160 ie = tt + nmeasperday - 1
161 iday = iday + 1
162 ! over gauges
163 do gg = 1, domain_mrm(idomain)%nGauges
164 ! when -9999 value/s are present in current day, daily value remain -9999.
165 if (.not.(any(gauge%Q(is : ie, domain_mrm(idomain)%gaugeIndexList(gg)) == nodata_dp))) then
166 ! observation
167 d_qobs(iday, domain_mrm(idomain)%gaugeIndexList(gg)) = &
168 sum( gauge%Q(is : ie, domain_mrm(idomain)%gaugeIndexList(gg))) / real(nmeasperday, dp)
169 end if
170 end do
171 end do
172 else
173 ! observed values are already at daily (nMeasPerDay = 1) and stored for evalper
174 ! over gauges
175 do gg = 1, domain_mrm(idomain)%nGauges
176 ! observation
177 d_qobs(:, domain_mrm(idomain)%gaugeIndexList(gg)) = gauge%Q(:, domain_mrm(idomain)%gaugeIndexList(gg))
178 end do
179 end if dailycheck
180
181
182 subdailycheck: if (nmeasperday > 1) then
183
184 ! Convert simulated values to subdaily
185 ntimesteps = (simper(idomain)%julEnd - simper(idomain)%julStart + 1) * ntstepday
186 isubday = 0
187 do tt = warmingdays(idomain) * ntstepday + 1, ntimesteps, factor
188 is = tt
189 ie = tt + factor - 1
190 isubday = isubday + 1
191 ! over gauges
192 do gg = 1, domain_mrm(idomain)%nGauges
193 ! simulation
194 subd_qmod(isubday, domain_mrm(idomain)%gaugeIndexList(gg)) = &
195 sum(mrm_runoff(is : ie, domain_mrm(idomain)%gaugeIndexList(gg))) / real(factor, dp)
196 end do
197 end do
198
199 ! Convert observed values to subdaily
200
201 ! observed values are already at subdaily (nMeasPerDay) and stored for evalper
202 ! over gauges
203 do gg = 1, domain_mrm(idomain)%nGauges
204 ! observation
205 subd_qobs(:, domain_mrm(idomain)%gaugeIndexList(gg)) = gauge%Q(:, domain_mrm(idomain)%gaugeIndexList(gg))
206 end do
207
208 end if subdailycheck
209
210 end if
211 end do
212
213
214 ! write in an ASCII file ! OBS[nModeling_days X nGauges_total] , SIM[nModeling_days X nGauges_total]
215 ! ToDo: is this if statement reasonable
216 if (allocated(gauge%Q)) call write_daily_obs_sim_discharge(d_qobs(:, :), d_qmod(:, :))
217
218 ! write in an ASCII file ! OBS[nMeasPerDay X nGauges_total] , SIM[nMeasPerDay X nGauges_total]
219 if (nmeasperday > 1 .and. allocated(gauge%Q)) call write_subdaily_obs_sim_discharge(subd_qobs(:, :), subd_qmod(:, :), factor)
220 ! The subdaily routine is only called if subdaily Q data is provided
221
222 ! free space
223 deallocate(d_qmod, d_qobs, subd_qmod, subd_qobs)
224 end subroutine mrm_write
225 ! ------------------------------------------------------------------
226
227 ! NAME
228 ! write_configfile
229
230 ! PURPOSE
231 !> \brief This modules writes the results of the configuration into an ASCII-file
232
233 !> \details TODO: add description
234
235 ! HISTORY
236 !> \authors Christoph Schneider
237
238 !> \date May 2013
239
240 ! Modifications:
241 ! Juliane Mai May 2013 - module version and documentation
242 ! Stephan Thober Jun 2014 - bug fix in L11 config print out
243 ! Stephan Thober Jun 2014 - updated read_restart
244 ! Rohini, Luis Jul 2015 - updated version, L1 level prints
245 ! Stephan Thober Sep 2015 - updated write of stream network
246 ! Stephan Thober Nov 2016 - adapted write to selected case for routing process
247 ! Robert Schweppe Jun 2018 - refactoring and reformatting
248
250
259 use mo_kind, only : dp, i4
260 use mo_mrm_file, only : version
264 use mo_string_utils, only : num2str
265 use mo_utils, only : ge
266 use mo_os, only : check_path_isdir
267
268 implicit none
269
270 character(256) :: fName
271
272 integer(i4) :: i, iDomain, domainID, j
273
274 integer(i4) :: err
275
276
277 fname = trim(adjustl(dirconfigout)) // trim(adjustl(file_config))
278 call message()
279 call message(' Log-file written to ', trim(fname))
280 !checking whether the directory exists where the file shall be created or opened
281 call check_path_isdir(trim(adjustl(dirconfigout)), raise=.true.)
282 open(uconfig, file = fname, status = 'unknown', action = 'write', iostat = err)
283 if (err .ne. 0) then
284 call error_message(' Problems while creating File. Error-Code ', num2str(err))
285 end if
286 write(uconfig, 200)
287 write(uconfig, 100) 'mRM-UFZ v-' // trim(version)
288 write(uconfig, 100) 'S. Thober, L. Samaniego & R. Kumar, UFZ'
289 write(uconfig, 200)
290 write(uconfig, 100)
291 write(uconfig, 201) ' M A I N mRM C O N F I G U R A T I O N I N F O R M A T I O N '
292 write(uconfig, 100)
293 write(uconfig, 103) 'Number of domains ', domainmeta%nDomains
294 write(uconfig, 103) 'Total No. of gauges ', ngaugestotal
295 write(uconfig, 103) 'Time Step [h] ', timestep
296 do idomain = 1, domainmeta%nDomains
297 domainid = domainmeta%indices(idomain)
298 write(uconfig, 103) 'Total No. of nodes ', level11(idomain)%nCells
299 write(uconfig, 103) 'No. of cells L0 ', level0(domainmeta%L0DataFrom(idomain))%nCells
300 write(uconfig, 103) 'No. of cells L1 ', level1(idomain)%nCells
301 write(uconfig, 103) 'No. of cells L11 ', level11(idomain)%nCells
302
303 ! select case (iFlag_cordinate_sys)
304 ! case (0)
305 write(uconfig, 301) 'domain ', domainid, ' Hydrology Resolution [m] ', resolutionhydrology(idomain)
306 write(uconfig, 301) 'domain ', domainid, ' Routing Resolution [m] ', resolutionrouting(idomain)
307 ! case(1)
308 ! write(uconfig, 302) 'domain ',domainID, ' Hydrology Resolution [o] ', resolutionHydrology(iDomain)
309 ! write(uconfig, 302) 'domain ',domainID, ' Routing Resolution [o] ', resolutionRouting(iDomain)
310 ! end select
311 end do
312 write(uconfig, 126) 'Flag READ restart ', read_restart
313 write(uconfig, 126) 'Flag WRITE restart ', write_restart
314 !
315 !******************
316 ! Model Run period
317 !******************
318 do idomain = 1, domainmeta%nDomains
319 domainid = domainmeta%indices(idomain)
320 write(uconfig, 115) ' Model Run Periods for domain ', num2str(domainid)
321 write(uconfig, 116) &
322 'From To', &
323 ' Day Month Year Day Month Year'
324 write(uconfig, 117) &
325 'Warming Period (1) ', &
326 warmper(idomain)%dStart, warmper(idomain)%mStart, warmper(idomain)%yStart, &
327 warmper(idomain)%dEnd, warmper(idomain)%mEnd, warmper(idomain)%yEnd
328 write(uconfig, 117) &
329 'Evaluation Period (2) ', &
330 evalper(idomain)%dStart, evalper(idomain)%mStart, evalper(idomain)%yStart, &
331 evalper(idomain)%dEnd, evalper(idomain)%mEnd, evalper(idomain)%yEnd
332 write(uconfig, 117) &
333 'Simulation Period (1)+(2) ', &
334 simper(idomain)%dStart, simper(idomain)%mStart, simper(idomain)%yStart, &
335 simper(idomain)%dEnd, simper(idomain)%mEnd, simper(idomain)%yEnd
336 end do
337
338 !*********************************
339 ! Model Land Cover Observations
340 !*********************************
341 if (processmatrix(8, 1) .eq. 1) then
342 do idomain = 1, domainmeta%nDomains
343 domainid = domainmeta%indices(idomain)
344 write(uconfig, 118) ' Land Cover Observations for domain ', num2str(domainid)
345 write(uconfig, 119) ' Start Year', ' End Year', ' Land cover scene', 'Land Cover File'
346 do i = 1, nlcoverscene
347 write(uconfig, 120) lc_year_start(i), lc_year_end(i), &
348 lcyearid(max(evalper(idomain)%yStart, lc_year_start(i)), idomain), trim(lcfilename(i))
349 end do
350 end do
351 end if
352 !*********************************
353 ! Initial Parameter Ranges
354 !*********************************
355 write(uconfig, 121) ' Initial Transfer Function Parameter Ranges (gammas) '
356 !
357 ! Transfer functions
358 write(uconfig, 122) &
359 ' i', ' min', ' max', ' current', &
360 ' name'
361 do i = 1, size(global_parameters, 1)
362 write(uconfig, 123) &
364 trim(adjustl(global_parameters_name(i)))
365 end do
366 ! domain runoff data
367 write(uconfig, 202) ' domain Runoff Data '
368 write(uconfig, 107) ' Gauge No.', ' domain Id', ' Qmax[m3/s]', ' Qmin[m3/s]'
369 do i = 1, ngaugestotal
370 if(any(gauge%Q(:, i) > nodata_dp)) then
371 write(uconfig, 108) i, gauge%domainId(i), maxval(gauge%Q(:, i), gauge%Q(:, i) > nodata_dp), &
372 minval(gauge%Q(:, i), gauge%Q(:, i) > nodata_dp)
373 else
374 write(uconfig, 108) i, gauge%domainId(i), nodata_dp, nodata_dp
375 end if
376 end do
377 ! inflow gauge data
378 if (ninflowgaugestotal .GT. 0) then
379 write(uconfig, 202) ' domain Inflow Data '
380 write(uconfig, 107) ' Gauge No.', ' domain Id', ' Qmax[m3/s]', ' Qmin[m3/s]'
381 do i = 1, ninflowgaugestotal
382 if(all(inflowgauge%Q(:, i) > nodata_dp)) then
383 write(uconfig, 108) i, inflowgauge%domainId(i), maxval(inflowgauge%Q(:, i), inflowgauge%Q(:, i) > nodata_dp), &
384 minval(inflowgauge%Q(:, i), inflowgauge%Q(:, i) > nodata_dp)
385 else
386 write(uconfig, 108) i, inflowgauge%domainId(i), nodata_dp, nodata_dp
387 end if
388 end do
389 end if
390 ! domain config
391 write(uconfig, 218) 'domain-wise Configuration'
392 do idomain = 1, domainmeta%nDomains
393 domainid = domainmeta%indices(idomain)
394 write(uconfig, 103) 'domain No. ', domainid, &
395 'No. of gauges ', domain_mrm(idomain)%nGauges
396
397 write(uconfig, 222) 'Directory list'
398
399 write(uconfig, 224) 'Directory to morphological input ', dirmorpho(idomain)
400 write(uconfig, 224) 'Directory to land cover input ', dirlcover(idomain)
401 write(uconfig, 224) 'Directory to gauging station input ', dirgauges(idomain)
402 if (mrm_coupling_mode .eq. 0) then
403 write(uconfig, 224) 'Directory to simulated runoff input ', dirtotalrunoff(idomain)
404 end if
405 write(uconfig, 224) 'Directory to write output by default ', dirout(idomain)
406 write(uconfig, 224) 'File to write mRM output when restarted ', mrmfilerestartout(idomain)
407
408 write(uconfig, 102) 'River Network (Routing level)'
409 write(uconfig, 100) 'Label 0 = intermediate draining cell '
410 write(uconfig, 100) 'Label 1 = headwater cell '
411 write(uconfig, 100) 'Label 2 = sink cell '
412
413 if (processmatrix(8, 1) .eq. 1_i4) then
414 write(uconfig, 104) ' Overall', &
415 ' From', &
416 ' To', &
417 ' Routing', &
418 ' Label', &
419 ' Length', &
420 ' Mean', &
421 ' Link', &
422 ' Routing', &
423 ' Routing', &
424 ' Sequence', &
425 ' ', &
426 ' ', &
427 ' Slope'
428 !
429 write(uconfig, 105) ' Id', &
430 ' Node', &
431 ' Node', &
432 '', &
433 '', &
434 ' [km]', &
435 ' [o/oo]'
436 !
437 do j = level11(idomain)%iStart, level11(idomain)%iEnd - 1
438 i = l11_netperm(j) + level11(idomain)%iStart - 1 ! adjust permutation for multi-domain option
439 write(uconfig, 106) i, l11_fromn(i), l11_ton(i), l11_rorder(i), l11_label(i), &
440 l11_length(i) / 1000.0_dp, l11_slope(i) * 1.0e3_dp
441 end do
442
443 else if (processmatrix(8, 1) .eq. 2_i4) then
444 write(uconfig, 134) ' Overall', &
445 ' From', &
446 ' To', &
447 ' Routing', &
448 ' Label', &
449 ' Link', &
450 ' Routing', &
451 ' Routing', &
452 ' Sequence', &
453 ' '
454 !
455 write(uconfig, 135) ' Id', &
456 ' Node', &
457 ' Node', &
458 '', &
459 ''
460 !
461 do j = level11(idomain)%iStart, level11(idomain)%iEnd - 1
462 i = l11_netperm(j) + level11(idomain)%iStart - 1 ! adjust permutation for multi-domain option
463 write(uconfig, 136) i, l11_fromn(i), l11_ton(i), l11_rorder(i), l11_label(i)
464 end do
465 end if
466 ! draining node at L11
467 write(uconfig, 109) ' Overall', ' domain', &
468 ' Cell', ' Routing', &
469 ' Id', ' Node Id'
470 do i = level11(idomain)%Id(1), level11(idomain)%Id(level11(idomain)%nCells)
471 write(uconfig, 110) i + level11(idomain)%iStart - 1, i
472 end do
473
474 ! L1 level information
475 write(uconfig, 111) ' Modeling', ' Routing', ' Effective', &
476 ' Cell', ' Cell Id', ' Area', &
477 ' Id', ' [-]', ' [km2]'
478 if (ge(resolutionrouting(idomain), resolutionhydrology(idomain))) then
479 do i = level1(idomain)%Id(1), level1(idomain)%Id(level1(idomain)%nCells)
480 write(uconfig, 113) i + level1(idomain)%iStart - 1, l1_l11_id(i + level1(idomain)%iStart - 1), &
481 level1(idomain)%CellArea(i) * 1.e-6_dp
482 domainid = domainmeta%indices(idomain)
483 end do
484 else
485 do i = level11(idomain)%Id(1), level11(idomain)%Id(level11(idomain)%nCells)
486 write(uconfig, 110) i + level11(idomain)%iStart - 1, l11_l1_id(i + level11(idomain)%iStart - 1)
487 end do
488 end if
489 write(uconfig, 114) ' Total[km2]', sum(level1(idomain)%CellArea) * 1.e-6_dp
490 end do
491
492 write(uconfig, *)
493 close(uconfig)
494
495 !! Formats
496 100 format (a80)
497 102 format (/ 30('-') / a30 / 30('-'))
498 103 format (a20, 10x, i10)
499 104 format (/ 75('-') / 5a10, 5x, 2a10 / 5a10, 5x, 2a10)
500 105 format (5a10, 5x, 2a10 / 75('-'))
501 106 format (5i10, 5x, 2f10.3)
502 107 format (2a10, 2a15)
503 108 format (2i10, 2f15.3)
504 !
505 109 format (/ 20('-') / 2a10 / 2a10 / 2a10 / 20('-'))
506 110 format (2i10)
507 !
508 111 format (/ 30('-') / 3a10 / 3a10 / 3a10 / 30('-'))
509 113 format ( 2i10, 1f10.3 )
510 114 format (30('-') / a15, 5x, 1f10.3 /)
511 !
512 115 format (/61('-')/ a50, a10 /61('-'))
513 116 format (39x, a22 / 25x, a36)
514 117 format (3(a25, 6(i6)))
515 !
516 118 format (/50('-')/ a40, a10 /50('-'))
517 119 format (a10, a10, a20, a20/)
518 120 format (i10, i10, 10x, i10, a20)
519 !
520 121 format (/55('-')/ a55 /55('-'))
521 122 format (a10, 3a15, a35)
522 123 format (i10, 3f15.3, a35)
523 !
524 126 format (a30, 9x, l1)
525 !
526 134 format (/ 50('-') / 5a10 / 5a10)
527 135 format (5a10 / 50('-'))
528 136 format (5i10)
529 !
530 200 format (80('-'))
531 201 format (a80)
532 202 format (/50('-')/ a50 /50('-'))
533 !
534 218 format (/ 80('-')/ 26x, a24, 26x, /80('-'))
535 222 format (/80('-')/ 26x, a21 /80('-'))
536 224 format (a40, 5x, a256)
537
538 301 format (a7, i2, a32, f15.0)
539 ! 302 format (a7, i2, a32,es20.8)
540 end Subroutine write_configfile
541
542 ! ------------------------------------------------------------------
543
544 ! NAME
545 ! write_daily_obs_sim_discharge
546
547 ! PURPOSE
548 !> \brief Write a file for the daily observed and simulated discharge timeseries
549 !> during the evaluation period for each gauging station
550
551 !> \details Write a file for the daily observed and simulated discharge timeseries
552 !> during the evaluation period for each gauging station
553
554 ! INTENT(IN)
555 !> \param[in] "real(dp), dimension(:, :) :: Qobs" daily time series of observed dischargedims = (nModeling_days
556 !> , nGauges_total)
557 !> \param[in] "real(dp), dimension(:, :) :: Qsim" daily time series of modeled dischargedims = (nModeling_days ,
558 !> nGauges_total)
559
560 ! HISTORY
561 !> \authors Rohini Kumar
562
563 !> \date August 2013
564
565 ! Modifications:
566 ! Robert Schweppe Jun 2018 - refactoring and reformatting
567
568 subroutine write_daily_obs_sim_discharge(Qobs, Qsim)
569
573 use mo_errormeasures, only : kge, nse
574 use mo_julian, only : dec2date
577 use mo_string_utils, only : num2str
578 use mo_utils, only : ge
579 use mo_netcdf, only : ncdataset, ncdimension, ncvariable
580
581 implicit none
582
583 ! daily time series of observed dischargedims = (nModeling_days , nGauges_total)
584 real(dp), dimension(:, :), intent(in) :: Qobs
585
586 ! daily time series of modeled dischargedims = (nModeling_days , nGauges_total)
587 real(dp), dimension(:, :), intent(in) :: Qsim
588
589 character(256) :: fName, formHeader, formData, dummy
590
591 integer(i4) :: domainID, iDomain, gg, tt, err
592
593 integer(i4) :: igauge_start, igauge_end
594
595 integer(i4) :: day, month, year
596
597 integer(i4) :: tlength
598
599 ! time axis
600 integer(i4), allocatable, dimension(:) :: taxis
601
602 real(dp) :: newTime
603
604 ! nc related variables
605 type(ncdataset) :: nc_out
606 type(ncdimension) :: dim, dim_bnd
607 type(ncvariable) :: var
608
609 ! initalize igauge_start
610 igauge_start = 1
611
612 ! domain loop
613 do idomain = 1, domainmeta%nDomains
614 domainid = domainmeta%indices(idomain)
615 if(domain_mrm(idomain)%nGauges .lt. 1) cycle
616
617 ! estimate igauge_end
618 igauge_end = igauge_start + domain_mrm(idomain)%nGauges - 1
619
620 ! check the existance of file
621 fname = trim(adjustl(dirout(idomain))) // trim(adjustl(file_daily_discharge))
622 open(udaily_discharge, file = trim(fname), status = 'unknown', action = 'write', iostat = err)
623 if(err .ne. 0) then
624 call error_message(' IOError while openening "', trim(fname), '". Error-Code ', num2str(err))
625 end if
626
627 ! header
628 write(formheader, *) '( 4a8, ', domain_mrm(idomain)%nGauges, '(2X, a5, i10.10, 2X, a5, i10.10) )'
629 write(udaily_discharge, formheader) 'No', 'Day', 'Mon', 'Year', &
630 ('Qobs_', gauge%gaugeId(gg), &
631 'Qsim_', gauge%gaugeId(gg), gg = igauge_start, igauge_end)
632
633 ! form data
634 write(formdata, *) '( 4I8, ', domain_mrm(idomain)%nGauges, '(2X, f15.7 , 2X, f15.7 ) )'
635
636 ! write data
637 newtime = real(evalper(idomain)%julStart, dp) - 0.5_dp
638
639 do tt = 1, (evalper(idomain)%julEnd - evalper(idomain)%julStart + 1)
640 call dec2date(newtime, yy = year, mm = month, dd = day)
641 write(udaily_discharge, formdata) tt, day, month, year, (qobs(tt, gg), qsim(tt, gg), gg = igauge_start, igauge_end)
642 newtime = newtime + 1.0_dp
643 end do
644
645 ! close file
646 close(udaily_discharge)
647
648 ! ======================================================================
649 ! write netcdf file
650 ! ======================================================================
651 fname = trim(adjustl(dirout(idomain))) // trim(adjustl(ncfile_discharge))
652 nc_out = ncdataset(trim(fname), "w")
653 tlength = evalper(idomain)%julEnd - evalper(idomain)%julStart + 1
654 ! write time
655 allocate(taxis(tlength))
656
657 ! tt is dependent on the unit of the time axis and is set to hours in mRM
658 select case( output_time_reference_mrm)
659 case(0)
660 forall(tt = 1 : tlength) taxis(tt) = (tt-1) * 24
661 case(1)
662 forall(tt = 1 : tlength) taxis(tt) = tt * 24 - 12
663 case(2)
664 forall(tt = 1 : tlength) taxis(tt) = tt * 24
665 end select
666
667 call dec2date(real(evalper(idomain)%julStart, dp) - 0.5_dp, yy = year, mm = month, dd = day)
668 dim = nc_out%setDimension("time", tlength)
669 var = nc_out%setVariable("time", "i32", [dim])
670 call var%setData(taxis)
671 call var%setAttribute( &
672 "units", &
673 'hours since '//trim(num2str(year))//'-'//trim(num2str(month, '(i2.2)'))//'-'//trim(num2str(day, '(i2.2)'))//' 00:00:00' &
674 )
675 call var%setAttribute("long_name", "time in hours")
676 call var%setAttribute("bounds", "time_bnds")
677 call var%setAttribute("axis", "T")
678 dim_bnd = nc_out%setDimension("bnds", 2)
679 var = nc_out%setVariable("time_bnds", "i32", [dim_bnd, dim])
680 do tt = 1, tlength
681 call var%setData((tt - 1) * 24, (/1, tt/))
682 call var%setData(tt * 24, (/2, tt/))
683 end do
684 deallocate(taxis)
685 ! write gauges
686 do gg = igauge_start, igauge_end
687 var = nc_out%setVariable('Qsim_' // trim(num2str(gauge%gaugeID(gg), '(i10.10)')), "f64", [dim])
688 call var%setFillValue(nodata_dp)
689 call var%setData(qsim(1 : tlength, gg))
690 call var%setAttribute("units", "m3 s-1")
691 call var%setAttribute("long_name", 'simulated discharge at gauge ' // trim(num2str(gauge%gaugeID(gg), '(i10.10)')))
692 call var%setAttribute("missing_value", nodata_dp)
693 ! write observed discharge at that gauge
694 var = nc_out%setVariable('Qobs_' // trim(num2str(gauge%gaugeID(gg), '(i10.10)')), "f64", [dim])
695 call var%setFillValue(nodata_dp)
696 call var%setData(qobs(1 : tlength, gg))
697 call var%setAttribute("units", "m3 s-1")
698 call var%setAttribute("long_name", 'observed discharge at gauge ' // trim(num2str(gauge%gaugeID(gg), '(i10.10)')))
699 call var%setAttribute("missing_value", nodata_dp)
700 end do
701 call nc_out%close()
702
703 ! ======================================================================
704 ! screen output
705 ! ======================================================================
706
707 ! if ( nMeasPerDay == 1_i4 ) then ! only print daily stats for daily Qobs
708
709 call message()
710 write(dummy, '(I3)') domainid
711 call message(' OUTPUT: saved daily discharge file for domain ', trim(adjustl(dummy)))
712 call message(' to ', trim(fname))
713 do gg = igauge_start, igauge_end
714 if (count(ge(qobs(:, gg), 0.0_dp)) > 1) then
715 call message(' KGE of daily discharge (gauge #', trim(adjustl(num2str(gg))), '): ', &
716 trim(adjustl(num2str(kge(qobs(:, gg), qsim(:, gg), mask = (ge(qobs(:, gg), 0.0_dp)))))))
717 call message(' NSE of daily discharge (gauge #', trim(adjustl(num2str(gg))), '): ', &
718 trim(adjustl(num2str(nse(qobs(:, gg), qsim(:, gg), mask = (ge(qobs(:, gg), 0.0_dp)))))))
719 end if
720 end do
721
722 ! end if
723
724 ! update igauge_start
725 igauge_start = igauge_end + 1
726 !
727 end do
728 !
729 end subroutine write_daily_obs_sim_discharge
730
731
732 ! ------------------------------------------------------------------
733
734 ! NAME
735 ! write_subdaily_obs_sim_discharge
736
737 ! PURPOSE
738 !> \brief Write a file for the simulated discharge timeseries
739 !> during the evaluation period for each gauging station
740
741 !> \details Write a file for the simulated discharge timeseries
742 !> during the evaluation period for each gauging station
743
744 ! INTENT(IN)
745 !> \param[in] "real(dp), dimension(:, :) :: Qobs" time series of observed discharge dims = (nMeasTimeSteps ,
746 !> nGauges_total)
747 !> \param[in] "real(dp), dimension(:, :) :: Qsim" time series of modeled discharge dims = (nMeasTimeSteps ,
748 !> nGauges_total)
749 !> \param[in] "integer(i4), :: factor" ratio of modelled time steps per day to observation time steps per day
750
751 ! HISTORY
752 !> \authors Rohini Kumar
753
754 !> \date August 2013
755
756 ! Modifications:
757 ! Robert Schweppe Jun 2018 - refactoring and reformatting
758 ! Pallav Shrestha Jul 2021 - ported for printing out simulations at hourly time step
759 ! Pallav Shrestha, Husain Najafi Mar 2022 - refactoring for subdaily timestep output
760
761 subroutine write_subdaily_obs_sim_discharge(Qobs, Qsim, factor)
762
766 use mo_errormeasures, only : kge, nse
767 use mo_julian, only : dec2date
771 use mo_string_utils, only : num2str
772 use mo_utils, only : ge
773 use mo_netcdf, only : ncdataset, ncdimension, ncvariable
774
775 implicit none
776
777 ! time series of observed discharge. dims = (nMeasTimeSteps , nGauges_total)
778 real(dp), dimension(:, :), intent(in) :: Qobs
779
780 ! time series of modeled discharge. dims = (nMeasTimeSteps , nGauges_total)
781 real(dp), dimension(:, :), intent(in) :: Qsim
782
783 ! ratio of modelled time steps per day to observation time steps per day
784 integer(i4), intent(in) :: factor
785
786 character(256) :: fName, formHeader, formData, dummy
787
788 integer(i4) :: domainID, iDomain, gg, tt, err
789
790 integer(i4) :: igauge_start, igauge_end
791
792 integer(i4) :: hour, day, month, year
793
794 integer(i4) :: tlength
795
796 ! time axis
797 integer(i4), allocatable, dimension(:) :: taxis
798
799 real(dp) :: newTime
800
801 ! nc related variables
802 type(ncdataset) :: nc_out
803 type(ncdimension) :: dim, dim_bnd
804 type(ncvariable) :: var
805
806 ! use minutes if needed
807 logical :: use_minutes
808 integer(i4) :: time_unit_factor
809
810 ! initalize igauge_start
811 igauge_start = 1
812
813 ! domain loop
814 do idomain = 1, domainmeta%nDomains
815 domainid = domainmeta%indices(idomain)
816 if(domain_mrm(idomain)%nGauges .lt. 1) cycle
817
818 ! estimate igauge_end
819 igauge_end = igauge_start + domain_mrm(idomain)%nGauges - 1
820
821
822 ! ======================================================================
823 ! write text file
824 ! ======================================================================
825
826 ! check the existance of file
827 fname = trim(adjustl(dirout(idomain))) // trim(adjustl(file_subdaily_discharge))
828 open(usubdaily_discharge, file = trim(fname), status = 'unknown', action = 'write', iostat = err)
829 if(err .ne. 0) then
830 call error_message(' IOError while openening "', trim(fname), '". Error-Code ', num2str(err))
831 end if
832
833 ! header
834 write(formheader, *) '( 5a8, ', domain_mrm(idomain)%nGauges, '(2X, a5, i10.10, 2X, a5, i10.10) )'
835 write(usubdaily_discharge, formheader) 'No', 'Hour', 'Day', 'Mon', 'Year', &
836 ('Qobs_', gauge%gaugeId(gg), &
837 'Qsim_', gauge%gaugeId(gg), gg = igauge_start, igauge_end)
838
839 ! form data
840 write(formdata, *) '( 5I8, ', domain_mrm(idomain)%nGauges, '(2X, f15.7 , 2X, f15.7 ) )'
841
842 ! write data
843 newtime = real(evalper(idomain)%julStart, dp) - 0.5_dp
844
845 do tt = 1, (evalper(idomain)%julEnd - evalper(idomain)%julStart + 1) * nmeasperday
846 call dec2date(newtime, yy = year, mm = month, dd = day, hh = hour)
847 write(usubdaily_discharge, formdata) tt, hour, day, month, year, (qobs(tt, gg), qsim(tt, gg), gg = igauge_start, igauge_end)
848 newtime = newtime + 1.0_dp / real(nmeasperday, dp)
849 end do
850
851 ! close file
853
854 ! ======================================================================
855 ! write netcdf file
856 ! ======================================================================
857 fname = trim(adjustl(dirout(idomain))) // trim(adjustl(ncfile_subdaily_discharge))
858 nc_out = ncdataset(trim(fname), "w")
859 tlength = (evalper(idomain)%julEnd - evalper(idomain)%julStart + 1) * nmeasperday
860 ! write time
861 allocate(taxis(tlength))
862
863 use_minutes = .false.
864 time_unit_factor = 1
865 if ( mod(factor, 2) == 1 ) then
866 use_minutes = .true.
867 time_unit_factor = 60
868 end if
869
870 ! tt is dependent on the unit of the time axis and is set to hours in mRM
871 select case( output_time_reference_mrm)
872 case(0)
873 forall(tt = 1 : tlength) taxis(tt) = (tt-1) * factor * time_unit_factor
874 case(1)
875 forall(tt = 1 : tlength) taxis(tt) = tt * factor - factor * time_unit_factor / 2
876 case(2)
877 forall(tt = 1 : tlength) taxis(tt) = tt * factor * time_unit_factor
878 end select
879
880 call dec2date(real(evalper(idomain)%julStart, dp) - 0.5_dp, yy = year, mm = month, dd = day, hh = hour)
881 dim = nc_out%setDimension("time", tlength)
882 var = nc_out%setVariable("time", "i32", [dim])
883 call var%setData(taxis)
884 if (use_minutes) then
885 call var%setAttribute( &
886 "units", &
887 'minutes since '//trim(num2str(year))//'-'//trim(num2str(month, '(i2.2)'))//'-'//trim(num2str(day, '(i2.2)'))//' '// &
888 trim(num2str(hour, '(i2.2)'))//':00:00' &
889 )
890 call var%setAttribute("long_name", "time in minutes")
891 else
892 call var%setAttribute( &
893 "units", &
894 'hours since '//trim(num2str(year))//'-'//trim(num2str(month, '(i2.2)'))//'-'//trim(num2str(day, '(i2.2)'))//' '// &
895 trim(num2str(hour, '(i2.2)'))//':00:00' &
896 )
897 call var%setAttribute("long_name", "time in hours")
898 end if
899 call var%setAttribute("bounds", "time_bnds")
900 call var%setAttribute("axis", "T")
901 dim_bnd = nc_out%setDimension("bnds", 2)
902 var = nc_out%setVariable("time_bnds", "i32", [dim_bnd, dim])
903 do tt = 1, tlength
904 call var%setData((tt - 1) * factor * time_unit_factor, (/1, tt/))
905 call var%setData(tt * factor * time_unit_factor, (/2, tt/))
906 end do
907 deallocate(taxis)
908 ! write gauges
909 do gg = igauge_start, igauge_end
910 var = nc_out%setVariable('Qsim_' // trim(num2str(gauge%gaugeID(gg), '(i10.10)')), "f64", [dim])
911 call var%setFillValue(nodata_dp)
912 call var%setData(qsim(1 : tlength, gg))
913 call var%setAttribute("units", "m3 s-1")
914 call var%setAttribute("long_name", 'simulated discharge at gauge ' // trim(num2str(gauge%gaugeID(gg), '(i10.10)')))
915 call var%setAttribute("missing_value", nodata_dp)
916 ! write observed discharge at that gauge
917 var = nc_out%setVariable('Qobs_' // trim(num2str(gauge%gaugeID(gg), '(i10.10)')), "f64", [dim])
918 call var%setFillValue(nodata_dp)
919 call var%setData(qobs(1 : tlength, gg))
920 call var%setAttribute("units", "m3 s-1")
921 call var%setAttribute("long_name", 'observed discharge at gauge ' // trim(num2str(gauge%gaugeID(gg), '(i10.10)')))
922 call var%setAttribute("missing_value", nodata_dp)
923 end do
924 call nc_out%close()
925
926 ! ======================================================================
927 ! screen output
928 ! ======================================================================
929 call message()
930 write(dummy, '(I3)') domainid
931 call message(' OUTPUT: saved subdaily discharge file for domain ', trim(adjustl(dummy)))
932 call message(' to ', trim(fname))
933 do gg = igauge_start, igauge_end
934 if (count(ge(qobs(:, gg), 0.0_dp)) > 1) then
935 call message(' KGE of subdaily discharge (gauge #', trim(adjustl(num2str(gg))), '): ', &
936 trim(adjustl(num2str(kge(qobs(:, gg), qsim(:, gg), mask = (ge(qobs(:, gg), 0.0_dp)))))))
937 call message(' NSE of subdaily discharge (gauge #', trim(adjustl(num2str(gg))), '): ', &
938 trim(adjustl(num2str(nse(qobs(:, gg), qsim(:, gg), mask = (ge(qobs(:, gg), 0.0_dp)))))))
939 end if
940 end do
941
942 ! update igauge_start
943 igauge_start = igauge_end + 1
944 !
945 end do
946 !
948
949 ! ------------------------------------------------------------------
950
951 ! NAME
952 ! mrm_write_optifile
953
954 ! PURPOSE
955 !> \brief Write briefly final optimization results.
956
957 !> \details Write overall best objective function and the best optimized parameter set to a file_opti.
958
959 ! INTENT(IN)
960 !> \param[in] "real(dp) :: best_OF" best objective function value as returnedby the
961 !> optimization routine
962 !> \param[in] "real(dp), dimension(:) :: best_paramSet" best associated global parameter setCalled only
963 !> when optimize is .TRUE.
964 !> \param[in] "character(len = *), dimension(:) :: param_names"
965
966 ! HISTORY
967 !> \authors David Schaefer
968
969 !> \date July 2013
970
971 ! Modifications:
972 ! Rohini Kumar Aug 2013 - change in structure of the code including call statements
973 ! Juliane Mai Oct 2013 - clear parameter names added
974 ! - double precision written
975 ! Stephan Thober Oct 2015 - ported to mRM
976 ! Robert Schweppe Jun 2018 - refactoring and reformatting
977
978 subroutine mrm_write_optifile(best_OF, best_paramSet, param_names)
979
982 use mo_string_utils, only : num2str
983
984 implicit none
985
986 ! best objective function value as returnedby the optimization routine
987 real(dp), intent(in) :: best_of
988
989 ! best associated global parameter setCalled only when optimize is .TRUE.
990 real(dp), dimension(:), intent(in) :: best_paramset
991
992 character(len = *), dimension(:), intent(in) :: param_names
993
994 character(256) :: fname, formheader, formparams
995
996 integer(i4) :: ii, err, n_params
997
998
999 ! number of parameters
1000 n_params = size(best_paramset)
1001
1002 ! open file
1003 fname = trim(adjustl(dirconfigout)) // trim(adjustl(file_opti))
1004 open(uopti, file = fname, status = 'unknown', action = 'write', iostat = err, recl = (n_params + 1) * 40)
1005 if(err .ne. 0) then
1006 call error_message(' IOError while openening "', trim(fname), '" Error-Code ', num2str(err))
1007 end if
1008
1009 ! header
1010 write(formheader, *) '(a40,', n_params, 'a40)'
1011 ! len(param_names(1))=256 but only 39 characters taken here
1012 ! write(uopti, formHeader) 'OF', (trim(adjustl(param_names(ii))), ii=1, n_params)
1013 write(uopti, formheader) 'OF', (trim(adjustl(param_names(ii)(1 : 39))), ii = 1, n_params)
1014
1015 ! output
1016 write(formparams, *) '( es40.14, ', n_params, '(es40.14) )'
1017 write(uopti, formparams) best_of, (best_paramset(ii), ii = 1, n_params)
1018
1019 ! close file
1020 close(uopti)
1021
1022 ! screen output
1023 call message()
1024 call message(' Optimized parameters written to ', trim(fname))
1025
1026 end subroutine mrm_write_optifile
1027
1028 ! ------------------------------------------------------------------
1029
1030 ! NAME
1031 ! mrm_write_optinamelist
1032
1033 ! PURPOSE
1034 !> \brief Write final, optimized parameter set in a namelist format.
1035
1036 !> \details Write final, optimized parameter set in a namelist format.
1037
1038 ! INTENT(IN)
1039 !> \param[in] "real(dp), dimension(:, :) :: parameters" (min, max, opti)
1040 !> \param[in] "logical, dimension(size(parameters, 1)) :: maskpara" .true. if parameter was
1041 !> calibrated
1042 !> \param[in] "character(len = *), dimension(size(parameters, 1)) :: parameters_name" clear names of parameters
1043
1044 ! HISTORY
1045 !> \authors Juliane Mai
1046
1047 !> \date Dec 2013
1048
1049 ! Modifications:
1050 ! Stephan Thober Oct 2015 - adapted to mRM
1051 ! Stephan Thober Nov 2016 - adapt header to routing process
1052 ! Robert Schweppe Jun 2018 - refactoring and reformatting
1053
1054 subroutine mrm_write_optinamelist(parameters, maskpara, parameters_name)
1055
1058 use mo_string_utils, only : num2str
1059
1060 implicit none
1061
1062 ! (min, max, opti)
1063 real(dp), dimension(:, :), intent(in) :: parameters
1064
1065 ! .true. if parameter was calibrated
1066 logical, dimension(size(parameters, 1)), intent(in) :: maskpara
1067
1068 ! clear names of parameters
1069 character(len = *), dimension(size(parameters, 1)), intent(in) :: parameters_name
1070
1071 character(256) :: fname
1072
1073 character(3) :: flag
1074
1075 integer(i4) :: err
1076
1077 integer(i4) :: ipar
1078
1079
1080 ! open file
1081 fname = trim(adjustl(dirconfigout)) // trim(adjustl(file_opti_nml))
1082 open(uopti_nml, file = fname, status = 'unknown', action = 'write', iostat = err)
1083 if(err .ne. 0) then
1084 call message (' IOError while openening "', trim(fname), '" Error-Code ', num2str(err))
1085 end if
1086
1087 write(uopti_nml, *) '!global_parameters'
1088 write(uopti_nml, *) '!PARAMETER lower_bound upper_bound value FLAG SCALING'
1089
1090 write(uopti_nml, *) '! ', trim(adjustl('routing'))
1091
1092 if (processmatrix(8, 1) .eq. 1_i4) write(uopti_nml, *) '&routing1'
1093 if (processmatrix(8, 1) .eq. 2_i4) write(uopti_nml, *) '&routing2'
1094 if (processmatrix(8, 1) .eq. 3_i4) write(uopti_nml, *) '&routing3'
1095
1096 do ipar = 1, size(parameters, 1)
1097 if (maskpara(ipar)) then
1098 flag = ' 1 '
1099 else
1100 flag = ' 0 '
1101 end if
1102 write(uopti_nml, *) trim(adjustl(parameters_name(ipar))), ' = ', &
1103 parameters(ipar, 1), ' , ', &
1104 parameters(ipar, 2), ' , ', &
1105 parameters(ipar, 3), ' , ', &
1106 flag, ', 1 '
1107 end do
1108
1109 write(uopti_nml, *) '/'
1110 write(uopti_nml, *) ' '
1111
1112 ! close file
1113 close(uopti_nml)
1114
1115 ! screen output
1116 call message()
1117 call message(' Optimized parameters written in namelist format to ', trim(fname))
1118
1119 end subroutine mrm_write_optinamelist
1120
1121
1122end module mo_mrm_write
Provides constants commonly used by mHM, mRM and MPR.
real(dp), parameter, public nodata_dp
Provides file names and units for mRM.
integer, parameter uconfig
Unit for file defining mHM's outputs.
character(len= *), parameter file_config
file defining mHM's outputs
Provides file names and units for mHM.
integer, parameter uopti
Unit for file optimization outputs (objective and parameter set)
character(len=*), parameter file_opti
file defining optimization outputs (objective and parameter set)
character(len=*), parameter file_opti_nml
file defining optimization outputs in a namelist format (parameter set)
integer, parameter uopti_nml
Unit for file optimization outputs in a namelist format (parameter set)
Provides structures needed by mHM, mRM and/or mpr.
type(period), dimension(:), allocatable, public warmper
real(dp), dimension(:), allocatable, public resolutionrouting
integer(i4), dimension(:), allocatable, public warmingdays
integer(i4), dimension(:, :), allocatable, public lcyearid
type(period), dimension(:), allocatable, public simper
type(period), dimension(:), allocatable, public evalper
Provides structures needed by mHM, mRM and/or mpr.
real(dp), dimension(:), allocatable, public resolutionhydrology
logical, public write_restart
real(dp), dimension(:, :), allocatable, target, public global_parameters
character(256), dimension(:), allocatable, public lcfilename
character(256), dimension(:), allocatable, public global_parameters_name
type(domain_meta), public domainmeta
character(256), public dirconfigout
integer(i4), public nlcoverscene
character(256), dimension(:), allocatable, public dirlcover
integer(i4), dimension(:), allocatable, public lc_year_end
character(256), dimension(:), allocatable, public dirout
character(256), dimension(:), allocatable, public dirmorpho
integer(i4), dimension(nprocesses, 3), public processmatrix
character(256), dimension(:), allocatable, public mrmfilerestartout
type(grid), dimension(:), allocatable, target, public level1
type(grid), dimension(:), allocatable, target, public level0
integer(i4), dimension(:), allocatable, public lc_year_start
Provides file names and units for mRM.
integer, parameter udaily_discharge
Unit for file optimazation outputs.
integer, parameter usubdaily_discharge
Unit for file optimazation outputs.
character(len=*), parameter version
Current mHM model version.
character(len=*), parameter ncfile_subdaily_discharge
file containing simulated discharge at observat time step
character(len=*), parameter file_daily_discharge
file defining optimazation outputs
character(len=*), parameter file_subdaily_discharge
file defining optimazation outputs
character(len=*), parameter ncfile_discharge
file defining optimazation outputs
Global variables for mRM only.
type(gaugingstation), public inflowgauge
integer(i4), dimension(:), allocatable, public l11_netperm
integer(i4), dimension(:), allocatable, public l11_l1_id
integer(i4), dimension(:), allocatable, public l1_l11_id
integer(i4), dimension(:), allocatable, public l11_label
real(dp), dimension(:, :), allocatable, public mrm_runoff
character(256), dimension(:), allocatable, public dirgauges
integer(i4) output_time_reference_mrm
time reference point location in output nc files
type(gaugingstation), public gauge
integer(i4), dimension(:), allocatable, public l11_fromn
real(dp), dimension(:), allocatable, public l11_length
integer(i4), dimension(:), allocatable, public l11_ton
type(domaininfo_mrm), dimension(:), allocatable, target, public domain_mrm
type(grid), dimension(:), allocatable, target, public level11
real(dp), dimension(:), allocatable, public l11_slope
character(256), dimension(:), allocatable, public dirtotalrunoff
integer(i4), public ninflowgaugestotal
integer(i4), dimension(:), allocatable, public l11_rorder
Restart routines.
subroutine, public mrm_write_restart(idomain, domainid, outfile)
write routing states and configuration
Creates NetCDF output for different fluxes and state variables of mHM.
write of discharge and restart files
subroutine write_daily_obs_sim_discharge(qobs, qsim)
Write a file for the daily observed and simulated discharge timeseries during the evaluation period f...
subroutine, public mrm_write_optifile(best_of, best_paramset, param_names)
Write briefly final optimization results.
subroutine, public mrm_write_optinamelist(parameters, maskpara, parameters_name)
Write final, optimized parameter set in a namelist format.
subroutine write_subdaily_obs_sim_discharge(qobs, qsim, factor)
Write a file for the simulated discharge timeseries during the evaluation period for each gauging sta...
subroutine, public mrm_write
write discharge and restart files
subroutine write_configfile
This modules writes the results of the configuration into an ASCII-file.