14 USE mo_kind,
ONLY : i4, dp
15 use mo_message,
only: error_message
53 use mo_message,
only : message
54 use mo_string_utils,
only : num2str
59 character(*),
intent(in) :: file_namelist
62 integer(i4),
dimension(nProcesses) :: processcase
64 character(256),
dimension(maxNoDomains) :: dir_morpho
66 character(256),
dimension(maxNoDomains) :: mhm_file_restartout
68 character(256),
dimension(maxNoDomains) :: mrm_file_restartout
70 character(256),
dimension(maxNoDomains) :: dir_lcover
72 character(256),
dimension(maxNoDomains) :: dir_out
74 character(256),
dimension(maxNoDomains) :: file_latlon
76 real(dp),
dimension(maxNoDomains) :: resolution_hydrology
78 integer(i4),
dimension(maxNoDomains) :: l0domain
80 integer(i4),
dimension(maxNoDomains) :: read_opt_domain_data
83 integer(i4),
dimension(maxNLCovers) :: lcoveryearstart
86 integer(i4),
dimension(maxNLCovers) :: lcoveryearend
89 character(256),
dimension(maxNLCovers) :: lcoverfname
91 integer(i4) :: i, newdomainid, domainid, idomain, ndomains
122 call error_message(
'***ERROR: Number of domains is resticted to ', trim(num2str(
maxnodomains)),
'!')
145 newdomainid = l0domain(domainid)
149 do i = 1, idomain - 1
150 if (newdomainid ==
domainmeta%indices(i))
then
160 call error_message(
'***ERROR: coordinate system for the model run should be 0 or 1')
196 domainmeta%optidata(idomain) = read_opt_domain_data(domainid)
197 dirmorpho(idomain) = dir_morpho(domainid)
200 dirlcover(idomain) = dir_lcover(domainid)
201 dirout(idomain) = dir_out(domainid)
237 use mo_string_utils,
only : num2str
241 type(
period),
dimension(:),
intent(in) :: sim_per
242 integer(i4),
dimension(:, :),
allocatable,
intent(inout) :: lcyear_id
244 integer(i4) :: ii, idomain
249 call error_message(
'***ERROR: Land cover for warming period is missing!', raise=.false.)
250 call error_message(
' SimStart : ', trim(num2str(minval(sim_per(1 :
domainmeta%nDomains)%yStart))), raise=.false.)
251 call error_message(
' LCoverStart: ', trim(num2str(
lc_year_start(1))))
254 call error_message(
'***ERROR: Land cover period shorter than modelling period!', raise=.false.)
255 call error_message(
' SimEnd : ', trim(num2str(maxval(sim_per(1 :
domainmeta%nDomains)%yEnd))), raise=.false.)
259 allocate(lcyear_id(minval(sim_per(1 :
domainmeta%nDomains)%yStart) : maxval(sim_per(1 :
domainmeta%nDomains)%yEnd), &
265 if ((
lc_year_end(ii) .LT. sim_per(idomain)%yStart) .OR. &
269 else if ((
lc_year_start(ii) .LE. sim_per(idomain)%yStart) .AND. &
271 lcyear_id(sim_per(idomain)%yStart : sim_per(idomain)%yEnd, idomain) = ii
274 else if ((
lc_year_start(ii) .LE. sim_per(idomain)%yStart) .AND. &
276 lcyear_id(sim_per(idomain)%yStart :
lc_year_end(ii), idomain) = ii
278 else if ((
lc_year_start(ii) .GT. sim_per(idomain)%yStart) .AND. &
280 lcyear_id(
lc_year_start(ii) : sim_per(idomain)%yEnd, idomain) = ii
322 integer(i4),
intent(in) :: nDomains
323 integer(i4),
dimension(:),
intent(in) :: optiData
329 integer(i4) :: iDomain
330 integer(i4) :: colDomain, colMasters
332 domainmeta%overallNumberOfDomains = ndomains
335 call mpi_comm_size(comm, nproc, ierror)
337 call mpi_comm_rank(comm, rank, ierror)
339 call error_message(
'at least 2 processes are required')
342 if (nproc > domainmeta%overallNumberOfDomains + 1)
then
343 domainmeta%nDomains = 0
346 call init_domain_variable_for_master(domainmeta, colmasters, coldomain)
352 call distribute_processes_to_domains_according_to_role(optidata, rank, &
353 domainmeta, colmasters, coldomain)
361 call mpi_comm_split(comm, colmasters, rank, domainmeta%comMaster, ierror)
362 call mpi_comm_split(comm, coldomain, rank, domainmeta%comLocal, ierror)
363 call mpi_comm_size(domainmeta%comMaster, nproc, ierror)
367 call mpi_comm_dup(comm, domainmeta%comMaster, ierror)
368 domainmeta%isMasterInComLocal = .true.
369 domainmeta%nDomains = 0
372 domainmeta%nDomains = domainmeta%overallNumberOfDomains
373 allocate(domainmeta%indices(domainmeta%nDomains))
374 do idomain = 1, domainmeta%nDomains
375 domainmeta%indices(idomain) = idomain
379 call distributedomainsroundrobin(nproc, rank, domainmeta)
383 domainmeta%nDomains = ndomains
384 allocate(domainmeta%indices(domainmeta%nDomains))
385 do idomain = 1, domainmeta%nDomains
386 domainmeta%indices(idomain) = idomain
393 subroutine init_domain_variable_for_master(domainMeta, colMasters, colDomain)
396 integer(i4),
intent(out) :: colMasters
397 integer(i4),
intent(out) :: colDomain
399 integer(i4) :: iDomain
401 domainmeta%nDomains = domainmeta%overallNumberOfDomains
402 allocate(domainmeta%indices(domainmeta%nDomains))
403 do idomain = 1, domainmeta%nDomains
404 domainmeta%indices(idomain) = idomain
408 domainmeta%isMasterInComLocal = .true.
410 end subroutine init_domain_variable_for_master
412 subroutine distributedomainsroundrobin(nproc, rank, domainMeta)
414 integer(i4),
intent(in) :: nproc
415 integer(i4),
intent(in) :: rank
418 integer(i4) :: iDomain, iProcDomain
420 do idomain = 1 , domainmeta%overallNumberOfDomains
421 if (rank == (modulo(idomain + nproc - 2, (nproc - 1)) + 1))
then
422 domainmeta%nDomains = domainmeta%nDomains + 1
425 allocate(domainmeta%indices(domainmeta%nDomains))
427 do idomain = 1 , domainmeta%overallNumberOfDomains
428 if (rank == (modulo(idomain + nproc - 2, (nproc - 1)) + 1))
then
429 iprocdomain = iprocdomain + 1
430 domainmeta%indices(iprocdomain) = idomain
433 end subroutine distributedomainsroundrobin
435 subroutine distribute_processes_to_domains_according_to_role(optiData, rank, &
436 domainMeta, colMasters, colDomain)
438 integer(i4),
dimension(:),
intent(in) :: optiData
439 integer(i4),
intent(in) :: rank
441 integer(i4),
intent(out) :: colMasters
442 integer(i4),
intent(out) :: colDomain
445 integer(i4) :: nDomainsAll, nTreeDomains, i, iDomain
446 integer(i4),
dimension(:),
allocatable :: treeDomainList
448 ndomainsall = domainmeta%overallNumberOfDomains
450 do idomain = 1, ndomainsall
452 if (optidata(idomain) == 1)
then
453 ntreedomains = ntreedomains + 1
456 allocate(treedomainlist(ntreedomains))
458 do idomain = 1, ndomainsall
459 if (optidata(idomain) == 1)
then
461 treedomainlist(i) = idomain
464 if (rank < ndomainsall + 1)
then
467 domainmeta%isMasterInComLocal = .true.
468 domainmeta%nDomains = 1
469 allocate(domainmeta%indices(domainmeta%nDomains))
470 domainmeta%indices(1) = rank
473 if (ntreedomains > 0)
then
474 coldomain = treedomainlist(mod(rank, ntreedomains) + 1)
478 domainmeta%isMasterInComLocal = .false.
479 domainmeta%nDomains = 1
480 allocate(domainmeta%indices(domainmeta%nDomains))
483 domainmeta%indices(1) = 1
485 deallocate(treedomainlist)
494 use mo_string_utils,
only : num2str
496 integer(i4),
dimension(maxNoDomains),
intent(in) ::L0Domain
497 integer(i4),
intent(in) :: nDomains
502 if (l0domain(i) < 0)
call error_message( &
503 "L0Domain values need to be positive: ", &
504 "L0Domain(", trim(adjustl(num2str(i))),
") = ", trim(adjustl(num2str(l0domain(i)))))
505 if (l0domain(i) > i)
call error_message( &
506 "L0Domain values need to be less or equal to the domain index: ", &
507 "L0Domain(", trim(adjustl(num2str(i))),
") = ", trim(adjustl(num2str(l0domain(i)))))
510 if (l0domain(i) < l0domain(i-1))
call error_message( &
511 "L0Domain values need to be increasing: ", &
512 "L0Domain(", trim(adjustl(num2str(i-1))),
") = ", trim(adjustl(num2str(l0domain(i-1)))), &
513 ", L0Domain(", trim(adjustl(num2str(i))),
") = ", trim(adjustl(num2str(l0domain(i)))))
516 if (l0domain(i) < i)
then
517 if (l0domain(l0domain(i)) /= l0domain(i))
call error_message( &
518 "L0Domain values should be taken from a domain with its own L0 data: ", &
519 "L0Domain(", trim(adjustl(num2str(i))),
") = ", trim(adjustl(num2str(l0domain(i)))), &
520 ", L0Domain(", trim(adjustl(num2str(l0domain(i)))),
") = ", trim(adjustl(num2str(l0domain(l0domain(i))))))
Provides constants commonly used by mHM, mRM and MPR.
integer(i4), parameter, public maxnodomains
integer(i4), parameter, public maxnlcovers
integer(i4), parameter, public nodata_i4
Reading of main model configurations.
subroutine check_l0domain(l0domain, ndomains)
subroutine, public set_land_cover_scenes_id(sim_per, lcyear_id)
Set land cover scenes IDs.
subroutine init_domain_variable(ndomains, optidata, domainmeta)
Initialization of the domain variables.
subroutine, public common_read_config(file_namelist)
Read main configurations commonly used by mHM, mRM and MPR.
Provides common types needed by mHM, mRM and/or mpr.
Provides structures needed by mHM, mRM and/or mpr.
integer(i4), parameter, public nprocesses
character(256), dimension(:), allocatable, public filelatlon
character(256), dimension(:), allocatable, public mhmfilerestartout
character(1024), public history
details on version/creation date
character(1024), public setup_description
any specific description of simulation
real(dp), dimension(:), allocatable, public resolutionhydrology
logical, public write_restart
character(256), dimension(:), allocatable, public lcfilename
type(domain_meta), public domainmeta
character(1024), public project_details
project including funding instituion., PI, etc.
character(1024), public contact
contact details, incl.
character(256), public dirconfigout
character(256), public conventions
convention used for dataset
character(1024), public simulation_type
e.g.
integer(i4), public nuniquel0domains
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), public dircommonfiles
character(256), dimension(:), allocatable, public dirmorpho
integer(i4), public iflag_cordinate_sys
integer(i4), dimension(nprocesses, 3), public processmatrix
character(256), dimension(:), allocatable, public mrmfilerestartout
character(1024), public mhm_details
developing institution, specific mHM revision
integer(i4), dimension(:), allocatable, public lc_year_start
Module containing all namelists representations.
type(nml_lcover_t), public nml_lcover
'LCover' namelist content
type(nml_processselection_t), public nml_processselection
'processSelection' namelist content
type(nml_mainconfig_t), public nml_mainconfig
'mainconfig' namelist content
type(nml_project_description_t), public nml_project_description
'project_description' namelist content
type(nml_directories_general_t), public nml_directories_general
'directories_general' namelist content
DOMAIN general description.