Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace MOM_stochastics_stub with stochastic_physics stub #6

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions config_src/drivers/nuopc_cap/mom_cap.F90
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ module MOM_cap_mod
use NUOPC_Model, only: model_label_Finalize => label_Finalize
use NUOPC_Model, only: SetVM

use MOM_stochastics, only : write_mom_restart_stoch
use get_stochy_pattern_mod, only : write_stoch_restart_ocn
!$use omp_lib , only : omp_set_num_threads

implicit none; private
Expand Down Expand Up @@ -1749,17 +1749,15 @@ subroutine ModelAdvance(gcomp, rc)
! write restart file(s)
call ocean_model_restart(ocean_state, restartname=restartname)

if (ocean_state%do_sppt .OR. ocean_state%pert_epbl) then
if (ESMF_AlarmIsRinging(stop_alarm, rc=rc)) then
write(restartname,'(A)')"ocn_stoch.res.nc"
else
write(restartname,'(A,I4.4,"-",I2.2,"-",I2.2,"-",I2.2,"-",I2.2,"-",I2.2,A)') &
"ocn_stoch.res.", year, month, day, hour, minute, seconds,".nc"
endif
call ESMF_LogWrite("MOM_cap: Writing stoch restart : "//trim(restartname), &
ESMF_LOGMSG_INFO)
call write_mom_restart_stoch('RESTART/'//trim(restartname))
if (ESMF_AlarmIsRinging(stop_alarm, rc=rc)) then
write(restartname,'(A)')"ocn_stoch.res.nc"
else
write(restartname,'(A,I4.4,"-",I2.2,"-",I2.2,"-",I2.2,"-",I2.2,"-",I2.2,A)') &
"ocn_stoch.res.", year, month, day, hour, minute, seconds,".nc"
endif
call ESMF_LogWrite("MOM_cap: Writing stoch restart : "//trim(restartname), &
ESMF_LOGMSG_INFO)
call write_stoch_restart_ocn('RESTART/'//trim(restartname))
endif

if (is_root_pe()) then
Expand Down
13 changes: 0 additions & 13 deletions config_src/drivers/nuopc_cap/mom_ocean_model_nuopc.F90
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,6 @@ module MOM_ocean_model_nuopc
!! steps can span multiple coupled time steps.
logical :: diabatic_first !< If true, apply diabatic and thermodynamic
!! processes before time stepping the dynamics.
logical,public :: do_sppt !< If true, write stochastic physics restarts
logical,public :: pert_epbl !< If true, write stochastic physics restarts

real :: eps_omesh !< Max allowable difference between ESMF mesh and MOM6
!! domain coordinates
Expand Down Expand Up @@ -428,17 +426,6 @@ subroutine ocean_model_init(Ocean_sfc, OS, Time_init, Time_in, gas_fields_ocn, i

endif

! check to see if stochastic physics is active
call get_param(param_file, mdl, "DO_SPPT", OS%do_sppt, &
"If true, then stochastically perturb the thermodynamic "//&
"tendemcies of T,S, amd h. Amplitude and correlations are "//&
"controlled by the nam_stoch namelist in the UFS model only.", &
default=.false.)
call get_param(param_file, mdl, "PERT_EPBL", OS%pert_epbl, &
"If true, then stochastically perturb the kinetic energy "//&
"production and dissipation terms. Amplitude and correlations are "//&
"controlled by the nam_stoch namelist in the UFS model only.", &
default=.false.)
call extract_surface_state(OS%MOM_CSp, OS%sfc_state)

call close_param_file(param_file)
Expand Down

This file was deleted.

59 changes: 59 additions & 0 deletions config_src/external/stochastic_physics/stochastic_physics.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
! The are stubs for ocean stochastic physics
! the fully functional code is available at
! http://github.com/noaa-psd/stochastic_physics
module stochastic_physics

implicit none

private

public :: init_stochastic_physics_ocn
public :: run_stochastic_physics_ocn

contains

!!!!!!!!!!!!!!!!!!!!
subroutine init_stochastic_physics_ocn(delt,geoLonT,geoLatT,nx,ny,nz,pert_epbl_in,do_sppt_in, &
mpiroot, mpicomm, iret)
implicit none
real,intent(in) :: delt
integer,intent(in) :: nx,ny,nz
real,intent(in) :: geoLonT(nx,ny),geoLatT(nx,ny)
logical,intent(in) :: pert_epbl_in,do_sppt_in
integer,intent(in) :: mpiroot, mpicomm
integer, intent(out) :: iret

iret=0
if (pert_epbl_in .EQV. .true. ) then
print*,'pert_epbl needs to be false if using the stub'
iret=-1
endif
if (do_sppt_in.EQV. .true. ) then
print*,'do_sppt needs to be false if using the stub'
iret=-1
endif
return
end subroutine init_stochastic_physics_ocn

subroutine run_stochastic_physics_ocn(sppt_wts,t_rp1,t_rp2)
implicit none
real, intent(inout) :: sppt_wts(:,:),t_rp1(:,:),t_rp2(:,:)
return
end subroutine run_stochastic_physics_ocn

end module stochastic_physics

module get_stochy_pattern_mod

private

public :: write_stoch_restart_ocn

contains
subroutine write_stoch_restart_ocn(sfile)

character(len=*) :: sfile
return
end subroutine write_stoch_restart_ocn

end module get_stochy_pattern_mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,19 @@ module MOM_stochastics
use MOM_domains, only : root_PE,num_PEs
use MOM_coms, only : Get_PElist
use stochastic_physics, only : init_stochastic_physics_ocn, run_stochastic_physics_ocn
use get_stochy_pattern_mod, only: write_stoch_restart_ocn

#include <MOM_memory.h>

implicit none ; private

public stochastics_init, update_stochastics, write_mom_restart_stoch
public stochastics_init, update_stochastics

!> This control structure holds parameters for the MOM_stochastics module
type, public:: stochastic_CS
logical :: do_sppt !< If true, stochastically perturb the diabatic
logical :: pert_epbl !! If true, then randomly perturb the KE dissipation and genration terms
integer :: id_sppt_wts = -1
integer :: id_epbl1_wts=-1,id_epbl2_wts=-1
logical :: do_sppt !< If true, stochastically perturb the diabatic
logical :: pert_epbl !< If true, then randomly perturb the KE dissipation and genration terms
integer :: id_sppt_wts = -1 !< Diagnostic id for SPPT
integer :: id_epbl1_wts=-1,id_epbl2_wts=-1 !< Diagnostic id for epbl
! stochastic patterns
real, allocatable :: sppt_wts(:,:) !< Random pattern for ocean SPPT
!! tendencies with a number between 0 and 2
Expand All @@ -47,9 +46,9 @@ module MOM_stochastics
!! This subroutine initializes the stochastics physics control structure.
subroutine stochastics_init(dt, grid, GV, CS, param_file, diag, Time)
real, intent(in) :: dt !< time step [T ~> s]
type(ocean_grid_type), intent(in) :: grid ! horizontal grid information
type(verticalGrid_type), intent(in) :: GV ! vertical grid structure
type(stochastic_CS), pointer, intent(inout):: CS
type(ocean_grid_type), intent(in) :: grid !< horizontal grid information
type(verticalGrid_type), intent(in) :: GV !< vertical grid structure
type(stochastic_CS), pointer, intent(inout):: CS !< stochastic control structure
type(param_file_type), intent(in) :: param_file !< A structure to parse for run-time parameters
type(diag_ctrl), target, intent(inout) :: diag !< structure to regulate diagnostic output
type(time_type), target :: Time !< model time
Expand Down Expand Up @@ -140,16 +139,5 @@ subroutine update_stochastics(CS)
return
end subroutine update_stochastics

!< wrapper to write ocean stochastic restarts
subroutine write_mom_restart_stoch(filename)
character(len=*) :: filename

call callTree_enter("write_mom_restart_stoch(), MOM_stochastics.F90")

call write_stoch_restart_ocn(filename)

return
end subroutine write_mom_restart_stoch

end module MOM_stochastics

4 changes: 2 additions & 2 deletions src/parameterizations/vertical/MOM_energetic_PBL.F90
Original file line number Diff line number Diff line change
Expand Up @@ -600,8 +600,8 @@ subroutine ePBL_column(h, u, v, T0, S0, dSV_dT, dSV_dS, TKE_forcing, B_flux, abs
optional, pointer :: Waves !< Wave CS for Langmuir turbulence
type(ocean_grid_type), &
optional, intent(inout) :: G !< The ocean's grid structure.
real, optional, intent(in) :: epbl1_wt ! random number to perturb KE generation
real, optional, intent(in) :: epbl2_wt ! random number to perturb KE dissipation
real, optional, intent(in) :: epbl1_wt !< random number to perturb KE generation
real, optional, intent(in) :: epbl2_wt !< random number to perturb KE dissipation
integer, optional, intent(in) :: i !< The i-index to work on (used for Waves)
integer, optional, intent(in) :: j !< The i-index to work on (used for Waves)

Expand Down