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)
92 use mo_os,
only: change_dir
96 character(*),
optional,
intent(in) :: namelist_mhm
97 character(*),
optional,
intent(in) :: namelist_mhm_param
98 character(*),
optional,
intent(in) :: namelist_mhm_output
99 character(*),
optional,
intent(in) :: namelist_mrm_output
100 character(*),
optional,
intent(in) :: cwd
102 integer(i4) :: domainid, idomain
106 integer(i4) :: nproc, rank
112 if (
present(namelist_mhm_output))
file_defoutput = namelist_mhm_output
113 if (
present(namelist_mrm_output)) mrm_file_defoutput = namelist_mrm_output
115 if (
present(cwd))
call change_dir(cwd)
144 call mpi_comm_size(
domainmeta%comMaster, nproc, ierror)
146 call mpi_comm_rank(
domainmeta%comMaster, rank, ierror)
151 if (rank > 0 .and.
domainmeta%isMasterInComLocal)
then
156 call message(
' Read data ...')
162 call message(
' in ', trim(num2str(timer_get(
itimer),
'(F9.3)')),
' seconds.')
167 call message(
' Initialize domains ...')
172 call message(
' in ', trim(num2str(timer_get(
itimer),
'(F9.3)')),
' seconds.')
177 call message(
' Read forcing and optional data ...')
219 call message(
' in ', trim(num2str(timer_get(
itimer),
'(F9.3)')),
' seconds.')
236 real(dp),
dimension(:),
allocatable,
intent(out) :: para
250 integer(i4),
intent(out) :: n
264 use mo_timer,
only: &
274 integer(i4) :: nproc, rank
276 call mpi_comm_size(
domainmeta%comMaster, nproc, ierror)
278 call mpi_comm_rank(
domainmeta%comMaster, rank, ierror)
291 if (rank > 0 .and.
domainmeta%isMasterInComLocal)
then
294 call message(
' Run mHM')
298 call message(
' in ', trim(num2str(timer_get(
itimer),
'(F12.3)')),
' seconds.')
319 use mo_timer,
only: &
326 objective_subprocess, &
343 procedure(
mhm_eval),
pointer :: eval
344 procedure(
objective),
pointer :: obj_func
347 logical,
dimension(:),
allocatable :: maskpara
352 integer(i4) :: nproc, rank
354 call mpi_comm_size(
domainmeta%comMaster, nproc, ierror)
356 call mpi_comm_rank(
domainmeta%comMaster, rank, ierror)
360 call message(
' Run mHM optimization')
366 case(1 : 9, 14, 31 : 32)
370 if (rank == 0 .and.
domainmeta%isMasterInComLocal)
then
384 case(10 : 13, 15, 17, 27, 28, 29, 30, 33, 34)
388 if (rank == 0 .and.
domainmeta%isMasterInComLocal)
then
389 obj_func => objective_master
396 call objective_subprocess(eval)
403 call error_message(
'***ERROR: mhm_driver: The given objective function number ', &
404 trim(adjustl(num2str(
opti_function))),
' in mhm.nml is not valid!')
408 if (rank == 0 .and.
domainmeta%isMasterInComLocal)
then
422 call message(
' in ', trim(num2str(timer_get(
itimer),
'(F12.3)')),
' seconds.')
438 use mo_timer,
only: &
451 integer(i4) :: nproc, rank
453 call mpi_comm_size(
domainmeta%comMaster, nproc, ierror)
455 call mpi_comm_rank(
domainmeta%comMaster, rank, ierror)
456 if (rank > 0 .and.
domainmeta%isMasterInComLocal)
then
465 call message(
' Write restart file')
469 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 common_mhm_mrm_read_config(file_namelist, unamelist)
Read main configurations for common parts.
subroutine, public check_optimization_settings
check optimization settings
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, unamelist)
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.
integer, parameter unamelist_mhm_param
Unit for namelist.
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
integer, parameter unamelist_mhm
Unit for namelist.
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, unamelist)
Read main configurations for mHM.
subroutine, public mpr_read_config(file_namelist, unamelist, file_namelist_param, unamelist_param)
Read the general config of mpr.
Provides file names and units for mRM.
Wrapper for initializing Routing.
subroutine, public mrm_configuration(file_namelist, unamelist, file_namelist_param, unamelist_param)
read mRM configuration from namelists
subroutine, public mrm_init(file_namelist, unamelist, file_namelist_param, unamelist_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.