@@ -227,8 +227,7 @@ module MOM
227227 type (diag_ctrl) :: diag ! < structure to regulate diagnostic output timing
228228 type (vertvisc_type) :: visc ! < structure containing vertical viscosities,
229229 ! ! bottom drag viscosities, and related fields
230- type (MEKE_type), pointer :: MEKE = > NULL () ! < structure containing fields
231- ! ! related to the Mesoscale Eddy Kinetic Energy
230+ type (MEKE_type) :: MEKE ! < Fields related to the Mesoscale Eddy Kinetic Energy
232231 logical :: adiabatic ! < If true, there are no diapycnal mass fluxes, and no calls
233232 ! ! to routines to calculate or apply diapycnal fluxes.
234233 logical :: diabatic_first ! < If true, apply diabatic and thermodynamic processes before time
@@ -347,21 +346,19 @@ module MOM
347346 ! < Pointer to the control structure used for the unsplit RK2 dynamics
348347 type (MOM_dyn_split_RK2_CS), pointer :: dyn_split_RK2_CSp = > NULL ()
349348 ! < Pointer to the control structure used for the mode-split RK2 dynamics
350- type (thickness_diffuse_CS), pointer :: thickness_diffuse_CSp = > NULL ()
349+ type (thickness_diffuse_CS) :: thickness_diffuse_CSp
351350 ! < Pointer to the control structure used for the isopycnal height diffusive transport.
352351 ! ! This is also common referred to as Gent-McWilliams diffusion
353- type (mixedlayer_restrat_CS), pointer :: mixedlayer_restrat_CSp = > NULL ()
352+ type (mixedlayer_restrat_CS) :: mixedlayer_restrat_CSp
354353 ! < Pointer to the control structure used for the mixed layer restratification
355- type (set_visc_CS), pointer :: set_visc_CSp = > NULL ()
354+ type (set_visc_CS) :: set_visc_CSp
356355 ! < Pointer to the control structure used to set viscosities
357356 type (diabatic_CS), pointer :: diabatic_CSp = > NULL ()
358357 ! < Pointer to the control structure for the diabatic driver
359- type (MEKE_CS), pointer :: MEKE_CSp = > NULL ()
358+ type (MEKE_CS) :: MEKE_CSp
360359 ! < Pointer to the control structure for the MEKE updates
361- type (VarMix_CS), pointer :: VarMix = > NULL ()
362- ! < Pointer to the control structure for the variable mixing module
363- type (Barotropic_CS), pointer :: Barotropic_CSp = > NULL ()
364- ! < Pointer to the control structure for the barotropic module
360+ type (VarMix_CS) :: VarMix
361+ ! < Control structure for the variable mixing module
365362 type (tracer_registry_type), pointer :: tracer_Reg = > NULL ()
366363 ! < Pointer to the MOM tracer registry
367364 type (tracer_advect_CS), pointer :: tracer_adv_CSp = > NULL ()
@@ -388,7 +385,7 @@ module MOM
388385 ! Pointers to control structures used for diagnostics
389386 type (sum_output_CS), pointer :: sum_output_CSp = > NULL ()
390387 ! < Pointer to the globally summed output control structure
391- type (diagnostics_CS), pointer :: diagnostics_CSp = > NULL ()
388+ type (diagnostics_CS) :: diagnostics_CSp
392389 ! < Pointer to the MOM diagnostics control structure
393390 type (offline_transport_CS), pointer :: offline_CSp = > NULL ()
394391 ! < Pointer to the offline tracer transport control structure
@@ -637,7 +634,7 @@ subroutine step_MOM(forces_in, fluxes_in, sfc_state, Time_start, time_int_in, CS
637634 CS% time_in_cycle = 0.0
638635 do j= js,je ; do i= is,ie ; CS% ssh_rint(i,j) = 0.0 ; enddo ; enddo
639636
640- if (associated ( CS% VarMix) ) then
637+ if (CS% VarMix% use_variable_mixing ) then
641638 call enable_averages(cycle_time, Time_start + real_to_time(US% T_to_s* cycle_time), CS% diag)
642639 call calc_resoln_function(h, CS% tv, G, GV, US, CS% VarMix)
643640 call calc_depth_function(G, CS% VarMix)
@@ -1033,7 +1030,7 @@ subroutine step_MOM_dynamics(forces, p_surf_begin, p_surf_end, dt, dt_thermo, &
10331030
10341031 call enable_averages(dt_thermo, Time_local+ real_to_time(US% T_to_s* (dt_thermo- dt)), CS% diag)
10351032 call cpu_clock_begin(id_clock_thick_diff)
1036- if (associated ( CS% VarMix) ) &
1033+ if (CS% VarMix% use_variable_mixing ) &
10371034 call calc_slope_functions(h, CS% tv, dt, G, GV, US, CS% VarMix, OBC= CS% OBC)
10381035 call thickness_diffuse(h, CS% uhtr, CS% vhtr, CS% tv, dt_thermo, G, GV, US, &
10391036 CS% MEKE, CS% VarMix, CS% CDp, CS% thickness_diffuse_CSp)
@@ -1112,7 +1109,7 @@ subroutine step_MOM_dynamics(forces, p_surf_begin, p_surf_end, dt, dt_thermo, &
11121109
11131110 if (CS% debug) call hchksum(h," Pre-thickness_diffuse h" , G% HI, haloshift= 0 , scale= GV% H_to_m)
11141111
1115- if (associated ( CS% VarMix) ) &
1112+ if (CS% VarMix% use_variable_mixing ) &
11161113 call calc_slope_functions(h, CS% tv, dt, G, GV, US, CS% VarMix, OBC= CS% OBC)
11171114 call thickness_diffuse(h, CS% uhtr, CS% vhtr, CS% tv, dt, G, GV, US, &
11181115 CS% MEKE, CS% VarMix, CS% CDp, CS% thickness_diffuse_CSp)
@@ -1563,7 +1560,7 @@ subroutine step_offline(forces, fluxes, sfc_state, Time_start, time_interval, CS
15631560
15641561 ! Perform offline diffusion if requested
15651562 if (.not. skip_diffusion) then
1566- if (associated ( CS% VarMix) ) then
1563+ if (CS% VarMix% use_variable_mixing ) then
15671564 call pass_var(CS% h, G% Domain)
15681565 call calc_resoln_function(CS% h, CS% tv, G, GV, US, CS% VarMix)
15691566 call calc_depth_function(G, CS% VarMix)
@@ -1589,7 +1586,7 @@ subroutine step_offline(forces, fluxes, sfc_state, Time_start, time_interval, CS
15891586 call offline_redistribute_residual(CS% offline_CSp, CS% h, uhtr, vhtr, adv_converged)
15901587 ! Perform offline diffusion if requested
15911588 if (.not. skip_diffusion) then
1592- if (associated ( CS% VarMix) ) then
1589+ if (CS% VarMix% use_variable_mixing ) then
15931590 call pass_var(CS% h, G% Domain)
15941591 call calc_resoln_function(CS% h, CS% tv, G, GV, US, CS% VarMix)
15951592 call calc_depth_function(G, CS% VarMix)
@@ -2333,7 +2330,10 @@ subroutine initialize_MOM(Time, Time_init, param_file, dirs, CS, restart_CSp, &
23332330 ! Use the Wright equation of state by default, unless otherwise specified
23342331 ! Note: this line and the following block ought to be in a separate
23352332 ! initialization routine for tv.
2336- if (use_EOS) call EOS_init(param_file, CS% tv% eqn_of_state, US)
2333+ if (use_EOS) then
2334+ allocate (CS% tv% eqn_of_state)
2335+ call EOS_init(param_file, CS% tv% eqn_of_state, US)
2336+ endif
23372337 if (use_temperature) then
23382338 allocate (CS% tv% TempxPmE(isd:ied,jsd:jed), source= 0.0 )
23392339 if (use_geothermal) then
@@ -2351,10 +2351,10 @@ subroutine initialize_MOM(Time, Time_init, param_file, dirs, CS, restart_CSp, &
23512351 CS% dyn_split_RK2_CSp, restart_CSp, CS% uh, CS% vh)
23522352 elseif (CS% use_RK2) then
23532353 call register_restarts_dyn_unsplit_RK2(HI, GV, param_file, &
2354- CS% dyn_unsplit_RK2_CSp, restart_CSp )
2354+ CS% dyn_unsplit_RK2_CSp)
23552355 else
23562356 call register_restarts_dyn_unsplit(HI, GV, param_file, &
2357- CS% dyn_unsplit_CSp, restart_CSp )
2357+ CS% dyn_unsplit_CSp)
23582358 endif
23592359
23602360 ! This subroutine calls user-specified tracer registration routines.
@@ -2662,14 +2662,14 @@ subroutine initialize_MOM(Time, Time_init, param_file, dirs, CS, restart_CSp, &
26622662 endif
26632663 elseif (CS% use_RK2) then
26642664 call initialize_dyn_unsplit_RK2(CS% u, CS% v, CS% h, Time, G, GV, US, &
2665- param_file, diag, CS% dyn_unsplit_RK2_CSp, restart_CSp, &
2666- CS% ADp, CS% CDp, MOM_internal_state, CS% MEKE, CS % OBC, &
2665+ param_file, diag, CS% dyn_unsplit_RK2_CSp, &
2666+ CS% ADp, CS% CDp, MOM_internal_state, CS% OBC, &
26672667 CS% update_OBC_CSp, CS% ALE_CSp, CS% set_visc_CSp, CS% visc, dirs, &
26682668 CS% ntrunc, cont_stencil= CS% cont_stencil)
26692669 else
26702670 call initialize_dyn_unsplit(CS% u, CS% v, CS% h, Time, G, GV, US, &
2671- param_file, diag, CS% dyn_unsplit_CSp, restart_CSp, &
2672- CS% ADp, CS% CDp, MOM_internal_state, CS% MEKE, CS % OBC, &
2671+ param_file, diag, CS% dyn_unsplit_CSp, &
2672+ CS% ADp, CS% CDp, MOM_internal_state, CS% OBC, &
26732673 CS% update_OBC_CSp, CS% ALE_CSp, CS% set_visc_CSp, CS% visc, dirs, &
26742674 CS% ntrunc, cont_stencil= CS% cont_stencil)
26752675 endif
@@ -3595,7 +3595,6 @@ subroutine MOM_end(CS)
35953595 endif
35963596
35973597 call MOM_diagnostics_end(CS% diagnostics_CSp, CS% ADp, CS% CDp)
3598- deallocate (CS% diagnostics_CSp)
35993598
36003599 if (CS% offline_tracer_mode) call offline_transport_end(CS% offline_CSp)
36013600
@@ -3613,25 +3612,9 @@ subroutine MOM_end(CS)
36133612 endif
36143613
36153614 call thickness_diffuse_end(CS% thickness_diffuse_CSp, CS% CDp)
3616- deallocate (CS% thickness_diffuse_CSp)
3617-
3618- if (associated (CS% VarMix)) then
3619- call VarMix_end(CS% VarMix)
3620- deallocate (CS% VarMix)
3621- endif
3622-
3623- if (associated (CS% mixedlayer_restrat_CSp)) &
3624- deallocate (CS% mixedlayer_restrat_CSp)
3625-
3626- if (associated (CS% set_visc_CSp)) &
3627- call set_visc_end(CS% visc, CS% set_visc_CSp)
3628-
3629- if (associated (CS% MEKE_CSp)) deallocate (CS% MEKE_CSp)
3630-
3631- if (associated (CS% MEKE)) then
3632- call MEKE_end(CS% MEKE)
3633- deallocate (CS% MEKE)
3634- endif
3615+ call VarMix_end(CS% VarMix)
3616+ call set_visc_end(CS% visc, CS% set_visc_CSp)
3617+ call MEKE_end(CS% MEKE)
36353618
36363619 if (associated (CS% tv% internal_heat)) deallocate (CS% tv% internal_heat)
36373620 if (associated (CS% tv% TempxPmE)) deallocate (CS% tv% TempxPmE)
0 commit comments