15 use mo_kind,
only: i4, dp
16 use mo_message,
only: message, error_message
17 use mo_string_utils,
only: num2str
37 subroutine mhm_interface_init(namelist_mhm, namelist_mhm_param, namelist_mhm_output, namelist_mrm_output, cwd)
87 use mo_os,
only: change_dir
91 character(*),
optional,
intent(in) :: namelist_mhm
92 character(*),
optional,
intent(in) :: namelist_mhm_param
93 character(*),
optional,
intent(in) :: namelist_mhm_output
94 character(*),
optional,
intent(in) :: namelist_mrm_output
95 character(*),
optional,
intent(in) :: cwd
97 integer(i4) :: domainid, idomain
101 integer(i4) :: nproc, rank
107 if (
present(namelist_mhm_output))
file_defoutput = namelist_mhm_output
108 if (
present(namelist_mrm_output)) mrm_file_defoutput = namelist_mrm_output
110 if (
present(cwd))
call change_dir(cwd)
139 call mpi_comm_size(
domainmeta%comMaster, nproc, ierror)
141 call mpi_comm_rank(
domainmeta%comMaster, rank, ierror)
146 if (rank > 0 .and.
domainmeta%isMasterInComLocal)
then
151 call message(
' Read data ...')
157 call message(
' in ', trim(num2str(timer_get(
itimer),
'(F9.3)')),
' seconds.')
162 call message(
' Initialize domains ...')
167 call message(
' in ', trim(num2str(timer_get(
itimer),
'(F9.3)')),
' seconds.')
172 call message(
' Read forcing and optional data ...')
214 call message(
' in ', trim(num2str(timer_get(
itimer),
'(F9.3)')),
' seconds.')
231 real(dp),
dimension(:),
allocatable,
intent(out) :: para
245 integer(i4),
intent(out) :: n
259 use mo_timer,
only: &
269 integer(i4) :: nproc, rank
271 call mpi_comm_size(
domainmeta%comMaster, nproc, ierror)
273 call mpi_comm_rank(
domainmeta%comMaster, rank, ierror)
286 if (rank > 0 .and.
domainmeta%isMasterInComLocal)
then
289 call message(
' Run mHM')
293 call message(
' in ', trim(num2str(timer_get(
itimer),
'(F12.3)')),
' seconds.')
306 objective_subprocess, &
320 use mo_timer,
only: &
334 procedure(
mhm_eval),
pointer :: eval
335 procedure(
objective),
pointer :: obj_func
338 logical,
dimension(:),
allocatable :: maskpara
343 integer(i4) :: nproc, rank
345 call mpi_comm_size(
domainmeta%comMaster, nproc, ierror)
347 call mpi_comm_rank(
domainmeta%comMaster, rank, ierror)
351 call message(
' Run mHM optimization')
357 case(1 : 9, 14, 31 : 32)
361 if (rank == 0 .and.
domainmeta%isMasterInComLocal)
then
375 case(10 : 13, 15, 17, 27, 28, 29, 30, 33, 34)
379 if (rank == 0 .and.
domainmeta%isMasterInComLocal)
then
380 obj_func => objective_master
387 call objective_subprocess(eval)
394 call error_message(
'***ERROR: mhm_driver: The given objective function number ', &
395 trim(adjustl(num2str(
opti_function))),
' in mhm.nml is not valid!')
399 if (rank == 0 .and.
domainmeta%isMasterInComLocal)
then
413 call message(
' in ', trim(num2str(timer_get(
itimer),
'(F12.3)')),
' seconds.')
429 use mo_timer,
only: &
442 integer(i4) :: nproc, rank
444 call mpi_comm_size(
domainmeta%comMaster, nproc, ierror)
446 call mpi_comm_rank(
domainmeta%comMaster, rank, ierror)
447 if (rank > 0 .and.
domainmeta%isMasterInComLocal)
then
456 call message(
' Write restart file')
460 call message(
' in ', trim(num2str(timer_get(
itimer),
'(F9.3)')),
' seconds.')
Module to clean up after a mHM run.
subroutine, public deallocate_global_variables()
Deallocate all global variables.
Reading of main model configurations.
subroutine, public check_optimization_settings
check optimization settings
subroutine, public common_mhm_mrm_read_config(file_namelist)
Read main configurations for common parts.
Provides structures needed by mHM, mRM and/or mpr.
integer(i4) mrm_coupling_mode
integer(i4), public opti_function
type(period), dimension(:), allocatable, public simper
integer(i4), public timestep
logical, public read_restart
Reading of main model configurations.
subroutine, public common_read_config(file_namelist)
Read main configurations commonly used by mHM, mRM and MPR.
Provides structures needed by mHM, mRM and/or mpr.
character(256), dimension(:), allocatable, public mhmfilerestartout
logical, public write_restart
real(dp), dimension(:, :), allocatable, target, public global_parameters
character(256), dimension(:), allocatable, public global_parameters_name
type(domain_meta), public domainmeta
character(256), public dirconfigout
integer(i4), dimension(nprocesses, 3), public processmatrix
type(grid), dimension(:), allocatable, target, public level1
type(grid), dimension(:), allocatable, target, public level0
Provides file names and units for mHM.
character(:), allocatable file_namelist_mhm_param
Parameter namelists file name.
character(:), allocatable file_namelist_mhm
Namelist file name.
character(:), allocatable file_defoutput
file defining mHM's outputs
Main global variables for mHM.
type(meteo_handler_type), public meteo_handler
the meteo handler class
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(couple_cfg_type), public couple_cfg
coupling configuration class
type(optidata), dimension(:), allocatable, public l1_smobs
type(optidata), dimension(:), allocatable, public l1_etobs
Module to calculate BFI form gauging stations in mHM.
subroutine, public calculate_bfi()
Calculate BFI from given discharge observation.
Runs mhm with a specific parameter set and returns required variables, e.g.
subroutine, public mhm_eval(parameterset, opti_domain_indices, runoff, smoptisim, neutronsoptisim, etoptisim, twsoptisim, bfi)
Runs mhm with a specific parameter set and returns required variables, e.g.
Module providing interfaces for mHM.
subroutine, public mhm_interface_init(namelist_mhm, namelist_mhm_param, namelist_mhm_output, namelist_mrm_output, cwd)
initialize mHM from given namelist paths.
subroutine, public mhm_interface_run()
Run mHM with current settings.
subroutine, public mhm_interface_get_parameter(para)
Get current global parameter value of mHM.
subroutine, public mhm_interface_get_parameter_number(n)
Get number of current global parameter value of mHM.
subroutine, public mhm_interface_run_optimization()
Run mHM optimization with current settings.
subroutine, public mhm_interface_finalize()
Write mHM restart.
subroutine, public domain_dir_check_message()
Check input directories for mHM.
subroutine, public startup_message()
write startup message of mHM.
subroutine, public finish_message()
Finish message for mHM.
Reading of main model configurations.
subroutine, public mhm_read_config(file_namelist)
Read main configurations for mHM.
subroutine, public mpr_read_config(file_namelist, file_namelist_param)
Read the general config of mpr.
Provides file names and units for mRM.
Wrapper for initializing Routing.
subroutine, public mrm_configuration(file_namelist, file_namelist_param)
read mRM configuration from namelists
subroutine, public mrm_init(file_namelist, file_namelist_param)
Initialize all mRM variables at all levels (i.e., L0, L1, and L11).
Objective Functions for Optimization of mHM/mRM against runoff.
real(dp) function, public single_objective_runoff(parameterset, eval, arg1, arg2, arg3)
Wrapper for objective functions optimizing agains runoff.
subroutine, public single_objective_runoff_subprocess(eval, arg1, arg2, arg3)
Wrapper for objective functions optimizing agains runoff.
real(dp) function, public single_objective_runoff_master(parameterset, eval, arg1, arg2, arg3)
Wrapper for objective functions optimizing agains runoff.
write of discharge and restart files
subroutine, public mrm_write
write discharge and restart files
Objective Functions for Optimization of mHM.
real(dp) function, public objective(parameterset, eval, arg1, arg2, arg3)
Wrapper for objective functions.
Wrapper subroutine for optimization against runoff and sm.
subroutine, public optimization(eval, objective, dirconfigout, funcbest, maskpara)
Wrapper for optimization.
Read optional data for mHM calibration.
subroutine, public readoptidataobs(idomain, domainid, l1_optiobs)
Read evapotranspiration data from NetCDF file for calibration.
Wrapper for all reading routines.
subroutine, public read_data(laiper)
Reads data.
reading and writing states, fluxes and configuration for restart of mHM.
subroutine, public write_restart_files(outfile)
write restart files for each domain
Startup procedures for mHM.
subroutine, public mhm_initialize
Initialize main mHM variables.
Module to write ascii file output.
subroutine, public write_configfile(dirprecipitation, dirreferenceet, dirtemperature)
This modules writes the results of the configuration into an ASCII-file.
subroutine, public write_optinamelist(processmatrix, parameters, maskpara, parameters_name)
Write final, optimized parameter set in a namelist format.
subroutine, public write_optifile(best_of, best_paramset, param_names)
Write briefly final optimization results.