Skip to content

Commit 72aef61

Browse files
committed
Adding inerface changes to infra/FMS1
- This commit adds the corresponding interface chages to infre/FMS1 per reviewer request - It also changes the domain_name="MOM_domain_d" // char(48+dlfac) per reviewer request
1 parent 1749248 commit 72aef61

5 files changed

Lines changed: 27 additions & 39 deletions

File tree

config_src/infra/FMS1/MOM_diag_manager_infra.F90

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,12 @@ integer function MOM_diag_axis_init(name, data, units, cart_name, long_name, MOM
9595
!! describes the edges of this axis
9696
character(len=*), &
9797
optional, intent(in) :: set_name !< A name to use for this set of axes.
98-
integer, optional, intent(in) :: coarsen !< An optional degree of coarsening for the grid, 1
99-
!! by default.
98+
integer, optional, intent(in) :: coarsen !< An optional degree of coarsening for the grid, 0
99+
!! by default. This is the index of the coarsening level.
100100
logical, optional, intent(in) :: null_axis !< If present and true, return the special null axis
101101
!! id for use with scalars.
102102

103-
integer :: coarsening ! The degree of grid coarsening
103+
integer :: coarsening ! The degree of grid coarsening, this is the index of an array of coarsening levels
104104

105105
if (present(null_axis)) then ; if (null_axis) then
106106
! Return the special null axis id for scalars
@@ -109,17 +109,15 @@ integer function MOM_diag_axis_init(name, data, units, cart_name, long_name, MOM
109109
endif ; endif
110110

111111
if (present(MOM_domain)) then
112-
coarsening = 1 ; if (present(coarsen)) coarsening = coarsen
113-
if (coarsening == 1) then
112+
coarsening = 0 ; if (present(coarsen)) coarsening = coarsen
113+
if (coarsening == 0) then
114114
MOM_diag_axis_init = fms_axis_init(name, data, units, cart_name, long_name=long_name, &
115115
direction=direction, set_name=set_name, edges=edges, &
116116
domain2=MOM_domain%mpp_domain, domain_position=position)
117-
elseif (coarsening == 2) then
117+
else
118118
MOM_diag_axis_init = fms_axis_init(name, data, units, cart_name, long_name=long_name, &
119119
direction=direction, set_name=set_name, edges=edges, &
120-
domain2=MOM_domain%mpp_domain_d2, domain_position=position)
121-
else
122-
call MOM_error(FATAL, "diag_axis_init called with an invalid value of coarsen.")
120+
domain2=MOM_domain%mpp_domain_d(coarsening), domain_position=position)
123121
endif
124122
else
125123
if (present(coarsen)) then ; if (coarsen /= 1) then

config_src/infra/FMS1/MOM_domain_infra.F90

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ module MOM_domain_infra
135135
character(len=64) :: name !< The name of this domain
136136
type(domain2D), pointer :: mpp_domain => NULL() !< The FMS domain with halos
137137
!! on this processor, centered at h points.
138-
type(domain2D), pointer :: mpp_domain_d2 => NULL() !< A coarse FMS domain with halos
138+
type(domain2D), pointer :: mpp_domain_d(:) => NULL() !< A coarse FMS domain with halos
139139
!! on this processor, centered at h points.
140140
integer :: niglobal !< The total horizontal i-domain size.
141141
integer :: njglobal !< The total horizontal j-domain size.
@@ -1377,7 +1377,6 @@ subroutine create_MOM_domain(MOM_dom, n_global, n_halo, reentrant, tripolar_N, l
13771377
if (.not.associated(MOM_dom)) then
13781378
allocate(MOM_dom)
13791379
allocate(MOM_dom%mpp_domain)
1380-
allocate(MOM_dom%mpp_domain_d2)
13811380
endif
13821381

13831382
MOM_dom%name = "MOM" ; if (present(domain_name)) MOM_dom%name = trim(domain_name)
@@ -1445,12 +1444,6 @@ subroutine create_MOM_domain(MOM_dom, n_global, n_halo, reentrant, tripolar_N, l
14451444

14461445
call clone_MD_to_d2D(MOM_dom, MOM_dom%mpp_domain)
14471446

1448-
!For downsampled domain, recommend a halo of 1 (or 0?) since we're not doing wide-stencil computations.
1449-
!But that does not work because the downsampled field would not have the correct size to pass the checks, e.g., we get
1450-
!error: downsample_diag_indices_get: peculiar size 28 in i-direction\ndoes not match one of 24 25 26 27
1451-
! call clone_MD_to_d2D(MOM_dom, MOM_dom%mpp_domain_d2, halo_size=(MOM_dom%nihalo/2), coarsen=2)
1452-
call clone_MD_to_d2D(MOM_dom, MOM_dom%mpp_domain_d2, coarsen=2)
1453-
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)
@@ -1580,7 +1572,6 @@ subroutine clone_MD_to_MD(MD_in, MOM_dom, min_halo, halo_size, symmetric, domain
15801572
if (.not.associated(MOM_dom)) then
15811573
allocate(MOM_dom)
15821574
allocate(MOM_dom%mpp_domain)
1583-
allocate(MOM_dom%mpp_domain_d2)
15841575
endif
15851576

15861577
! Save the extra data for creating other domains of different resolution that overlay this domain
@@ -1702,7 +1693,6 @@ subroutine clone_MD_to_MD(MD_in, MOM_dom, min_halo, halo_size, symmetric, domain
17021693
endif
17031694

17041695
call clone_MD_to_d2D(MOM_dom, MOM_dom%mpp_domain, xextent=exni, yextent=exnj)
1705-
call clone_MD_to_d2D(MOM_dom, MOM_dom%mpp_domain_d2, domain_name=MOM_dom%name, coarsen=2)
17061696

17071697
end subroutine clone_MD_to_MD
17081698

@@ -1823,8 +1813,8 @@ subroutine get_domain_extent_MD(Domain, isc, iec, jsc, jec, isd, ied, jsd, jed,
18231813
integer, optional, intent(in) :: index_offset !< A fixed additional offset to all indices. This
18241814
!! can be useful for some types of debugging with
18251815
!! dynamic memory allocation. The default is 0.
1826-
integer, optional, intent(in) :: coarsen !< A factor by which the grid is coarsened.
1827-
!! The default is 1, for no coarsening.
1816+
integer, optional, intent(in) :: coarsen !< The index of the factor by which the grid is coarsened.
1817+
!! The default is 0, for no coarsening.
18281818

18291819
! Local variables
18301820
integer :: isg_, ieg_, jsg_, jeg_
@@ -1834,20 +1824,18 @@ subroutine get_domain_extent_MD(Domain, isc, iec, jsc, jec, isd, ied, jsd, jed,
18341824
local = .true. ; if (present(local_indexing)) local = local_indexing
18351825
ind_off = 0 ; if (present(index_offset)) ind_off = index_offset
18361826

1837-
coarsen_lev = 1 ; if (present(coarsen)) coarsen_lev = coarsen
1827+
coarsen_lev = 0 ; if (present(coarsen)) coarsen_lev = coarsen
18381828

1839-
if (coarsen_lev == 1) then
1829+
if (coarsen_lev == 0) then
18401830
call mpp_get_compute_domain(Domain%mpp_domain, isc, iec, jsc, jec)
18411831
call mpp_get_data_domain(Domain%mpp_domain, isd, ied, jsd, jed)
18421832
call mpp_get_global_domain(Domain%mpp_domain, isg_, ieg_, jsg_, jeg_)
1843-
elseif (coarsen_lev == 2) then
1844-
if (.not.associated(Domain%mpp_domain_d2)) call MOM_error(FATAL, &
1845-
"get_domain_extent called with coarsen=2, but Domain%mpp_domain_d2 is not associated.")
1846-
call mpp_get_compute_domain(Domain%mpp_domain_d2, isc, iec, jsc, jec)
1847-
call mpp_get_data_domain(Domain%mpp_domain_d2, isd, ied, jsd, jed)
1848-
call mpp_get_global_domain(Domain%mpp_domain_d2, isg_, ieg_, jsg_, jeg_)
18491833
else
1850-
call MOM_error(FATAL, "get_domain_extent called with an unsupported level of coarsening.")
1834+
if (.not.associated(Domain%mpp_domain_d)) call MOM_error(FATAL, &
1835+
"get_domain_extent called with coarsen_lev, but Domain%mpp_domain_d(coarsen_lev) is not associated.")
1836+
call mpp_get_compute_domain(Domain%mpp_domain_d(coarsen_lev), isc, iec, jsc, jec)
1837+
call mpp_get_data_domain(Domain%mpp_domain_d(coarsen_lev), isd, ied, jsd, jed)
1838+
call mpp_get_global_domain(Domain%mpp_domain_d(coarsen_lev), isg_, ieg_, jsg_, jeg_)
18511839
endif
18521840

18531841
if (local) then

config_src/infra/FMS2/MOM_diag_manager_infra.F90

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,12 @@ integer function MOM_diag_axis_init(name, data, units, cart_name, long_name, MOM
9797
!! describes the edges of this axis
9898
character(len=*), &
9999
optional, intent(in) :: set_name !< A name to use for this set of axes.
100-
integer, optional, intent(in) :: coarsen !< An optional degree of coarsening for the grid, 1
101-
!! by default.
100+
integer, optional, intent(in) :: coarsen !< An optional degree of coarsening for the grid, 0
101+
!! by default. This is the index of the coarsening level.
102102
logical, optional, intent(in) :: null_axis !< If present and true, return the special null axis
103103
!! id for use with scalars.
104104

105-
integer :: coarsening ! The degree of grid coarsening
105+
integer :: coarsening ! The degree of grid coarsening, this is the index of an array of coarsening levels
106106

107107
if (present(null_axis)) then ; if (null_axis) then
108108
! Return the special null axis id for scalars

config_src/infra/FMS2/MOM_domain_infra.F90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1815,8 +1815,8 @@ subroutine get_domain_extent_MD(Domain, isc, iec, jsc, jec, isd, ied, jsd, jed,
18151815
integer, optional, intent(in) :: index_offset !< A fixed additional offset to all indices. This
18161816
!! can be useful for some types of debugging with
18171817
!! dynamic memory allocation. The default is 0.
1818-
integer, optional, intent(in) :: coarsen !< A factor by which the grid is coarsened.
1819-
!! The default is 1, for no coarsening.
1818+
integer, optional, intent(in) :: coarsen !< The index of the factor by which the grid is coarsened.
1819+
!! The default is 0, for no coarsening.
18201820

18211821
! Local variables
18221822
integer :: isg_, ieg_, jsg_, jeg_

src/framework/MOM_diag_mediator.F90

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3474,6 +3474,7 @@ subroutine diag_mediator_init(G, GV, US, nz, param_file, diag_cs, doc_file_dir)
34743474
# include "version_variable.h"
34753475
character(len=40) :: mdl = "MOM_diag_mediator" ! This module's name.
34763476
character(len=32) :: filename_appendix = '' ! FMS appendix to filename for ensemble runs
3477+
character(len=16) :: dsamp_domain_name
34773478

34783479
id_clock_diag_mediator = cpu_clock_id('(Ocean diagnostics framework)', grain=CLOCK_MODULE)
34793480
id_clock_diag_remap = cpu_clock_id('(Ocean diagnostics remapping)', grain=CLOCK_ROUTINE)
@@ -3606,8 +3607,9 @@ subroutine diag_mediator_init(G, GV, US, nz, param_file, diag_cs, doc_file_dir)
36063607
dlfac = diag_cs%diag_dsamp_levels(dl)
36073608
!Create the auxiliary mpp_domain for this level of downsampled diagnostics
36083609
!Downsample diagnostics calculations do not need halos.
3610+
write(dsamp_domain_name, '(a,i0)') trim("MOM_domain_d"),dlfac
36093611
call clone_MOM_domain(G%Domain, G%Domain%mpp_domain_d(dl), coarsen=dlfac, & !halo_size=0, &
3610-
domain_name="MOM_domain_d" // char(48+dlfac))
3612+
domain_name=dsamp_domain_name)
36113613

36123614
!Set the grid extents for this level of downsampling.
36133615
call get_domain_extent(G%Domain, G%HId(dl)%isc, G%HId(dl)%iec, G%HId(dl)%jsc, G%HId(dl)%jec, &

0 commit comments

Comments
 (0)