Skip to content

Commit 57e6086

Browse files
committed
Added methods to return domain/grid shape
- get_global_shape() returns niglobal, njglobal from domain type. - get_global_grid_shape() returns niglobal, njglobal by calling get_global_shape(). - This avoids exposing members inside opaque types otherwise needed for initializing under MCT.
1 parent 37e7356 commit 57e6086

2 files changed

Lines changed: 24 additions & 2 deletions

File tree

src/core/MOM_grid.F90

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ module MOM_grid
55

66
use MOM_hor_index, only : hor_index_type, hor_index_init
77
use MOM_domains, only : MOM_domain_type, get_domain_extent, compute_block_extent
8+
use MOM_domains, only : get_global_shape
89
use MOM_error_handler, only : MOM_error, MOM_mesg, FATAL
910
use MOM_file_parser, only : get_param, log_param, log_version, param_file_type
1011

@@ -13,7 +14,7 @@ module MOM_grid
1314
#include <MOM_memory.h>
1415

1516
public MOM_grid_init, MOM_grid_end, set_derived_metrics, set_first_direction
16-
public isPointInCell, hor_index_type
17+
public isPointInCell, hor_index_type, get_global_grid_size
1718

1819
!> Ocean grid type. See mom_grid for details.
1920
type, public :: ocean_grid_type
@@ -443,6 +444,16 @@ subroutine set_first_direction(G, y_first)
443444
G%first_direction = y_first
444445
end subroutine set_first_direction
445446

447+
!> Return global shape of horizontal grid
448+
subroutine get_global_grid_size(G, niglobal, njglobal)
449+
type(ocean_grid_type), intent(inout) :: G !< The horizontal grid type
450+
integer, intent(out) :: niglobal !< i-index global size of grid
451+
integer, intent(out) :: njglobal !< j-index global size of grid
452+
453+
call get_global_shape(G%domain, niglobal, njglobal)
454+
455+
end subroutine get_global_grid_size
456+
446457
!> Allocate memory used by the ocean_grid_type and related structures.
447458
subroutine allocate_metrics(G)
448459
type(ocean_grid_type), intent(inout) :: G !< The horizontal grid type

src/framework/MOM_domains.F90

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ module MOM_domains
6060
public :: To_East, To_West, To_North, To_South, To_All, Omit_Corners
6161
public :: create_group_pass, do_group_pass, group_pass_type
6262
public :: start_group_pass, complete_group_pass
63-
public :: compute_block_extent
63+
public :: compute_block_extent, get_global_shape
6464

6565
interface pass_var
6666
module procedure pass_var_3d, pass_var_2d
@@ -1599,4 +1599,15 @@ subroutine get_domain_extent(Domain, isc, iec, jsc, jec, isd, ied, jsd, jed, &
15991599

16001600
end subroutine get_domain_extent
16011601

1602+
!> Returns the global shape of h-point arrays
1603+
subroutine get_global_shape(domain, niglobal, njglobal)
1604+
type(MOM_domain_type), intent(in) :: domain !< MOM domain
1605+
integer, intent(out) :: niglobal !< i-index global size of h-point arrays
1606+
integer, intent(out) :: njglobal !< j-index global size of h-point arrays
1607+
1608+
niglobal = domain%niglobal
1609+
njglobal = domain%njglobal
1610+
1611+
end subroutine get_global_shape
1612+
16021613
end module MOM_domains

0 commit comments

Comments
 (0)