Skip to content

Commit 32c0e1e

Browse files
authored
Merge pull request #81 from jiandewang/feature/update-to-main-20211220
update MOM6 to its main branch commit 20211220
2 parents 90d5961 + 9642b1d commit 32c0e1e

File tree

6 files changed

+105
-115
lines changed

6 files changed

+105
-115
lines changed

config_src/drivers/nuopc_cap/mom_cap.F90

+6-14
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ module MOM_cap_mod
9898
use NUOPC_Model, only: model_label_Finalize => label_Finalize
9999
use NUOPC_Model, only: SetVM
100100

101-
use MOM_stochastics, only : write_mom_restart_stoch
102101
!$use omp_lib , only : omp_set_num_threads
103102

104103
implicit none; private
@@ -1526,7 +1525,7 @@ subroutine ModelAdvance(gcomp, rc)
15261525
integer :: nc
15271526
type(ESMF_Time) :: MyTime
15281527
integer :: seconds, day, year, month, hour, minute
1529-
character(ESMF_MAXSTR) :: restartname, cvalue
1528+
character(ESMF_MAXSTR) :: restartname, cvalue, stoch_restartname
15301529
character(240) :: msgString
15311530
character(ESMF_MAXSTR) :: casename
15321531
integer :: iostat
@@ -1740,26 +1739,19 @@ subroutine ModelAdvance(gcomp, rc)
17401739
! write the final restart without a timestamp
17411740
if (ESMF_AlarmIsRinging(stop_alarm, rc=rc)) then
17421741
write(restartname,'(A)')"MOM.res"
1742+
write(stoch_restartname,'(A)')"ocn_stoch.res.nc"
17431743
else
17441744
write(restartname,'(A,I4.4,"-",I2.2,"-",I2.2,"-",I2.2,"-",I2.2,"-",I2.2)') &
17451745
"MOM.res.", year, month, day, hour, minute, seconds
1746+
write(stoch_restartname,'(A,I4.4,"-",I2.2,"-",I2.2,"-",I2.2,"-",I2.2,"-",I2.2,A)') &
1747+
"ocn_stoch.res.", year, month, day, hour, minute, seconds,".nc"
17461748
endif
17471749
call ESMF_LogWrite("MOM_cap: Writing restart : "//trim(restartname), ESMF_LOGMSG_INFO)
17481750

17491751
! write restart file(s)
1750-
call ocean_model_restart(ocean_state, restartname=restartname)
1752+
call ocean_model_restart(ocean_state, restartname=restartname, &
1753+
stoch_restartname=stoch_restartname)
17511754

1752-
if (ocean_state%do_sppt .OR. ocean_state%pert_epbl) then
1753-
if (ESMF_AlarmIsRinging(stop_alarm, rc=rc)) then
1754-
write(restartname,'(A)')"ocn_stoch.res.nc"
1755-
else
1756-
write(restartname,'(A,I4.4,"-",I2.2,"-",I2.2,"-",I2.2,"-",I2.2,"-",I2.2,A)') &
1757-
"ocn_stoch.res.", year, month, day, hour, minute, seconds,".nc"
1758-
endif
1759-
call ESMF_LogWrite("MOM_cap: Writing stoch restart : "//trim(restartname), &
1760-
ESMF_LOGMSG_INFO)
1761-
call write_mom_restart_stoch('RESTART/'//trim(restartname))
1762-
endif
17631755
endif
17641756

17651757
if (is_root_pe()) then

config_src/drivers/nuopc_cap/mom_ocean_model_nuopc.F90

+17-8
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ module MOM_ocean_model_nuopc
6262
use MOM_surface_forcing_nuopc, only : convert_IOB_to_forces, ice_ocn_bnd_type_chksum
6363
use MOM_surface_forcing_nuopc, only : ice_ocean_boundary_type, surface_forcing_CS
6464
use MOM_surface_forcing_nuopc, only : forcing_save_restart
65-
use MOM_domains, only : root_PE,num_PEs
66-
use MOM_coms, only : Get_PElist
65+
use get_stochy_pattern_mod, only : write_stoch_restart_ocn
6766
use iso_fortran_env, only : int64
6867

6968
#include <MOM_memory.h>
@@ -178,8 +177,10 @@ module MOM_ocean_model_nuopc
178177
!! steps can span multiple coupled time steps.
179178
logical :: diabatic_first !< If true, apply diabatic and thermodynamic
180179
!! processes before time stepping the dynamics.
181-
logical,public :: do_sppt !< If true, write stochastic physics restarts
182-
logical,public :: pert_epbl !< If true, write stochastic physics restarts
180+
logical :: do_sppt !< If true, stochastically perturb the diabatic and
181+
!! write restarts
182+
logical :: pert_epbl !< If true, then randomly perturb the KE dissipation and
183+
!! genration termsand write restarts
183184

184185
real :: eps_omesh !< Max allowable difference between ESMF mesh and MOM6
185186
!! domain coordinates
@@ -428,18 +429,18 @@ subroutine ocean_model_init(Ocean_sfc, OS, Time_init, Time_in, gas_fields_ocn, i
428429

429430
endif
430431

431-
! check to see if stochastic physics is active
432+
call extract_surface_state(OS%MOM_CSp, OS%sfc_state)
433+
! get number of processors and PE list for stocasthci physics initialization
432434
call get_param(param_file, mdl, "DO_SPPT", OS%do_sppt, &
433435
"If true, then stochastically perturb the thermodynamic "//&
434-
"tendemcies of T,S, amd h. Amplitude and correlations are "//&
436+
"tendencies of T,S, and h. Amplitude and correlations are "//&
435437
"controlled by the nam_stoch namelist in the UFS model only.", &
436438
default=.false.)
437439
call get_param(param_file, mdl, "PERT_EPBL", OS%pert_epbl, &
438440
"If true, then stochastically perturb the kinetic energy "//&
439441
"production and dissipation terms. Amplitude and correlations are "//&
440442
"controlled by the nam_stoch namelist in the UFS model only.", &
441443
default=.false.)
442-
call extract_surface_state(OS%MOM_CSp, OS%sfc_state)
443444

444445
call close_param_file(param_file)
445446
call diag_mediator_close_registration(OS%diag)
@@ -701,14 +702,17 @@ subroutine update_ocean_model(Ice_ocean_boundary, OS, Ocean_sfc, &
701702
end subroutine update_ocean_model
702703

703704
!> This subroutine writes out the ocean model restart file.
704-
subroutine ocean_model_restart(OS, timestamp, restartname, num_rest_files)
705+
subroutine ocean_model_restart(OS, timestamp, restartname, stoch_restartname, num_rest_files)
705706
type(ocean_state_type), pointer :: OS !< A pointer to the structure containing the
706707
!! internal ocean state being saved to a restart file
707708
character(len=*), optional, intent(in) :: timestamp !< An optional timestamp string that should be
708709
!! prepended to the file name. (Currently this is unused.)
709710
character(len=*), optional, intent(in) :: restartname !< Name of restart file to use
710711
!! This option distinguishes the cesm interface from the
711712
!! non-cesm interface
713+
character(len=*), optional, intent(in) :: stoch_restartname !< Name of restart file to use
714+
!! This option distinguishes the cesm interface from the
715+
!! non-cesm interface
712716
integer, optional, intent(out) :: num_rest_files !< number of restart files written
713717

714718
if (.not.MOM_state_is_synchronized(OS%MOM_CSp)) &
@@ -748,6 +752,11 @@ subroutine ocean_model_restart(OS, timestamp, restartname, num_rest_files)
748752
endif
749753
endif
750754
endif
755+
if (present(stoch_restartname)) then
756+
if (OS%do_sppt .OR. OS%pert_epbl) then
757+
call write_stoch_restart_ocn('RESTART/'//trim(stoch_restartname))
758+
endif
759+
endif
751760

752761
end subroutine ocean_model_restart
753762
! </SUBROUTINE> NAME="ocean_model_restart"

config_src/external/OCEAN_stochastic_phyiscs/MOM_stochastics_stub.F90

-68
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
! The are stubs for ocean stochastic physics
2+
! the fully functional code is available at
3+
! http://github.com/noaa-psd/stochastic_physics
4+
module stochastic_physics
5+
6+
implicit none
7+
8+
private
9+
10+
public :: init_stochastic_physics_ocn
11+
public :: run_stochastic_physics_ocn
12+
13+
contains
14+
15+
!!!!!!!!!!!!!!!!!!!!
16+
subroutine init_stochastic_physics_ocn(delt,geoLonT,geoLatT,nx,ny,nz,pert_epbl_in,do_sppt_in, &
17+
mpiroot, mpicomm, iret)
18+
implicit none
19+
real,intent(in) :: delt !< timestep in seconds between calls to run_stochastic_physics_ocn
20+
integer,intent(in) :: nx !< number of gridpoints in the x-direction of the compute grid
21+
integer,intent(in) :: ny !< number of gridpoints in the y-direction of the compute grid
22+
integer,intent(in) :: nz !< number of gridpoints in the z-direction of the compute grid
23+
real,intent(in) :: geoLonT(nx,ny) !< Longitude in degrees
24+
real,intent(in) :: geoLatT(nx,ny) !< Latitude in degrees
25+
logical,intent(in) :: pert_epbl_in !< logical flag, if true generate random pattern for ePBL perturbations
26+
logical,intent(in) :: do_sppt_in !< logical flag, if true generate random pattern for SPPT perturbations
27+
integer,intent(in) :: mpiroot !< root processor
28+
integer,intent(in) :: mpicomm !< mpi communicator
29+
integer, intent(out) :: iret !< return code
30+
31+
iret=0
32+
if (pert_epbl_in .EQV. .true. ) then
33+
print*,'pert_epbl needs to be false if using the stub'
34+
iret=-1
35+
endif
36+
if (do_sppt_in.EQV. .true. ) then
37+
print*,'do_sppt needs to be false if using the stub'
38+
iret=-1
39+
endif
40+
return
41+
end subroutine init_stochastic_physics_ocn
42+
43+
subroutine run_stochastic_physics_ocn(sppt_wts,t_rp1,t_rp2)
44+
implicit none
45+
real, intent(inout) :: sppt_wts(:,:) !< array containing random weights for SPPT range [0,2]
46+
real, intent(inout) :: t_rp1(:,:) !< array containing random weights for ePBL
47+
!! perturbations (KE generation) range [0,2]
48+
real, intent(inout) :: t_rp2(:,:) !< array containing random weights for ePBL
49+
!! perturbations (KE dissipation) range [0,2]
50+
return
51+
end subroutine run_stochastic_physics_ocn
52+
53+
end module stochastic_physics
54+
55+
module get_stochy_pattern_mod
56+
57+
private
58+
59+
public :: write_stoch_restart_ocn
60+
61+
contains
62+
subroutine write_stoch_restart_ocn(sfile)
63+
64+
character(len=*) :: sfile !< name of restart file
65+
return
66+
end subroutine write_stoch_restart_ocn
67+
68+
end module get_stochy_pattern_mod

config_src/external/OCEAN_stochastic_phyiscs/MOM_stochastics.F90 src/parameterizations/stochastic/MOM_stochastics.F90

+12-23
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,20 @@ module MOM_stochastics
1919
use MOM_domains, only : root_PE,num_PEs
2020
use MOM_coms, only : Get_PElist
2121
use stochastic_physics, only : init_stochastic_physics_ocn, run_stochastic_physics_ocn
22-
use get_stochy_pattern_mod, only: write_stoch_restart_ocn
2322

2423
#include <MOM_memory.h>
2524

2625
implicit none ; private
2726

28-
public stochastics_init, update_stochastics, write_mom_restart_stoch
27+
public stochastics_init, update_stochastics
2928

3029
!> This control structure holds parameters for the MOM_stochastics module
3130
type, public:: stochastic_CS
32-
logical :: do_sppt !< If true, stochastically perturb the diabatic
33-
logical :: pert_epbl !! If true, then randomly perturb the KE dissipation and genration terms
34-
integer :: id_sppt_wts = -1
35-
integer :: id_epbl1_wts=-1,id_epbl2_wts=-1
31+
logical :: do_sppt !< If true, stochastically perturb the diabatic
32+
logical :: pert_epbl !< If true, then randomly perturb the KE dissipation and genration terms
33+
integer :: id_sppt_wts = -1 !< Diagnostic id for SPPT
34+
integer :: id_epbl1_wts=-1 !< Diagnostic id for epbl generation perturbation
35+
integer :: id_epbl2_wts=-1 !< Diagnostic id for epbl dissipation perturbation
3636
! stochastic patterns
3737
real, allocatable :: sppt_wts(:,:) !< Random pattern for ocean SPPT
3838
!! tendencies with a number between 0 and 2
@@ -47,9 +47,9 @@ module MOM_stochastics
4747
!! This subroutine initializes the stochastics physics control structure.
4848
subroutine stochastics_init(dt, grid, GV, CS, param_file, diag, Time)
4949
real, intent(in) :: dt !< time step [T ~> s]
50-
type(ocean_grid_type), intent(in) :: grid ! horizontal grid information
51-
type(verticalGrid_type), intent(in) :: GV ! vertical grid structure
52-
type(stochastic_CS), pointer, intent(inout):: CS
50+
type(ocean_grid_type), intent(in) :: grid !< horizontal grid information
51+
type(verticalGrid_type), intent(in) :: GV !< vertical grid structure
52+
type(stochastic_CS), pointer, intent(inout):: CS !< stochastic control structure
5353
type(param_file_type), intent(in) :: param_file !< A structure to parse for run-time parameters
5454
type(diag_ctrl), target, intent(inout) :: diag !< structure to regulate diagnostic output
5555
type(time_type), target :: Time !< model time
@@ -59,7 +59,7 @@ subroutine stochastics_init(dt, grid, GV, CS, param_file, diag, Time)
5959
integer :: num_procs ! number of processors to pass to stochastic physics
6060
integer :: iret ! return code from stochastic physics
6161
integer :: me ! my pe
62-
integer :: master ! root pe
62+
integer :: pe_zero ! root pe
6363
integer :: nx ! number of x-points including halo
6464
integer :: ny ! number of x-points including halo
6565

@@ -95,11 +95,11 @@ subroutine stochastics_init(dt, grid, GV, CS, param_file, diag, Time)
9595
num_procs=num_PEs()
9696
allocate(pelist(num_procs))
9797
call Get_PElist(pelist,commID = mom_comm)
98-
master=root_PE()
98+
pe_zero=root_PE()
9999
nx = grid%ied - grid%isd + 1
100100
ny = grid%jed - grid%jsd + 1
101101
call init_stochastic_physics_ocn(dt,grid%geoLonT,grid%geoLatT,nx,ny,GV%ke, &
102-
CS%pert_epbl,CS%do_sppt,master,mom_comm,iret)
102+
CS%pert_epbl,CS%do_sppt,pe_zero,mom_comm,iret)
103103
if (iret/=0) then
104104
call MOM_error(FATAL, "call to init_stochastic_physics_ocn failed")
105105
return
@@ -140,16 +140,5 @@ subroutine update_stochastics(CS)
140140
return
141141
end subroutine update_stochastics
142142

143-
!< wrapper to write ocean stochastic restarts
144-
subroutine write_mom_restart_stoch(filename)
145-
character(len=*) :: filename
146-
147-
call callTree_enter("write_mom_restart_stoch(), MOM_stochastics.F90")
148-
149-
call write_stoch_restart_ocn(filename)
150-
151-
return
152-
end subroutine write_mom_restart_stoch
153-
154143
end module MOM_stochastics
155144

src/parameterizations/vertical/MOM_energetic_PBL.F90

+2-2
Original file line numberDiff line numberDiff line change
@@ -600,8 +600,8 @@ subroutine ePBL_column(h, u, v, T0, S0, dSV_dT, dSV_dS, TKE_forcing, B_flux, abs
600600
optional, pointer :: Waves !< Wave CS for Langmuir turbulence
601601
type(ocean_grid_type), &
602602
optional, intent(inout) :: G !< The ocean's grid structure.
603-
real, optional, intent(in) :: epbl1_wt ! random number to perturb KE generation
604-
real, optional, intent(in) :: epbl2_wt ! random number to perturb KE dissipation
603+
real, optional, intent(in) :: epbl1_wt !< random number to perturb KE generation
604+
real, optional, intent(in) :: epbl2_wt !< random number to perturb KE dissipation
605605
integer, optional, intent(in) :: i !< The i-index to work on (used for Waves)
606606
integer, optional, intent(in) :: j !< The i-index to work on (used for Waves)
607607

0 commit comments

Comments
 (0)