Skip to content

Commit 9e9a81e

Browse files
nikizadehgfdlHallberg-NOAA
authored andcommitted
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 e60bc4c commit 9e9a81e

1 file changed

Lines changed: 25 additions & 17 deletions

File tree

src/framework/MOM_diag_mediator.F90

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,10 @@ module MOM_diag_mediator
133133
logical :: needs_interpolating = .false. !< If true, indicates that this axes group is for a sampled
134134
!! interface-located field that must be interpolated to
135135
!! these axes. Used for rank>2.
136-
integer :: downsample_level_factor = 1 !< If greater than 1, the factor by which this diagnostic/axes/masks be downsampled
137-
integer :: downsample_level_index = 0 !< If greater than 0, the index for the downsample level for this diagnostic in the diag_cs%dsamp array.
136+
integer :: downsample_level_factor = 1 !< If greater than 1, the factor by which this diagnostic/axes/masks
137+
!! be downsampled
138+
integer :: downsample_level_index = 0 !< If greater than 0, the index for the downsample level for this diagnostic
139+
!! in the diag_cs%dsamp array.
138140
! For horizontally averaged diagnostics (applies to 2d and 3d fields only)
139141
type(axes_grp), pointer :: xyave_axes => null() !< The associated 1d axes for horizontally area-averaged diagnostics
140142
! ID's for cell_measures
@@ -305,7 +307,7 @@ module MOM_diag_mediator
305307
real, dimension(:,:,:), pointer :: mask3dCvi => null()
306308

307309
integer :: num_diag_dsamp_levels !< The number of downsampled levels requested in the parameters files (default 0)
308-
integer, dimension(:), allocatable :: diag_dsamp_levels !< The downsample levels requested by diagnostics registrations
310+
integer, dimension(:), allocatable :: diag_dsamp_levels !< The downsample levels requested by diag registrations
309311
type(diagcs_dsamp), dimension(:), allocatable :: dsamp !< Downsample control container
310312
!! The size to be determined from paramaters files (default 0)
311313

@@ -3577,19 +3579,19 @@ subroutine diag_mediator_init(G, GV, US, nz, param_file, diag_cs, doc_file_dir)
35773579
diag_cs%isd = G%isd ; diag_cs%ied = G%ied
35783580
diag_cs%jsd = G%jsd ; diag_cs%jed = G%jed
35793581

