Skip to content

Commit 9bfc6e8

Browse files
committed
Add capability to use multiple diagnostics downsampling levels in MOM6
- This commit presents an enhancement of diag downsampling workflow for MOM6 - It allows an arbitrary number of downsampling factors in the same run (if they are commensurate with grid processor layout) - The number of downsampling levels should be specified in MOM override parameters E.g., #override NUM_DIAG_DOWNSAMP_LEV = 3 - The downampling factors should be specified E.g., #override DIAG_DOWNSAMP_LEVS = 2,4,5 - The required downsampled domains and axes are then generated at the initialization by MOM_diag_mediator No need for other modules to know anything about the downsampling scheme. - No need for a #define MAX_DSAMP_LEVEL, everything is allocated at runtime - Since everything is allocated at runtime users need to be congnisent of the number of levels they request. - Any downsampling diagnostics can be put in diag_table , only the levels that requested in parameters are handled - The overall dependence of downsampling levels on the grid shape and pe layout remains Only levels should be requested where NIGLOBAL/x_layout and NJGLOBAL/y_layout are divisible by downsampling factor
1 parent 0d0d310 commit 9bfc6e8

4 files changed

Lines changed: 220 additions & 175 deletions

File tree

config_src/infra/FMS2/MOM_diag_manager_infra.F90

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,17 +111,15 @@ integer function MOM_diag_axis_init(name, data, units, cart_name, long_name, MOM
111111
endif ; endif
112112

113113
if (present(MOM_domain)) then
114-
coarsening = 1 ; if (present(coarsen)) coarsening = coarsen
115-
if (coarsening == 1) then
114+
coarsening = 0 ; if (present(coarsen)) coarsening = coarsen
115+
if (coarsening == 0) then
116116
MOM_diag_axis_init = fms_axis_init(name, data, units, cart_name, long_name=long_name, &
117117
direction=direction, set_name=set_name, edges=edges, &
118118
domain2=MOM_domain%mpp_domain, domain_position=position)
119-
elseif (coarsening == 2) then
119+
else
120120
MOM_diag_axis_init = fms_axis_init(name, data, units, cart_name, long_name=long_name, &
121121
direction=direction, set_name=set_name, edges=edges, &
122-
domain2=MOM_domain%mpp_domain_d2, domain_position=position)
123-
else
124-
call MOM_error(FATAL, "diag_axis_init called with an invalid value of coarsen.")
122+
domain2=MOM_domain%mpp_domain_d(coarsening), domain_position=position)
125123
endif
126124
else
127125
if (present(coarsen)) then ; if (coarsen /= 1) then

