Skip to content

Commit

Permalink
Merge pull request #1303 from MJHarrison-GFDL/ensemble_manager_infra
Browse files Browse the repository at this point in the history
Rename MOM_ensemble_manager to MOM_ensemble_manager_infra
  • Loading branch information
Hallberg-NOAA authored Jan 27, 2021
2 parents 790ffbe + b6d6f82 commit 5a938c8
Show file tree
Hide file tree
Showing 2 changed files with 122 additions and 8 deletions.
34 changes: 26 additions & 8 deletions src/framework/MOM_ensemble_manager.F90
Original file line number Diff line number Diff line change
@@ -1,18 +1,36 @@
!> A simple (very thin) wrapper for managing ensemble member layout information
!> Manages ensemble member layout information
module MOM_ensemble_manager

! This file is part of MOM6. See LICENSE.md for the license.

use ensemble_manager_mod, only : ensemble_manager_init, ensemble_pelist_setup
use ensemble_manager_mod, only : get_ensemble_id, get_ensemble_size
use ensemble_manager_mod, only : get_ensemble_pelist, get_ensemble_filter_pelist
use MOM_ensemble_manager_infra, only : ensemble_manager_init
use MOM_ensemble_manager_infra, only : ensemble_pelist_setup
use MOM_ensemble_manager_infra, only : get_ensemble_id
use MOM_ensemble_manager_infra, only : get_ensemble_size
use MOM_ensemble_manager_infra, only : get_ensemble_pelist
use MOM_ensemble_manager_infra, only : get_ensemble_filter_pelist

implicit none ; private

public :: ensemble_manager_init, ensemble_pelist_setup
public :: get_ensemble_id, get_ensemble_size
public :: get_ensemble_pelist, get_ensemble_filter_pelist
!> Public functions:
!> mom_ensemble_manager_infra:ensemble_manager_init
public :: ensemble_manager_init
!> mom_ensemble_manager_infra:ensemble_pelist_setup
public :: ensemble_pelist_setup
!> mom_ensemble_manager_infra:get_ensemble_id
public :: get_ensemble_id
!> mom_ensemble_manager_infra:get_ensemble_size
public :: get_ensemble_size
!> mom_ensemble_manager_infra:get_ensemble_pelist
public :: get_ensemble_pelist
!> mom_ensemble_manager_infra:get_ensemble_filter_pelist
public :: get_ensemble_filter_pelist



! There need to be documented APIs in this module.

end module MOM_ensemble_manager

!> \namespace mom_ensemble_manager
!!
!! APIs are defined and implemented in MOM_ensemble_manager_infra
96 changes: 96 additions & 0 deletions src/framework/MOM_ensemble_manager_infra.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
!> A simple (very thin) wrapper for managing ensemble member layout information
module MOM_ensemble_manager_infra

! This file is part of MOM6. See LICENSE.md for the license.

use ensemble_manager_mod, only : FMS_ensemble_manager_init => ensemble_manager_init
use ensemble_manager_mod, only : FMS_ensemble_pelist_setup => ensemble_pelist_setup
use ensemble_manager_mod, only : FMS_get_ensemble_id => get_ensemble_id
use ensemble_manager_mod, only : FMS_get_ensemble_size => get_ensemble_size
use ensemble_manager_mod, only : FMS_get_ensemble_pelist => get_ensemble_pelist
use ensemble_manager_mod, only : FMS_get_ensemble_filter_pelist => get_ensemble_filter_pelist

implicit none ; private

public :: ensemble_manager_init, ensemble_pelist_setup
public :: get_ensemble_id, get_ensemble_size
public :: get_ensemble_pelist, get_ensemble_filter_pelist

contains

!> Initializes the ensemble manager which divides available resources
!! in order to concurrently execute an ensemble of model realizations.
subroutine ensemble_manager_init()

call FMS_ensemble_manager_init()

end subroutine ensemble_manager_init

!> Create a list of processing elements (PEs) across components
!! associated with the current ensemble member.
subroutine ensemble_pelist_setup(concurrent, atmos_npes, ocean_npes, land_npes, ice_npes, &
Atm_pelist, Ocean_pelist, Land_pelist, Ice_pelist)
logical, intent(in) :: concurrent !< A logical flag, if True, then
!! ocean fast PEs are run concurrently with
!! slow PEs within the coupler.
integer, intent(in) :: atmos_npes !< The number of atmospheric (fast) PEs
integer, intent(in) :: ocean_npes !< The number of ocean (slow) PEs
integer, intent(in) :: land_npes !< The number of land PEs (fast)
integer, intent(in) :: ice_npes !< The number of ice (fast) PEs
integer, dimension(:), intent(inout) :: Atm_pelist !< A list of Atm PEs
integer, dimension(:), intent(inout) :: Ocean_pelist !< A list of Ocean PEs
integer, dimension(:), intent(inout) :: Land_pelist !< A list of Land PEs
integer, dimension(:), intent(inout) :: Ice_pelist !< A list of Ice PEs


call FMS_ensemble_pelist_setup(concurrent, atmos_npes, ocean_npes, land_npes, ice_npes, &
Atm_pelist, Ocean_pelist, Land_pelist, Ice_pelist)

end subroutine ensemble_pelist_setup

!> Returns the numeric id for the current ensemble member
function get_ensemble_id()
integer :: get_ensemble_id

get_ensemble_id = FMS_get_ensemble_id()

end function get_ensemble_id

!> Returns ensemble information as follows,
!! index (1) :: ensemble size
!! index (2) :: Number of PEs per ensemble member
!! index (3) :: Number of ocean PEs per ensemble member
!! index (4) :: Number of atmos PEs per ensemble member
!! index (5) :: Number of land PEs per ensemble member
!! index (6) :: Number of ice PEs per ensemble member
function get_ensemble_size()
integer, dimension(6) :: get_ensemble_size

get_ensemble_size = FMS_get_ensemble_size()

end function get_ensemble_size

!> Returns the list of PEs associated with all ensemble members
!! Results are stored in the argument array which ust be large
!! enough to contain the list. If the optional name argument is present,
!! the returned processor list are for a particular component (atmos, ocean ,land, ice)
subroutine get_ensemble_pelist(pelist, name)
integer, intent(inout) :: pelist(:,:) !< A processor list for all ensemble members
character(len=*), intent(in), optional :: name !< An optional component name (atmos, ocean, land, ice)

call FMS_get_ensemble_pelist(pelist,name)

end subroutine get_ensemble_pelist

!> Returns the list of PEs associated with an ensemble filter application.
!! If the optional name argument is present, the returned list is for a
!! particular component (atmos, ocean ,land, ice)
subroutine get_ensemble_filter_pelist(pelist, name)
integer, intent(inout) :: pelist(:) !< A processor list for the ensemble filter
character(len=*), intent(in) :: name !< An optional component name (atmos, ocean, land, ice)

call FMS_get_Ensemble_filter_pelist(pelist,name)

end subroutine get_ensemble_filter_pelist

end module MOM_ensemble_manager_infra

0 comments on commit 5a938c8

Please sign in to comment.