Skip to content

Commit

Permalink
Merge 97b00c7 into e3c71b0
Browse files Browse the repository at this point in the history
  • Loading branch information
herrwang0 authored Aug 23, 2022
2 parents e3c71b0 + 97b00c7 commit b296aa5
Show file tree
Hide file tree
Showing 14 changed files with 605 additions and 187 deletions.
62 changes: 36 additions & 26 deletions src/core/MOM.F90
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ module MOM
use MOM_open_boundary, only : open_boundary_register_restarts
use MOM_open_boundary, only : update_segment_tracer_reservoirs
use MOM_open_boundary, only : rotate_OBC_config, rotate_OBC_init
use MOM_porous_barriers, only : porous_widths_layer, porous_widths_interface, porous_barriers_init
use MOM_porous_barriers, only : porous_barrier_CS
use MOM_set_visc, only : set_viscous_BBL, set_viscous_ML
use MOM_set_visc, only : set_visc_register_restarts, set_visc_CS
use MOM_set_visc, only : set_visc_init, set_visc_end
Expand Down Expand Up @@ -132,7 +134,7 @@ module MOM
use MOM_unit_scaling, only : unit_scale_type, unit_scaling_init
use MOM_unit_scaling, only : unit_scaling_end, fix_restart_unit_scaling
use MOM_variables, only : surface, allocate_surface_state, deallocate_surface_state
use MOM_variables, only : thermo_var_ptrs, vertvisc_type, porous_barrier_ptrs
use MOM_variables, only : thermo_var_ptrs, vertvisc_type, porous_barrier_type
use MOM_variables, only : accel_diag_ptrs, cont_diag_ptrs, ocean_internal_state
use MOM_variables, only : rotate_surface_state
use MOM_verticalGrid, only : verticalGrid_type, verticalGridInit, verticalGridEnd
Expand All @@ -141,8 +143,6 @@ module MOM
use MOM_wave_interface, only : wave_parameters_CS, waves_end, waves_register_restarts
use MOM_wave_interface, only : Update_Stokes_Drift

use MOM_porous_barriers, only : porous_widths

! Database client used for machine-learning interface
use MOM_database_comms, only : dbcomms_CS_type, database_comms_init, dbclient_type

Expand Down Expand Up @@ -403,21 +403,19 @@ module MOM
!< Pointer to the MOM diagnostics control structure
type(offline_transport_CS), pointer :: offline_CSp => NULL()
!< Pointer to the offline tracer transport control structure
type(porous_barrier_CS) :: por_bar_CS
!< Control structure for porous barrier