3580-
!In this code design
3582+
!In this code design
35813583
!diag_cs%num_diag_dsamp_levels is the number of downsampling levels requested in the parameters
3582-
!diag_cs%diag_dsamp_levels(dl) is the actual downsampling factor for each level,
3584+
!diag_cs%diag_dsamp_levels(dl) is the actual downsampling factor for each level,
35833585
!which is used to as the division factor to define the axes for that level.
3584-
!Note that the downsampling axes and domains are created at initialization based on what is
3585-
!requested in the parameter files (default is none) regardless of whether
3586+
!Note that the downsampling axes and domains are created at initialization based on what is
3587+
!requested in the parameter files (default is none) regardless of whether
35863588
!any downsampled diagnostics are present in the diag_table.
3587-
!Are downsampled diagnostics requested?
3589+
!Are downsampled diagnostics requested?
35883590
call get_param(param_file, mdl, 'NUM_DIAG_DOWNSAMP_LEV', diag_cs%num_diag_dsamp_levels, &
35893591
'The number of diagnostic downsample levels to use. '//&
35903592
'For each level, an entry in DIAG_DOWNSAMP_LEV must be provided.', &
35913593
default=0)
3592-
if (diag_cs%num_diag_dsamp_levels > 0) then
3594+
if (diag_cs%num_diag_dsamp_levels > 0) then
35933595
allocate(diag_cs%diag_dsamp_levels(diag_cs%num_diag_dsamp_levels))
35943596
call get_param(param_file, mdl, 'DIAG_DOWNSAMP_LEVS', diag_cs%diag_dsamp_levels, &
35953597
'A comma separated list of diagnostic downsample levels to be used. ', &
@@ -3604,7 +3606,7 @@ subroutine diag_mediator_init(G, GV, US, nz, param_file, diag_cs, doc_file_dir)
36043606
do dl=1, diag_cs%num_diag_dsamp_levels
36053607
dlfac = diag_cs%diag_dsamp_levels(dl)
36063608
!Create the auxiliary mpp_domain for this level of downsampled diagnostics
3607-
!Downsample diagnostics calculations do not need halos.
3609+
!Downsample diagnostics calculations do not need halos.
36083610
call clone_MOM_domain(G%Domain, G%Domain%mpp_domain_d(dl), coarsen=dlfac, & !halo_size=0, &
36093611
domain_name="MOM_domain_d" // char(48+dlfac))
36103612

@@ -3628,16 +3630,18 @@ subroutine diag_mediator_init(G, GV, US, nz, param_file, diag_cs, doc_file_dir)
36283630
G%HId(dl)%IegB = G%HId(dl)%ieg ; G%HId(dl)%JegB = G%HId(dl)%jeg
36293631

36303632
!Downsample indices for diagnostics that are on a coarser grid than the model grid.
3631-
diag_cs%dsamp(dl)%isc = G%HId(dl)%isc - (G%HId(dl)%isd-1) ; diag_cs%dsamp(dl)%iec = G%HId(dl)%iec - (G%HId(dl)%isd-1)
3632-
diag_cs%dsamp(dl)%jsc = G%HId(dl)%jsc - (G%HId(dl)%jsd-1) ; diag_cs%dsamp(dl)%jec = G%HId(dl)%jec - (G%HId(dl)%jsd-1)
3633+
diag_cs%dsamp(dl)%isc = G%HId(dl)%isc - (G%HId(dl)%isd-1)
3634+
diag_cs%dsamp(dl)%iec = G%HId(dl)%iec - (G%HId(dl)%isd-1)
3635+
diag_cs%dsamp(dl)%jsc = G%HId(dl)%jsc - (G%HId(dl)%jsd-1)
3636+
diag_cs%dsamp(dl)%jec = G%HId(dl)%jec - (G%HId(dl)%jsd-1)
36333637
diag_cs%dsamp(dl)%isd = G%HId(dl)%isd ; diag_cs%dsamp(dl)%ied = G%HId(dl)%ied
36343638
diag_cs%dsamp(dl)%jsd = G%HId(dl)%jsd ; diag_cs%dsamp(dl)%jed = G%HId(dl)%jed
36353639
diag_cs%dsamp(dl)%isg = G%HId(dl)%isg ; diag_cs%dsamp(dl)%ieg = G%HId(dl)%ieg
36363640
diag_cs%dsamp(dl)%jsg = G%HId(dl)%jsg ; diag_cs%dsamp(dl)%jeg = G%HId(dl)%jeg
36373641
diag_cs%dsamp(dl)%isgB = G%HId(dl)%isgB ; diag_cs%dsamp(dl)%iegB = G%HId(dl)%iegB
36383642
diag_cs%dsamp(dl)%jsgB = G%HId(dl)%jsgB ; diag_cs%dsamp(dl)%jegB = G%HId(dl)%jegB
36393643
enddo
3640-
endif
3644+
endif
36413645
! Initialze available diagnostic log file
36423646
if (is_root_pe() .and. (diag_CS%available_diag_doc_unit < 0)) then
36433647
write(this_pe,'(i6.6)') PE_here()
@@ -4370,13 +4374,17 @@ subroutine downsample_diag_masks_set(G, nz, diag_cs)
43704374
dlfac = diag_cs%diag_dsamp_levels(dl) !Actual downsampling factor for this level
43714375
! 2d mask
43724376
call downsample_mask(G%mask2dT, diag_cs%dsamp(dl)%mask2dT, dlfac, MMP, G%isc, G%jsc, G%isd, G%jsd, &
4373-
G%HId(dl)%isc, G%HId(dl)%iec, G%HId(dl)%jsc, G%HId(dl)%jec, G%HId(dl)%isd, G%HId(dl)%ied, G%HId(dl)%jsd, G%HId(dl)%jed)
4377+
G%HId(dl)%isc, G%HId(dl)%iec, G%HId(dl)%jsc, G%HId(dl)%jec, G%HId(dl)%isd, G%HId(dl)%ied, &
4378+
G%HId(dl)%jsd, G%HId(dl)%jed)
43744379
call downsample_mask(G%mask2dBu, diag_cs%dsamp(dl)%mask2dBu, dlfac, PPP,G%IscB, G%JscB, G%IsdB, G%JsdB, &
4375-
G%HId(dl)%IscB,G%HId(dl)%IecB, G%HId(dl)%JscB,G%HId(dl)%JecB,G%HId(dl)%IsdB,G%HId(dl)%IedB,G%HId(dl)%JsdB,G%HId(dl)%JedB)
4380+
G%HId(dl)%IscB,G%HId(dl)%IecB, G%HId(dl)%JscB,G%HId(dl)%JecB,G%HId(dl)%IsdB,G%HId(dl)%IedB, &
4381+
G%HId(dl)%JsdB,G%HId(dl)%JedB)
43764382
call downsample_mask(G%mask2dCu, diag_cs%dsamp(dl)%mask2dCu, dlfac, PMP, G%IscB, G%jsc, G%IsdB, G%jsd, &
4377-
G%HId(dl)%IscB,G%HId(dl)%IecB, G%HId(dl)%jsc, G%HId(dl)%jec,G%HId(dl)%IsdB,G%HId(dl)%IedB,G%HId(dl)%jsd, G%HId(dl)%jed)
4383+
G%HId(dl)%IscB,G%HId(dl)%IecB, G%HId(dl)%jsc, G%HId(dl)%jec,G%HId(dl)%IsdB,G%HId(dl)%IedB, &
4384+
G%HId(dl)%jsd, G%HId(dl)%jed)
43784385
call downsample_mask(G%mask2dCv, diag_cs%dsamp(dl)%mask2dCv, dlfac, MPP, G %isc ,G%JscB, G%isd, G%JsdB, &
4379-
G%HId(dl)%isc ,G%HId(dl)%iec, G%HId(dl)%JscB,G%HId(dl)%JecB,G%HId(dl)%isd ,G%HId(dl)%ied, G%HId(dl)%JsdB,G%HId(dl)%JedB)
4386+
G%HId(dl)%isc ,G%HId(dl)%iec, G%HId(dl)%JscB,G%HId(dl)%JecB,G%HId(dl)%isd ,G%HId(dl)%ied, &
4387+
G%HId(dl)%JsdB,G%HId(dl)%JedB)
43804388
! 3d native masks are needed by diag_manager but the native variables
43814389
! can only be masked 2d - for ocean points, all layers exists.
43824390
allocate(diag_cs%dsamp(dl)%mask3dTL(G%HId(dl)%isd:G%HId(dl)%ied,G%HId(dl)%jsd:G%HId(dl)%jed,1:nz))

0 commit comments

Comments
 (0)