Skip to content

Commit

Permalink
cleanup of code and enhancement of ePBL perts
Browse files Browse the repository at this point in the history
  • Loading branch information
pjpegion committed Dec 2, 2020
1 parent 9896d61 commit 7de295c
Show file tree
Hide file tree
Showing 6 changed files with 129 additions and 51 deletions.
2 changes: 0 additions & 2 deletions config_src/nuopc_driver/mom_surface_forcing_nuopc.F90
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,6 @@ subroutine convert_IOB_to_fluxes(IOB, fluxes, index_bounds, Time, valid_time, G,

call safe_alloc_ptr(fluxes%p_surf ,isd,ied,jsd,jed)
call safe_alloc_ptr(fluxes%p_surf_full,isd,ied,jsd,jed)
print*,'allocate fluxes%t_rp'
call safe_alloc_ptr(fluxes%t_rp,isd,ied,jsd,jed)
if (CS%use_limited_P_SSH) then
fluxes%p_surf_SSH => fluxes%p_surf
else
Expand Down
28 changes: 17 additions & 11 deletions src/core/MOM.F90
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ module MOM
use MOM_offline_main, only : offline_fw_fluxes_into_ocean, offline_fw_fluxes_out_ocean
use MOM_offline_main, only : offline_advection_layer, offline_transport_end
use MOM_ALE, only : ale_offline_tracer_final, ALE_main_offline
use stochastic_physics, only : init_stochastic_physics_ocn,run_stochastic_physics_ocn
use stochastic_physics, only : init_stochastic_physics_ocn

implicit none ; private

Expand Down Expand Up @@ -761,9 +761,6 @@ subroutine step_MOM(forces_in, fluxes_in, sfc_state, Time_start, time_int_in, CS
enddo ; enddo
endif

print*,'calling run_stochastic_physics_ocn',CS%do_stochy
if (CS%do_stochy) call run_stochastic_physics_ocn(forces%t_rp)

call step_MOM_dynamics(forces, CS%p_surf_begin, CS%p_surf_end, dt, &
dt_therm_here, bbl_time_int, CS, &
Time_local, Waves=Waves)
Expand Down Expand Up @@ -911,7 +908,8 @@ subroutine step_MOM(forces_in, fluxes_in, sfc_state, Time_start, time_int_in, CS
if (CS%time_in_thermo_cycle > 0.0) then
call enable_averages(CS%time_in_thermo_cycle, Time_local, CS%diag)
call post_surface_thermo_diags(CS%sfc_IDs, G, GV, US, CS%diag, CS%time_in_thermo_cycle, &
sfc_state_diag, CS%tv, ssh,fluxes%t_rp, CS%ave_ssh_ibc)
sfc_state_diag, CS%tv, ssh, CS%ave_ssh_ibc)
!sfc_state_diag, CS%tv, ssh,fluxes%t_rp,fluxes%sppt_wts, CS%ave_ssh_ibc)
endif
call disable_averaging(CS%diag)
call cpu_clock_end(id_clock_diagnostics)
Expand Down Expand Up @@ -1672,6 +1670,7 @@ subroutine initialize_MOM(Time, Time_init, param_file, dirs, CS, restart_CSp, &
logical :: calc_dtbt ! Indicates whether the dynamically adjusted barotropic
! time step needs to be updated before it is used.
logical :: debug_truncations ! If true, turn on diagnostics useful for debugging truncations.
logical :: do_epbl,do_sppt
integer :: first_direction ! An integer that indicates which direction is to be
! updated first in directionally split parts of the
! calculation. This can be altered during the course
Expand All @@ -1680,7 +1679,8 @@ subroutine initialize_MOM(Time, Time_init, param_file, dirs, CS, restart_CSp, &
integer :: dynamics_stencil ! The computational stencil for the calculations
! in the dynamic core.
integer,allocatable :: pelist(:) ! list of pes for this instance of the ocean
integer :: num_procs
integer :: mom_comm ! list of pes for this instance of the ocean
integer :: num_procs,iret
! model
integer :: me ! my pe
integer :: master ! root pe
Expand Down Expand Up @@ -2342,14 +2342,17 @@ subroutine initialize_MOM(Time, Time_init, param_file, dirs, CS, restart_CSp, &

num_procs=num_PEs()
allocate(pelist(num_procs))
call Get_PElist(pelist)
call Get_PElist(pelist,commID = mom_comm)
me=PE_here()
master=root_PE()

!call init_stochastic_physics_ocn(CS%dt_therm,G,me,master,pelist,CS%do_stochy)
print*,'callling init_stochastic_physics_ocn',maxval(G%geoLatT)
call init_stochastic_physics_ocn(CS%dt_therm,G%geoLonT,G%geoLatT,G%ied-G%isd+1,G%jed-G%jsd+1,nz,CS%do_stochy)
print*,'back from init_stochastic_physics_ocn',CS%do_stochy
!print*,'callling init_stochastic_physics_ocn',maxval(G%geoLatT)
do_epbl=.false.
do_sppt=.false.
call init_stochastic_physics_ocn(CS%dt_therm,G%geoLonT,G%geoLatT,G%ied-G%isd+1,G%jed-G%jsd+1,nz,do_epbl,do_sppt,master,mom_comm,iret)
if (do_sppt .eq. .true.) CS%do_stochy=.true.
if (do_epbl .eq. .true.) CS%do_stochy=.true.
!print*,'back from init_stochastic_physics_ocn',CS%do_stochy

! Set a few remaining fields that are specific to the ocean grid type.
call set_first_direction(G, first_direction)
Expand Down Expand Up @@ -2763,6 +2766,9 @@ subroutine initialize_MOM(Time, Time_init, param_file, dirs, CS, restart_CSp, &
! call fix_restart_scaling(GV)
! call fix_restart_unit_scaling(US)

CS%diabatic_CSp%do_epbl=do_epbl
CS%diabatic_CSp%do_sppt=do_sppt

call callTree_leave("initialize_MOM()")
call cpu_clock_end(id_clock_init)

Expand Down
37 changes: 25 additions & 12 deletions src/core/MOM_forcing_type.F90
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,10 @@ module MOM_forcing_type
!< Pressure at the top ocean interface [R L2 T-2 ~> Pa] that is used in corrections to the sea surface
!! height field that is passed back to the calling routines.
!! p_surf_SSH may point to p_surf or to p_surf_full.
real, pointer, dimension(:,:) :: t_rp => NULL()
!< random pattern at t-points
! real, pointer, dimension(:,:) :: t_rp => NULL()
! !< random pattern at t-points
! real, pointer, dimension(:,:) :: sppt_wts => NULL()
! !< random pattern at t-points
logical :: accumulate_p_surf = .false. !< If true, the surface pressure due to the atmosphere
!! and various types of ice needs to be accumulated, and the
!! surface pressure explicitly reset to zero at the driver level
Expand Down Expand Up @@ -240,8 +242,10 @@ module MOM_forcing_type
!! u-points [L4 Z-1 T-1 ~> m3 s-1]
rigidity_ice_v => NULL() !< Depth-integrated lateral viscosity of ice shelves or sea ice at
!! v-points [L4 Z-1 T-1 ~> m3 s-1]
real, pointer, dimension(:,:) :: t_rp => NULL()
!< random pattern at t-points
! real, pointer, dimension(:,:) :: t_rp => NULL()
! !< random pattern at t-points
! real, pointer, dimension(:,:) :: sppt_wts => NULL()
! !< random pattern at t-points
real :: dt_force_accum = -1.0 !< The amount of time over which the mechanical forcing fluxes
!! have been averaged [s].
logical :: net_mass_src_set = .false. !< If true, an estimate of net_mass_src has been provided.
Expand Down Expand Up @@ -2082,11 +2086,17 @@ subroutine copy_common_forcing_fields(forces, fluxes, G, skip_pres)

do_pres = .true. ; if (present(skip_pres)) do_pres = .not.skip_pres

if (associated(forces%t_rp) .and. associated(fluxes%t_rp)) then
do j=js,je ; do i=is,ie
fluxes%t_rp(i,j) = forces%t_rp(i,j)
enddo ; enddo
endif
! if (associated(forces%t_rp) .and. associated(fluxes%t_rp)) then
! do j=js,je ; do i=is,ie
! fluxes%t_rp(i,j) = forces%t_rp(i,j)
! enddo ; enddo
! endif
!
! if (associated(forces%sppt_wts) .and. associated(fluxes%sppt_wts)) then
! do j=js,je ; do i=is,ie
! fluxes%sppt_wts(i,j) = forces%sppt_wts(i,j)
! enddo ; enddo
! endif

if (associated(forces%ustar) .and. associated(fluxes%ustar)) then
do j=js,je ; do i=is,ie
Expand Down Expand Up @@ -3031,7 +3041,8 @@ subroutine allocate_mech_forcing_by_group(G, forces, stress, ustar, shelf, &
call myAlloc(forces%p_surf,isd,ied,jsd,jed, press)
call myAlloc(forces%p_surf_full,isd,ied,jsd,jed, press)
call myAlloc(forces%net_mass_src,isd,ied,jsd,jed, press)
call myAlloc(forces%t_rp,isd,ied,jsd,jed, press)
! call myAlloc(forces%t_rp,isd,ied,jsd,jed, press)
! call myAlloc(forces%sppt_wts,isd,ied,jsd,jed, press)

call myAlloc(forces%rigidity_ice_u,IsdB,IedB,jsd,jed, shelf)
call myAlloc(forces%rigidity_ice_v,isd,ied,JsdB,JedB, shelf)
Expand Down Expand Up @@ -3187,7 +3198,8 @@ subroutine deallocate_forcing_type(fluxes)
if (associated(fluxes%seaice_melt)) deallocate(fluxes%seaice_melt)
if (associated(fluxes%salt_flux)) deallocate(fluxes%salt_flux)
if (associated(fluxes%p_surf_full)) deallocate(fluxes%p_surf_full)
if (associated(fluxes%t_rp)) deallocate(fluxes%t_rp)
! if (associated(fluxes%t_rp)) deallocate(fluxes%t_rp)
! if (associated(fluxes%sppt_wts)) deallocate(fluxes%sppt_wts)
if (associated(fluxes%p_surf)) deallocate(fluxes%p_surf)
if (associated(fluxes%TKE_tidal)) deallocate(fluxes%TKE_tidal)
if (associated(fluxes%ustar_tidal)) deallocate(fluxes%ustar_tidal)
Expand All @@ -3212,7 +3224,8 @@ subroutine deallocate_mech_forcing(forces)
if (associated(forces%ustar)) deallocate(forces%ustar)
if (associated(forces%p_surf)) deallocate(forces%p_surf)
if (associated(forces%p_surf_full)) deallocate(forces%p_surf_full)
if (associated(forces%t_rp)) deallocate(forces%t_rp)
! if (associated(forces%t_rp)) deallocate(forces%t_rp)
! if (associated(forces%sppt_wts)) deallocate(forces%sppt_wts)
if (associated(forces%net_mass_src)) deallocate(forces%net_mass_src)
if (associated(forces%rigidity_ice_u)) deallocate(forces%rigidity_ice_u)
if (associated(forces%rigidity_ice_v)) deallocate(forces%rigidity_ice_v)
Expand Down
13 changes: 1 addition & 12 deletions src/diagnostics/MOM_diagnostics.F90
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,6 @@ module MOM_diagnostics
integer :: id_salt_deficit = -1
integer :: id_Heat_PmE = -1
integer :: id_intern_heat = -1
! stochastic pattern
integer :: id_t_rp = -1
!!@}
end type surface_diag_IDs

Expand Down Expand Up @@ -1199,7 +1197,7 @@ end subroutine post_surface_dyn_diags
!> This routine posts diagnostics of various ocean surface and integrated
!! quantities at the time the ocean state is reported back to the caller
subroutine post_surface_thermo_diags(IDs, G, GV, US, diag, dt_int, sfc_state, tv, &
ssh, t_rp, ssh_ibc)
ssh, ssh_ibc)
type(surface_diag_IDs), intent(in) :: IDs !< A structure with the diagnostic IDs.
type(ocean_grid_type), intent(in) :: G !< ocean grid structure
type(verticalGrid_type), intent(in) :: GV !< ocean vertical grid structure
Expand All @@ -1210,8 +1208,6 @@ subroutine post_surface_thermo_diags(IDs, G, GV, US, diag, dt_int, sfc_state, tv
type(thermo_var_ptrs), intent(in) :: tv !< A structure pointing to various thermodynamic variables
real, dimension(SZI_(G),SZJ_(G)), &
intent(in) :: ssh !< Time mean surface height without corrections for ice displacement [m]
real, dimension(SZI_(G),SZJ_(G)), &
intent(in) :: t_rp!< random pattern for stochastic proceeses
real, dimension(SZI_(G),SZJ_(G)), intent(in) :: ssh_ibc !< Time mean surface height with corrections
!! for ice displacement and the inverse barometer [m]

Expand Down Expand Up @@ -1336,11 +1332,6 @@ subroutine post_surface_thermo_diags(IDs, G, GV, US, diag, dt_int, sfc_state, tv
call post_data(IDs%id_sss_sq, work_2d, diag, mask=G%mask2dT)
endif

if (IDs%id_t_rp > 0) then
!call post_data(IDs%id_t_rp, t_rp, diag, mask=G%mask2dT)
call post_data(IDs%id_t_rp, t_rp, diag)
endif

call coupler_type_send_data(sfc_state%tr_fields, get_diag_time_end(diag))

end subroutine post_surface_thermo_diags
Expand Down Expand Up @@ -1842,8 +1833,6 @@ subroutine register_surface_diags(Time, G, US, IDs, diag, tv)
IDs%id_intern_heat = register_diag_field('ocean_model', 'internal_heat', diag%axesT1, Time,&
'Heat flux into ocean from geothermal or other internal sources', &
'W m-2', conversion=US%QRZ_T_to_W_m2)
IDs%id_t_rp = register_diag_field('ocean_model', 'random_pattern', diag%axesT1, Time, &
'random pattern for stochastics', 'None')


end subroutine register_surface_diags
Expand Down
Loading

0 comments on commit 7de295c

Please sign in to comment.