logical :: ensemble_ocean !< if true, this run is part of a
!! larger ensemble for the purpose of data assimilation
!! or statistical analysis.
type(ODA_CS), pointer :: odaCS => NULL() !< a pointer to the control structure for handling
!! ensemble model state vectors and data assimilation
!! increments and priors
logical :: use_porbar !< If true, use porous barrier to constrain the widths and face areas
!! at the edges of the grid cells.
type(porous_barrier_type) :: pbv !< porous barrier fractional cell metrics
type(dbcomms_CS_type) :: dbcomms_CS !< Control structure for database client used for online ML/AI
type(porous_barrier_ptrs) :: pbv !< porous barrier fractional cell metrics
real ALLOCABLE_, dimension(NIMEMB_PTR_,NJMEM_,NKMEM_) :: por_face_areaU !< fractional open area of U-faces [nondim]
real ALLOCABLE_, dimension(NIMEM_,NJMEMB_PTR_,NKMEM_) :: por_face_areaV !< fractional open area of V-faces [nondim]
real ALLOCABLE_, dimension(NIMEMB_PTR_,NJMEM_,NK_INTERFACE_) :: por_layer_widthU !< fractional open width
!! of U-faces [nondim]
real ALLOCABLE_, dimension(NIMEM_,NJMEMB_PTR_,NK_INTERFACE_) :: por_layer_widthV !< fractional open width
!! of V-faces [nondim]
type(particles), pointer :: particles => NULL() !<Lagrangian particles
type(stochastic_CS), pointer :: stoch_CS => NULL() !< a pointer to the stochastics control structure
end type MOM_control_struct
Expand Down Expand Up @@ -1056,8 +1054,6 @@ subroutine step_MOM_dynamics(forces, p_surf_begin, p_surf_end, dt, dt_thermo, &
integer :: i, j, k, is, ie, js, je, Isq, Ieq, Jsq, Jeq, nz
integer :: isd, ied, jsd, jed, IsdB, IedB, JsdB, JedB

real, dimension(SZI_(CS%G),SZJ_(CS%G),SZK_(CS%G)+1) :: eta_por ! layer interface heights
!! for porous topo. [Z ~> m or 1/eta_to_m]
G => CS%G ; GV => CS%GV ; US => CS%US ; IDs => CS%IDs
is = G%isc ; ie = G%iec ; js = G%jsc ; je = G%jec ; nz = GV%ke
Isq = G%IscB ; Ieq = G%IecB ; Jsq = G%JscB ; Jeq = G%JecB
Expand Down Expand Up @@ -1095,8 +1091,14 @@ subroutine step_MOM_dynamics(forces, p_surf_begin, p_surf_end, dt, dt_thermo, &
call diag_update_remap_grids(CS%diag)
endif

!update porous barrier fractional cell metrics
call porous_widths(h, CS%tv, G, GV, US, eta_por, CS%pbv)
! Update porous barrier fractional cell metrics
if (CS%use_porbar) then
call enable_averages(dt, Time_local, CS%diag)
call porous_widths_layer(h, CS%tv, G, GV, US, CS%pbv, CS%por_bar_CS)
call disable_averaging(CS%diag)
call pass_vector(CS%pbv%por_face_areaU, CS%pbv%por_face_areaV, &
G%Domain, direction=To_All+SCALAR_PAIR, clock=id_clock_pass, halo=CS%cont_stencil)
endif

! The bottom boundary layer properties need to be recalculated.
if (bbl_time_int > 0.0) then
Expand Down Expand Up @@ -1384,9 +1386,6 @@ subroutine step_MOM_thermo(CS, G, GV, US, u, v, h, tv, fluxes, dtdia, &
integer :: halo_sz ! The size of a halo where data must be valid.
integer :: is, ie, js, je, nz

real, dimension(SZI_(CS%G),SZJ_(CS%G),SZK_(CS%G)+1) :: eta_por ! layer interface heights
!! for porous topo. [Z ~> m or 1/eta_to_m]

is = G%isc ; ie = G%iec ; js = G%jsc ; je = G%jec ; nz = GV%ke
showCallTree = callTree_showQuery()
if (showCallTree) call callTree_enter("step_MOM_thermo(), MOM.F90")
Expand Down Expand Up @@ -1423,7 +1422,11 @@ subroutine step_MOM_thermo(CS, G, GV, US, u, v, h, tv, fluxes, dtdia, &
! and set_viscous_BBL is called as a part of the dynamic stepping.
call cpu_clock_begin(id_clock_BBL_visc)
!update porous barrier fractional cell metrics
call porous_widths(h, CS%tv, G, GV, US, eta_por, CS%pbv)
if (CS%use_porbar) then
call porous_widths_interface(h, CS%tv, G, GV, US, CS%pbv, CS%por_bar_CS)
call pass_vector(CS%pbv%por_layer_widthU, CS%pbv%por_layer_widthV, &
G%Domain, direction=To_ALL+SCALAR_PAIR, clock=id_clock_pass, halo=CS%cont_stencil)
endif
call set_viscous_BBL(u, v, h, tv, CS%visc, G, GV, US, CS%set_visc_CSp, CS%pbv)
call cpu_clock_end(id_clock_BBL_visc)
if (showCallTree) call callTree_wayPoint("done with set_viscous_BBL (step_MOM_thermo)")
Expand Down Expand Up @@ -1998,6 +2001,10 @@ subroutine initialize_MOM(Time, Time_init, param_file, dirs, CS, restart_CSp, &
"This is only used if THICKNESSDIFFUSE is true.", &
default=.false.)
if (.not.CS%thickness_diffuse) CS%thickness_diffuse_first = .false.
call get_param(param_file, "MOM", "USE_POROUS_BARRIER", CS%use_porbar, &
"If true, use porous barrier to constrain the widths "//&
"and face areas at the edges of the grid cells. ", &
default=.true.) ! The default should be false after tests.
call get_param(param_file, "MOM", "BATHYMETRY_AT_VEL", bathy_at_vel, &
"If true, there are separate values for the basin depths "//&
"at velocity points. Otherwise the effects of topography "//&
Expand Down Expand Up @@ -2478,12 +2485,11 @@ subroutine initialize_MOM(Time, Time_init, param_file, dirs, CS, restart_CSp, &
CS%time_in_cycle = 0.0 ; CS%time_in_thermo_cycle = 0.0

!allocate porous topography variables
ALLOC_(CS%por_face_areaU(IsdB:IedB,jsd:jed,nz)) ; CS%por_face_areaU(:,:,:) = 1.0
ALLOC_(CS%por_face_areaV(isd:ied,JsdB:JedB,nz)) ; CS%por_face_areaV(:,:,:) = 1.0
ALLOC_(CS%por_layer_widthU(IsdB:IedB,jsd:jed,nz+1)) ; CS%por_layer_widthU(:,:,:) = 1.0
ALLOC_(CS%por_layer_widthV(isd:ied,JsdB:JedB,nz+1)) ; CS%por_layer_widthV(:,:,:) = 1.0
CS%pbv%por_face_areaU => CS%por_face_areaU; CS%pbv%por_face_areaV=> CS%por_face_areaV
CS%pbv%por_layer_widthU => CS%por_layer_widthU; CS%pbv%por_layer_widthV => CS%por_layer_widthV
allocate(CS%pbv%por_face_areaU(IsdB:IedB,jsd:jed,nz)) ; CS%pbv%por_face_areaU(:,:,:) = 1.0
allocate(CS%pbv%por_face_areaV(isd:ied,JsdB:JedB,nz)) ; CS%pbv%por_face_areaV(:,:,:) = 1.0
allocate(CS%pbv%por_layer_widthU(IsdB:IedB,jsd:jed,nz+1)) ; CS%pbv%por_layer_widthU(:,:,:) = 1.0
allocate(CS%pbv%por_layer_widthV(isd:ied,JsdB:JedB,nz+1)) ; CS%pbv%por_layer_widthV(:,:,:) = 1.0

! Use the Wright equation of state by default, unless otherwise specified
! Note: this line and the following block ought to be in a separate
! initialization routine for tv.
Expand Down Expand Up @@ -2822,6 +2828,10 @@ subroutine initialize_MOM(Time, Time_init, param_file, dirs, CS, restart_CSp, &

new_sim = is_new_run(restart_CSp)
call MOM_stoch_eos_init(G,Time,param_file,CS%stoch_eos_CS,restart_CSp,diag)

if (CS%use_porbar) &
call porous_barriers_init(Time, US, param_file, diag, CS%por_bar_CS)

if (CS%split) then
allocate(eta(SZI_(G),SZJ_(G)), source=0.0)
call initialize_dyn_split_RK2(CS%u, CS%v, CS%h, CS%uh, CS%vh, eta, Time, &
Expand Down Expand Up @@ -3775,8 +3785,8 @@ subroutine MOM_end(CS)
if (CS%use_ALE_algorithm) call ALE_end(CS%ALE_CSp)

!deallocate porous topography variables
DEALLOC_(CS%por_face_areaU) ; DEALLOC_(CS%por_face_areaV)
DEALLOC_(CS%por_layer_widthU) ; DEALLOC_(CS%por_layer_widthV)
deallocate(CS%pbv%por_face_areaU) ; deallocate(CS%pbv%por_face_areaV)
deallocate(CS%pbv%por_layer_widthU) ; deallocate(CS%pbv%por_layer_widthV)

! NOTE: Allocated in PressureForce_FV_Bouss
if (associated(CS%tv%varT)) deallocate(CS%tv%varT)
Expand Down
4 changes: 2 additions & 2 deletions src/core/MOM_CoriolisAdv.F90
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module MOM_CoriolisAdv
use MOM_open_boundary, only : OBC_DIRECTION_N, OBC_DIRECTION_S
use MOM_string_functions, only : uppercase
use MOM_unit_scaling, only : unit_scale_type
use MOM_variables, only : accel_diag_ptrs, porous_barrier_ptrs
use MOM_variables, only : accel_diag_ptrs, porous_barrier_type
use MOM_verticalGrid, only : verticalGrid_type
use MOM_wave_interface, only : wave_parameters_CS

Expand Down Expand Up @@ -140,7 +140,7 @@ subroutine CorAdCalc(u, v, h, uh, vh, CAu, CAv, OBC, AD, G, GV, US, CS, pbv, Wav
type(accel_diag_ptrs), intent(inout) :: AD !< Storage for acceleration diagnostics
type(unit_scale_type), intent(in) :: US !< A dimensional unit scaling type
type(CoriolisAdv_CS), intent(in) :: CS !< Control structure for MOM_CoriolisAdv
type(porous_barrier_ptrs), intent(in) :: pbv !< porous barrier fractional cell metrics
type(porous_barrier_type), intent(in) :: pbv !< porous barrier fractional cell metrics
type(Wave_parameters_CS), optional, pointer :: Waves !< An optional pointer to Stokes drift CS

! Local variables
Expand Down
4 changes: 2 additions & 2 deletions src/core/MOM_continuity.F90
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module MOM_continuity
use MOM_grid, only : ocean_grid_type
use MOM_open_boundary, only : ocean_OBC_type
use MOM_unit_scaling, only : unit_scale_type
use MOM_variables, only : BT_cont_type, porous_barrier_ptrs
use MOM_variables, only : BT_cont_type, porous_barrier_type
use MOM_verticalGrid, only : verticalGrid_type

implicit none ; private
Expand Down Expand Up @@ -61,7 +61,7 @@ subroutine continuity(u, v, hin, h, uh, vh, dt, G, GV, US, CS, OBC, pbv, uhbt, v
type(unit_scale_type), intent(in) :: US !< A dimensional unit scaling type
type(continuity_CS), intent(in) :: CS !< Control structure for mom_continuity.
type(ocean_OBC_type), pointer :: OBC !< Open boundaries control structure.
type(porous_barrier_ptrs), intent(in) :: pbv !< porous barrier fractional cell metrics
type(porous_barrier_type), intent(in) :: pbv !< porous barrier fractional cell metrics
real, dimension(SZIB_(G),SZJ_(G)), &
optional, intent(in) :: uhbt !< The vertically summed volume
!! flux through zonal faces [H L2 T-1 ~> m3 s-1 or kg s-1].
Expand Down
4 changes: 2 additions & 2 deletions src/core/MOM_continuity_PPM.F90
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module MOM_continuity_PPM
use MOM_open_boundary, only : ocean_OBC_type, OBC_segment_type, OBC_NONE
use MOM_open_boundary, only : OBC_DIRECTION_E, OBC_DIRECTION_W, OBC_DIRECTION_N, OBC_DIRECTION_S
use MOM_unit_scaling, only : unit_scale_type
use MOM_variables, only : BT_cont_type, porous_barrier_ptrs
use MOM_variables, only : BT_cont_type, porous_barrier_type
use MOM_verticalGrid, only : verticalGrid_type

implicit none ; private
Expand Down Expand Up @@ -90,7 +90,7 @@ subroutine continuity_PPM(u, v, hin, h, uh, vh, dt, G, GV, US, CS, OBC, pbv, uhb
type(unit_scale_type), intent(in) :: US !< A dimensional unit scaling type
type(continuity_PPM_CS), intent(in) :: CS !< Module's control structure.
type(ocean_OBC_type), pointer :: OBC !< Open boundaries control structure.
type(porous_barrier_ptrs), intent(in) :: pbv !< pointers to porous barrier fractional cell metrics
type(porous_barrier_type), intent(in) :: pbv !< pointers to porous barrier fractional cell metrics
real, dimension(SZIB_(G),SZJ_(G)), &
optional, intent(in) :: uhbt !< The summed volume flux through zonal faces
!! [H L2 T-1 ~> m3 s-1 or kg s-1].
Expand Down
6 changes: 3 additions & 3 deletions src/core/MOM_dynamics_split_RK2.F90
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module MOM_dynamics_split_RK2

! This file is part of MOM6. See LICENSE.md for the license.

use MOM_variables, only : vertvisc_type, thermo_var_ptrs, porous_barrier_ptrs
use MOM_variables, only : vertvisc_type, thermo_var_ptrs, porous_barrier_type
use MOM_variables, only : BT_cont_type, alloc_bt_cont_type, dealloc_bt_cont_type
use MOM_variables, only : accel_diag_ptrs, ocean_internal_state, cont_diag_ptrs
use MOM_forcing_type, only : mech_forcing
Expand Down Expand Up @@ -297,7 +297,7 @@ subroutine step_MOM_dyn_split_RK2(u, v, h, tv, visc, Time_local, dt, forces, p_s
type(MEKE_type), intent(inout) :: MEKE !< MEKE fields
type(thickness_diffuse_CS), intent(inout) :: thickness_diffuse_CSp !< Pointer to a structure containing
!! interface height diffusivities
type(porous_barrier_ptrs), intent(in) :: pbv !< porous barrier fractional cell metrics
type(porous_barrier_type), intent(in) :: pbv !< porous barrier fractional cell metrics
type(wave_parameters_CS), optional, pointer :: Waves !< A pointer to a structure containing
!! fields related to the surface wave conditions

Expand Down Expand Up @@ -1152,7 +1152,7 @@ subroutine initialize_dyn_split_RK2(u, v, h, uh, vh, eta, Time, G, GV, US, param
!! the number of times the velocity is
!! truncated (this should be 0).
logical, intent(out) :: calc_dtbt !< If true, recalculate the barotropic time step
type(porous_barrier_ptrs), intent(in) :: pbv !< porous barrier fractional cell metrics
type(porous_barrier_type), intent(in) :: pbv !< porous barrier fractional cell metrics
integer, intent(out) :: cont_stencil !< The stencil for thickness
!! from the continuity solver.

Expand Down
4 changes: 2 additions & 2 deletions src/core/MOM_dynamics_unsplit.F90
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ module MOM_dynamics_unsplit
!* *
!********+*********+*********+*********+*********+*********+*********+**

use MOM_variables, only : vertvisc_type, thermo_var_ptrs, porous_barrier_ptrs
use MOM_variables, only : vertvisc_type, thermo_var_ptrs, porous_barrier_type
use MOM_variables, only : accel_diag_ptrs, ocean_internal_state, cont_diag_ptrs
use MOM_forcing_type, only : mech_forcing
use MOM_checksum_packages, only : MOM_thermo_chksum, MOM_state_chksum, MOM_accel_chksum
Expand Down Expand Up @@ -217,7 +217,7 @@ subroutine step_MOM_dyn_unsplit(u, v, h, tv, visc, Time_local, dt, forces, &
!! initialize_dyn_unsplit.
type(VarMix_CS), intent(inout) :: VarMix !< Variable mixing control structure
type(MEKE_type), intent(inout) :: MEKE !< MEKE fields
type(porous_barrier_ptrs), intent(in) :: pbv !< porous barrier fractional cell metrics
type(porous_barrier_type), intent(in) :: pbv !< porous barrier fractional cell metrics
type(wave_parameters_CS), optional, pointer :: Waves !< A pointer to a structure containing
!! fields related to the surface wave conditions

Expand Down
4 changes: 2 additions & 2 deletions src/core/MOM_dynamics_unsplit_RK2.F90
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ module MOM_dynamics_unsplit_RK2
!* *
!********+*********+*********+*********+*********+*********+*********+**

use MOM_variables, only : vertvisc_type, thermo_var_ptrs, porous_barrier_ptrs
use MOM_variables, only : vertvisc_type, thermo_var_ptrs, porous_barrier_type
use MOM_variables, only : ocean_internal_state, accel_diag_ptrs, cont_diag_ptrs
use MOM_forcing_type, only : mech_forcing
use MOM_checksum_packages, only : MOM_thermo_chksum, MOM_state_chksum, MOM_accel_chksum
Expand Down Expand Up @@ -230,7 +230,7 @@ subroutine step_MOM_dyn_unsplit_RK2(u_in, v_in, h_in, tv, visc, Time_local, dt,
type(MEKE_type), intent(inout) :: MEKE !< MEKE fields
!! fields related to the Mesoscale
!! Eddy Kinetic Energy.
type(porous_barrier_ptrs), intent(in) :: pbv !< porous barrier fractional cell metrics
type(porous_barrier_type), intent(in) :: pbv !< porous barrier fractional cell metrics
! Local variables
real, dimension(SZI_(G),SZJ_(G),SZK_(GV)) :: h_av ! Averaged layer thicknesses [H ~> m or kg m-2]
real, dimension(SZI_(G),SZJ_(G),SZK_(GV)) :: hp ! Predicted layer thicknesses [H ~> m or kg m-2]
Expand Down
8 changes: 4 additions & 4 deletions src/core/MOM_grid.F90
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,13 @@ module MOM_grid
areaCv !< The areas of the v-grid cells [L2 ~> m2].

real ALLOCABLE_, dimension(NIMEMB_PTR_,NJMEM_) :: &
porous_DminU, & !< minimum topographic height of U-face [Z ~> m]
porous_DmaxU, & !< maximum topographic height of U-face [Z ~> m]
porous_DminU, & !< minimum topographic height (deepest) of U-face [Z ~> m]
porous_DmaxU, & !< maximum topographic height (shallowest) of U-face [Z ~> m]
porous_DavgU !< average topographic height of U-face [Z ~> m]

real ALLOCABLE_, dimension(NIMEM_,NJMEMB_PTR_) :: &
porous_DminV, & !< minimum topographic height of V-face [Z ~> m]
porous_DmaxV, & !< maximum topographic height of V-face [Z ~> m]
porous_DminV, & !< minimum topographic height (deepest) of V-face [Z ~> m]
porous_DmaxV, & !< maximum topographic height (shallowest) of V-face [Z ~> m]
porous_DavgV !< average topographic height of V-face [Z ~> m]

real ALLOCABLE_, dimension(NIMEMB_PTR_,NJMEMB_PTR_) :: &
Expand Down
Loading

0 comments on commit b296aa5

Please sign in to comment.