config_src/infra/FMS2/MOM_domain_infra.F90

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ module MOM_domain_infra
133133
character(len=64) :: name !< The name of this domain
134134
type(domain2D), pointer :: mpp_domain => NULL() !< The FMS domain with halos
135135
!! on this processor, centered at h points.
136-
type(domain2D), pointer :: mpp_domain_d2 => NULL() !< A coarse FMS domain with halos
136+
type(domain2D), pointer :: mpp_domain_d(:) => NULL() !< A coarse FMS domain with halos
137137
!! on this processor, centered at h points.
138138
integer :: niglobal !< The total horizontal i-domain size.
139139
integer :: njglobal !< The total horizontal j-domain size.
@@ -1371,14 +1371,12 @@ subroutine create_MOM_domain(MOM_dom, n_global, n_halo, reentrant, tripolar_N, l
13711371
integer, dimension(4) :: global_indices ! The lower and upper global i- and j-index bounds
13721372
integer :: X_FLAGS ! A combination of integers encoding the x-direction grid connectivity.
13731373
integer :: Y_FLAGS ! A combination of integers encoding the y-direction grid connectivity.
1374-
integer :: xhalo_d2, yhalo_d2
13751374
character(len=200) :: mesg ! A string for use in error messages
13761375
logical :: mask_table_exists ! Mask_table is present and the file it points to exists
13771376

13781377
if (.not.associated(MOM_dom)) then
13791378
allocate(MOM_dom)
13801379
allocate(MOM_dom%mpp_domain)
1381-
allocate(MOM_dom%mpp_domain_d2)
13821380
endif
13831381

13841382
MOM_dom%name = "MOM" ; if (present(domain_name)) MOM_dom%name = trim(domain_name)
@@ -1446,11 +1444,6 @@ subroutine create_MOM_domain(MOM_dom, n_global, n_halo, reentrant, tripolar_N, l
14461444

14471445
call clone_MD_to_d2D(MOM_dom, MOM_dom%mpp_domain)
14481446

1449-
!For downsampled domain, recommend a halo of 1 (or 0?) since we're not doing wide-stencil computations.
1450-
!But that does not work because the downsampled field would not have the correct size to pass the checks, e.g., we get
1451-
!error: downsample_diag_indices_get: peculiar size 28 in i-direction\ndoes not match one of 24 25 26 27
1452-
! call clone_MD_to_d2D(MOM_dom, MOM_dom%mpp_domain_d2, halo_size=(MOM_dom%nihalo/2), coarsen=2)
1453-
call clone_MD_to_d2D(MOM_dom, MOM_dom%mpp_domain_d2, coarsen=2)
14541447
end subroutine create_MOM_domain
14551448

14561449
!> dealloc_MOM_domain deallocates memory associated with a pointer to a MOM_domain_type
@@ -1468,9 +1461,8 @@ subroutine deallocate_MOM_domain(MOM_domain, cursory)
14681461
if (invasive) call mpp_deallocate_domain(MOM_domain%mpp_domain)
14691462
deallocate(MOM_domain%mpp_domain)
14701463
endif
1471-
if (associated(MOM_domain%mpp_domain_d2)) then
1472-
if (invasive) call mpp_deallocate_domain(MOM_domain%mpp_domain_d2)
1473-
deallocate(MOM_domain%mpp_domain_d2)
1464+
if (associated(MOM_domain%mpp_domain_d)) then
1465+
deallocate(MOM_domain%mpp_domain_d)
14741466
endif
14751467
if (associated(MOM_domain%maskmap)) deallocate(MOM_domain%maskmap)
14761468
deallocate(MOM_domain)
@@ -1582,7 +1574,6 @@ subroutine clone_MD_to_MD(MD_in, MOM_dom, min_halo, halo_size, symmetric, domain
15821574
if (.not.associated(MOM_dom)) then
15831575
allocate(MOM_dom)
15841576
allocate(MOM_dom%mpp_domain)
1585-
allocate(MOM_dom%mpp_domain_d2)
15861577
endif
15871578

15881579
! Save the extra data for creating other domains of different resolution that overlay this domain
@@ -1704,7 +1695,6 @@ subroutine clone_MD_to_MD(MD_in, MOM_dom, min_halo, halo_size, symmetric, domain
17041695
endif
17051696

17061697
call clone_MD_to_d2D(MOM_dom, MOM_dom%mpp_domain, xextent=exni, yextent=exnj)
1707-
call clone_MD_to_d2D(MOM_dom, MOM_dom%mpp_domain_d2, domain_name=MOM_dom%name, coarsen=2)
17081698

17091699
end subroutine clone_MD_to_MD
17101700

@@ -1836,20 +1826,18 @@ subroutine get_domain_extent_MD(Domain, isc, iec, jsc, jec, isd, ied, jsd, jed,
18361826
local = .true. ; if (present(local_indexing)) local = local_indexing
18371827
ind_off = 0 ; if (present(index_offset)) ind_off = index_offset
18381828

1839-
coarsen_lev = 1 ; if (present(coarsen)) coarsen_lev = coarsen
1829+
coarsen_lev = 0 ; if (present(coarsen)) coarsen_lev = coarsen
18401830

1841-
if (coarsen_lev == 1) then
1831+
if (coarsen_lev == 0) then
18421832
call mpp_get_compute_domain(Domain%mpp_domain, isc, iec, jsc, jec)
18431833
call mpp_get_data_domain(Domain%mpp_domain, isd, ied, jsd, jed)
18441834
call mpp_get_global_domain(Domain%mpp_domain, isg_, ieg_, jsg_, jeg_)
1845-
elseif (coarsen_lev == 2) then
1846-
if (.not.associated(Domain%mpp_domain_d2)) call MOM_error(FATAL, &
1847-
"get_domain_extent called with coarsen=2, but Domain%mpp_domain_d2 is not associated.")
1848-
call mpp_get_compute_domain(Domain%mpp_domain_d2, isc, iec, jsc, jec)
1849-
call mpp_get_data_domain(Domain%mpp_domain_d2, isd, ied, jsd, jed)
1850-
call mpp_get_global_domain(Domain%mpp_domain_d2, isg_, ieg_, jsg_, jeg_)
18511835
else
1852-
call MOM_error(FATAL, "get_domain_extent called with an unsupported level of coarsening.")
1836+
if (.not.associated(Domain%mpp_domain_d)) call MOM_error(FATAL, &
1837+
"get_domain_extent called with coarsen_lev, but Domain%mpp_domain_d(coarsen_lev) is not associated.")
1838+
call mpp_get_compute_domain(Domain%mpp_domain_d(coarsen_lev), isc, iec, jsc, jec)
1839+
call mpp_get_data_domain(Domain%mpp_domain_d(coarsen_lev), isd, ied, jsd, jed)
1840+
call mpp_get_global_domain(Domain%mpp_domain_d(coarsen_lev), isg_, ieg_, jsg_, jeg_)
18531841
endif
18541842

18551843
if (local) then

src/core/MOM_grid.F90

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ module MOM_grid
2929
type(MOM_domain_type), pointer :: Domain => NULL() !< Ocean model domain
3030
type(MOM_domain_type), pointer :: Domain_aux => NULL() !< A non-symmetric auxiliary domain type.
3131
type(hor_index_type) :: HI !< Horizontal index ranges
32-
type(hor_index_type) :: HId2 !< Horizontal index ranges for level-2-downsampling
32+
type(hor_index_type), allocatable :: HId(:) !< Horizontal index ranges for downsampling
3333

3434
integer :: isc !< The start i-index of cell centers within the computational domain
3535
integer :: iec !< The end i-index of cell centers within the computational domain
@@ -402,23 +402,6 @@ subroutine MOM_grid_init(G, param_file, US, HI, global_indexing, bathymetry_at_v
402402
if ( G%block(nblocks)%jed+G%block(nblocks)%jdg_offset > G%HI%jed + G%HI%jdg_offset ) &
403403
call MOM_error(FATAL, "MOM_grid_init: G%jed_bk > G%jed")
404404

405-
call get_domain_extent(G%Domain, G%HId2%isc, G%HId2%iec, G%HId2%jsc, G%HId2%jec, &
406-
G%HId2%isd, G%HId2%ied, G%HId2%jsd, G%HId2%jed, &
407-
G%HId2%isg, G%HId2%ieg, G%HId2%jsg, G%HId2%jeg, coarsen=2)
408-
409-
! Set array sizes for fields that are discretized at tracer cell boundaries.
410-
G%HId2%IscB = G%HId2%isc ; G%HId2%JscB = G%HId2%jsc
411-
G%HId2%IsdB = G%HId2%isd ; G%HId2%JsdB = G%HId2%jsd
412-
G%HId2%IsgB = G%HId2%isg ; G%HId2%JsgB = G%HId2%jsg
413-
if (G%symmetric) then
414-
G%HId2%IscB = G%HId2%isc-1 ; G%HId2%JscB = G%HId2%jsc-1
415-
G%HId2%IsdB = G%HId2%isd-1 ; G%HId2%JsdB = G%HId2%jsd-1
416-
G%HId2%IsgB = G%HId2%isg-1 ; G%HId2%JsgB = G%HId2%jsg-1
417-
endif
418-
G%HId2%IecB = G%HId2%iec ; G%HId2%JecB = G%HId2%jec
419-
G%HId2%IedB = G%HId2%ied ; G%HId2%JedB = G%HId2%jed
420-
G%HId2%IegB = G%HId2%ieg ; G%HId2%JegB = G%HId2%jeg
421-
422405
end subroutine MOM_grid_init
423406

424407
!> set_derived_metrics calculates metric terms that are derived from other metrics.

0 commit comments

Comments
 (0)