Skip to content

Commit b8d9888

Browse files
committed
place stochastic array in fluxes container and make SPPT specific arrays allocatable
2 parents d984a7e + eb88219 commit b8d9888

5 files changed

Lines changed: 38 additions & 25 deletions

File tree

config_src/nuopc_driver/mom_cap.F90

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1379,6 +1379,8 @@ subroutine ModelAdvance(gcomp, rc)
13791379
character(len=*),parameter :: subname='(MOM_cap:ModelAdvance)'
13801380
character(len=8) :: suffix
13811381
integer :: num_rest_files
1382+
logical :: do_sppt = .false.
1383+
logical :: pert_epbl = .false.
13821384

13831385
rc = ESMF_SUCCESS
13841386
if(profile_memory) call ESMF_VMLogMemInfo("Entering MOM Model_ADVANCE: ")
@@ -1587,15 +1589,17 @@ subroutine ModelAdvance(gcomp, rc)
15871589
! write restart file(s)
15881590
call ocean_model_restart(ocean_state, restartname=restartname)
15891591

1590-
! write stochastic physics restart file if active
1591-
if (ESMF_AlarmIsRinging(stop_alarm, rc=rc)) then
1592-
write(restartname,'(A)')"ocn_stoch.res.nc"
1593-
else
1594-
write(restartname,'(A,I4.4,"-",I2.2,"-",I2.2,"-",I2.2,"-",I2.2,"-",I2.2,A)') &
1595-
"ocn_stoch.res.", year, month, day, hour, minute, seconds,".nc"
1592+
if (ocean_state%do_sppt .OR. ocean_state%pert_epbl) then
1593+
if (ESMF_AlarmIsRinging(stop_alarm, rc=rc)) then
1594+
write(restartname,'(A)')"ocn_stoch.res.nc"
1595+
else
1596+
write(restartname,'(A,I4.4,"-",I2.2,"-",I2.2,"-",I2.2,"-",I2.2,"-",I2.2,A)') &
1597+
"ocn_stoch.res.", year, month, day, hour, minute, seconds,".nc"
1598+
endif
1599+
call ESMF_LogWrite("MOM_cap: Writing stoch restart : "//trim(restartname), &
1600+
ESMF_LOGMSG_INFO)
1601+
call write_stoch_restart_ocn('RESTART/'//trim(restartname))
15961602
endif
1597-
call ESMF_LogWrite("MOM_cap: Writing restart : "//trim(restartname), ESMF_LOGMSG_INFO)
1598-
call write_stoch_restart_ocn('RESTART/'//trim(restartname))
15991603
endif
16001604

16011605
if (is_root_pe()) then

config_src/nuopc_driver/mom_ocean_model_nuopc.F90

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ module MOM_ocean_model_nuopc
6363
use MOM_surface_forcing_nuopc, only : ice_ocean_boundary_type, surface_forcing_CS
6464
use MOM_surface_forcing_nuopc, only : forcing_save_restart
6565
use MOM_domains, only : root_PE,PE_here,num_PEs
66+
use MOM_coms, only : Get_PElist
6667
use stochastic_physics, only : init_stochastic_physics_ocn, run_stochastic_physics_ocn
6768

6869
#include <MOM_memory.h>
@@ -176,8 +177,8 @@ module MOM_ocean_model_nuopc
176177
!! steps can span multiple coupled time steps.
177178
logical :: diabatic_first !< If true, apply diabatic and thermodynamic
178179
!! processes before time stepping the dynamics.
179-
logical :: do_sppt !< If true, allocate array for SPPT
180-
logical :: pert_epbl !< If true, allocate arrays for energetic PBL perturbations
180+
logical,public :: do_sppt !< If true, allocate array for SPPT
181+
logical,public :: pert_epbl !< If true, allocate arrays for energetic PBL perturbations
181182

182183
real :: eps_omesh !< Max allowable difference between ESMF mesh and MOM6
183184
!! domain coordinates
@@ -253,6 +254,7 @@ subroutine ocean_model_init(Ocean_sfc, OS, Time_init, Time_in, gas_fields_ocn, i
253254
!! If HFrz <= 0 (default), melt potential will not be computed.
254255
logical :: use_melt_pot!< If true, allocate melt_potential array
255256
! stochastic physics
257+
integer,allocatable :: pelist(:) ! list of pes for this instance of the ocean
256258
integer :: mom_comm ! list of pes for this instance of the ocean
257259
integer :: num_procs ! number of processors to pass to stochastic physics
258260
integer :: iret ! return code from stochastic physics
@@ -439,7 +441,9 @@ subroutine ocean_model_init(Ocean_sfc, OS, Time_init, Time_in, gas_fields_ocn, i
439441
default=.false.)
440442
if (OS%do_sppt .OR. OS%pert_epbl) then
441443
num_procs=num_PEs()
442-
call mpp_get_pelist(Ocean_sfc%domain, mom_comm)
444+
allocate(pelist(num_procs))
445+
!call mpp_get_pelist(pelist, commID=mom_comm)
446+
call Get_PElist(pelist,commID = mom_comm)
443447
me=PE_here()
444448
master=root_PE()
445449

src/core/MOM.F90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ module MOM
123123
use MOM_variables, only : surface, allocate_surface_state, deallocate_surface_state
124124
use MOM_variables, only : thermo_var_ptrs, vertvisc_type
125125
use MOM_variables, only : accel_diag_ptrs, cont_diag_ptrs, ocean_internal_state
126-
use MOM_variables, only : rotate_surface_state,stochastic_pattern
126+
use MOM_variables, only : rotate_surface_state
127127
use MOM_verticalGrid, only : verticalGrid_type, verticalGridInit, verticalGridEnd
128128
use MOM_verticalGrid, only : fix_restart_scaling
129129
use MOM_verticalGrid, only : get_thickness_units, get_flux_units, get_tr_flux_units

src/parameterizations/vertical/MOM_diabatic_driver.F90

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -289,9 +289,9 @@ subroutine diabatic(u, v, h, tv, Hml, fluxes, visc, ADp, CDp, dt, Time_end, &
289289
integer :: i, j, k, m, is, ie, js, je, nz
290290
logical :: showCallTree ! If true, show the call tree
291291

292-
real, allocatable(:,:,:) :: h_in ! thickness before thermodynamics
293-
real, allocatable(:,:,:) :: t_in ! temperature before thermodynamics
294-
real, allocatable(:,:,:) :: s_in ! salinity before thermodynamics
292+
real, allocatable, dimension(:,:,:) :: h_in ! thickness before thermodynamics
293+
real, allocatable, dimension(:,:,:) :: t_in ! temperature before thermodynamics
294+
real, allocatable, dimension(:,:,:) :: s_in ! salinity before thermodynamics
295295
real :: t_tend,s_tend,h_tend ! holder for tendencey needed for SPPT
296296
real :: t_pert,s_pert,h_pert ! holder for perturbations needed for SPPT
297297

@@ -302,9 +302,9 @@ subroutine diabatic(u, v, h, tv, Hml, fluxes, visc, ADp, CDp, dt, Time_end, &
302302
allocate(h_in(G%isd:G%ied, G%jsd:G%jed,G%ke))
303303
allocate(t_in(G%isd:G%ied, G%jsd:G%jed,G%ke))
304304
allocate(s_in(G%isd:G%ied, G%jsd:G%jed,G%ke))
305-
h_in(:,:) = h(:,:)
306-
t_in(:,:) = tv%T(:,:)
307-
s_in(:,:) = tv%S(:,:)
305+
h_in(:,:,:)=h(:,:,:)
306+
t_in(:,:,:)=tv%T(:,:,:)
307+
s_in(:,:,:)=tv%S(:,:,:)
308308

309309
if (CS%id_sppt_wts > 0) then
310310
call post_data(CS%id_sppt_wts, fluxes%sppt_wts, CS%diag)
@@ -458,6 +458,7 @@ subroutine diabatic(u, v, h, tv, Hml, fluxes, visc, ADp, CDp, dt, Time_end, &
458458
if (CS%debugConservation) call MOM_state_stats('leaving diabatic', u, v, h, tv%T, tv%S, G, GV, US)
459459

460460
if (CS%do_sppt) then
461+
! perturb diabatic tendecies
461462
do k=1,nz
462463
do j=js,je
463464
do i=is,ie
@@ -468,17 +469,20 @@ subroutine diabatic(u, v, h, tv, Hml, fluxes, visc, ADp, CDp, dt, Time_end, &
468469
t_pert=t_tend+t_in(i,j,k)
469470
s_pert=s_tend+s_in(i,j,k)
470471
if (h_pert > GV%Angstrom_H) then
471-
h(i,j,k)=h_pert
472+
h(i,j,k) = h_pert
472473
else
473-
h(i,j,k)=GV%Angstrom_H
474+
h(i,j,k) = GV%Angstrom_H
474475
endif
475-
tv%T(i,j,k)=t_pert
476+
tv%T(i,j,k) = t_pert
476477
if (s_pert > 0.0) then
477-
tv%S(i,j,k)=s_pert
478+
tv%S(i,j,k) = s_pert
478479
endif
479480
enddo
480481
enddo
481482
enddo
483+
deallocate(h_in)
484+
deallocate(t_in)
485+
deallocate(s_in)
482486
endif
483487

484488
end subroutine diabatic

src/parameterizations/vertical/MOM_energetic_PBL.F90

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,8 @@ subroutine energetic_PBL(h_3d, u_3d, v_3d, tv, fluxes, dt, Kd_int, G, GV, US, CS
461461
call ePBL_column(h, u, v, T0, S0, dSV_dT_1d, dSV_dS_1d, TKE_forcing, B_flux, absf, &
462462
u_star, u_star_mean, dt, MLD_io, Kd, mixvel, mixlen, GV, &
463463
US, CS, eCD, dt_diag=dt_diag, Waves=Waves, G=G, &
464-
epbl1_wt=epbl1_wts(i,j),epbl2_wt=epbl2_wts(i,j),i=i, j=j)
464+
epbl1_wt=fluxes%epbl1_wts(i,j),epbl2_wt=fluxes%epbl2_wts(i,j), &
465+
i=i, j=j)
465466
else
466467
call ePBL_column(h, u, v, T0, S0, dSV_dT_1d, dSV_dS_1d, TKE_forcing, B_flux, absf, &
467468
u_star, u_star_mean, dt, MLD_io, Kd, mixvel, mixlen, GV, &
@@ -540,8 +541,8 @@ subroutine energetic_PBL(h_3d, u_3d, v_3d, tv, fluxes, dt, Kd_int, G, GV, US, CS
540541
! only write random patterns if running with stochastic physics, otherwise the
541542
! array is unallocated and will give an error
542543
if (CS%pert_epbl) then
543-
if (CS%id_epbl1_wts > 0) call post_data(CS%id_epbl1_wts, stochastics%epbl1_wts, CS%diag)
544-
if (CS%id_epbl2_wts > 0) call post_data(CS%id_epbl2_wts, stochastics%epbl2_wts, CS%diag)
544+
if (CS%id_epbl1_wts > 0) call post_data(CS%id_epbl1_wts, fluxes%epbl1_wts, CS%diag)
545+
if (CS%id_epbl2_wts > 0) call post_data(CS%id_epbl2_wts, fluxes%epbl2_wts, CS%diag)
545546
endif
546547
endif
547548

0 commit comments

Comments
 (0)