Skip to content

Commit

Permalink
Added methods to return domain/grid shape
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
alperaltuntas committed Jul 13, 2017
1 parent 37e7356 commit 57e6086
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
13 changes: 12 additions & 1 deletion src/core/MOM_grid.F90
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module MOM_grid

use MOM_hor_index, only : hor_index_type, hor_index_init
use MOM_domains, only : MOM_domain_type, get_domain_extent, compute_block_extent
use MOM_domains, only : get_global_shape
use MOM_error_handler, only : MOM_error, MOM_mesg, FATAL
use MOM_file_parser, only : get_param, log_param, log_version, param_file_type

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

public MOM_grid_init, MOM_grid_end, set_derived_metrics, set_first_direction
public isPointInCell, hor_index_type
public isPointInCell, hor_index_type, get_global_grid_size

!> Ocean grid type. See mom_grid for details.
type, public :: ocean_grid_type
Expand Down Expand Up @@ -443,6 +444,16 @@ subroutine set_first_direction(G, y_first)
G%first_direction = y_first
end subroutine set_first_direction

!> Return global shape of horizontal grid
subroutine get_global_grid_size(G, niglobal, njglobal)
type(ocean_grid_type), intent(inout) :: G !< The horizontal grid type
integer, intent(out) :: niglobal !< i-index global size of grid
integer, intent(out) :: njglobal !< j-index global size of grid

call get_global_shape(G%domain, niglobal, njglobal)

end subroutine get_global_grid_size

!> Allocate memory used by the ocean_grid_type and related structures.
subroutine allocate_metrics(G)
type(ocean_grid_type), intent(inout) :: G !< The horizontal grid type
Expand Down
13 changes: 12 additions & 1 deletion src/framework/MOM_domains.F90
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ module MOM_domains
public :: To_East, To_West, To_North, To_South, To_All, Omit_Corners
public :: create_group_pass, do_group_pass, group_pass_type
public :: start_group_pass, complete_group_pass
public :: compute_block_extent
public :: compute_block_extent, get_global_shape

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

end subroutine get_domain_extent

!> Returns the global shape of h-point arrays
subroutine get_global_shape(domain, niglobal, njglobal)
type(MOM_domain_type), intent(in) :: domain !< MOM domain
integer, intent(out) :: niglobal !< i-index global size of h-point arrays
integer, intent(out) :: njglobal !< j-index global size of h-point arrays

niglobal = domain%niglobal
njglobal = domain%njglobal

end subroutine get_global_shape

end module MOM_domains

0 comments on commit 57e6086

Please sign in to comment.