Skip to content

Commit

Permalink
Merge branch 'whannah/mmf/pam-variance-transport' into next (#6015)
Browse files Browse the repository at this point in the history
Implement the variance transport (VT) feature from SAM++ into PAM as a stealth feature. During testing it became clear that inclusion of strong hyperdiffusion in PAM made the variance transport unnecessary, but reducing the hyperdiffusion in cases with VT enabled led to instabilities. Thus, we will implement the VT capability here and leave it stealth in order to focus on improving the representation of horizontal mixing before revisiting whether VT is needed.

[BFB]
  • Loading branch information
brhillman committed Feb 20, 2024
2 parents 353e5bb + e747fa7 commit 9715a34
Show file tree
Hide file tree
Showing 3 changed files with 294 additions and 12 deletions.
24 changes: 13 additions & 11 deletions components/eam/src/physics/crm/crm_physics.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1302,14 +1302,23 @@ subroutine crm_physics_tend(ztodt, state, tend, ptend, pbuf2d, cam_in, cam_out,
call pam_mirror_array_readonly( 'input_tau00', crm_input%tau00 )
! call pam_mirror_array_readonly( 'input_ul_esmt', crm_input%ul_esmt )
! call pam_mirror_array_readonly( 'input_vl_esmt', crm_input%vl_esmt )
! call pam_mirror_array_readonly( 'input_t_vt', crm_input%t_vt )
! call pam_mirror_array_readonly( 'input_q_vt', crm_input%q_vt )
! call pam_mirror_array_readonly( 'input_u_vt', crm_input%u_vt )

call pam_mirror_array_readonly( 'input_nccn_prescribed',crm_input%nccn_prescribed )
call pam_mirror_array_readonly( 'input_nc_nuceat_tend', crm_input%nc_nuceat_tend )
call pam_mirror_array_readonly( 'input_ni_activated', crm_input%ni_activated )

! Variance transport inputs and outputs
if (use_MMF_VT) then
call pam_mirror_array_readonly( 'input_vt_t', crm_input%t_vt )
call pam_mirror_array_readonly( 'input_vt_q', crm_input%q_vt )
call pam_mirror_array_readonly( 'input_vt_u', crm_input%u_vt )
call pam_mirror_array_readwrite( 'output_t_vt_tend', crm_output%t_vt_tend )
call pam_mirror_array_readwrite( 'output_q_vt_tend', crm_output%q_vt_tend )
call pam_mirror_array_readwrite( 'output_u_vt_tend', crm_output%u_vt_tend )
call pam_mirror_array_readwrite( 'output_t_vt_ls', crm_output%t_vt_ls )
call pam_mirror_array_readwrite( 'output_q_vt_ls', crm_output%q_vt_ls )
call pam_mirror_array_readwrite( 'output_u_vt_ls', crm_output%u_vt_ls )
end if

call pam_mirror_array_readwrite( 'state_u_wind', crm_state%u_wind )
call pam_mirror_array_readwrite( 'state_v_wind', crm_state%v_wind )
call pam_mirror_array_readwrite( 'state_w_wind', crm_state%w_wind )
Expand Down Expand Up @@ -1389,12 +1398,6 @@ subroutine crm_physics_tend(ztodt, state, tend, ptend, pbuf2d, cam_in, cam_out,
call pam_mirror_array_readwrite( 'output_qltend', crm_output%qltend, '' )
call pam_mirror_array_readwrite( 'output_qcltend', crm_output%qcltend, '' )
call pam_mirror_array_readwrite( 'output_qiltend', crm_output%qiltend, '' )
! call pam_mirror_array_readwrite( 'output_t_vt_tend', crm_output%t_vt_tend, '' )
! call pam_mirror_array_readwrite( 'output_q_vt_tend', crm_output%q_vt_tend, '' )
! call pam_mirror_array_readwrite( 'output_u_vt_tend', crm_output%u_vt_tend, '' )
! call pam_mirror_array_readwrite( 'output_t_vt_ls', crm_output%t_vt_ls, '' )
! call pam_mirror_array_readwrite( 'output_q_vt_ls', crm_output%q_vt_ls, '' )
! call pam_mirror_array_readwrite( 'output_u_vt_ls', crm_output%u_vt_ls, '' )
call pam_mirror_array_readwrite( 'output_ultend', crm_output%ultend, '' )
call pam_mirror_array_readwrite( 'output_vltend', crm_output%vltend, '' )
! call pam_mirror_array_readwrite( 'output_tk', crm_output%tk, '' )
Expand Down Expand Up @@ -1450,7 +1453,6 @@ subroutine crm_physics_tend(ztodt, state, tend, ptend, pbuf2d, cam_in, cam_out,
call pam_register_dimension('gcm_lev',pver)

call pam_set_option('use_MMF_VT', use_MMF_VT_tmp )
call pam_set_option('MMF_VT_wn_max', MMF_VT_wn_max )
call pam_set_option('use_MMF_ESMT', use_MMF_ESMT_tmp )

call pam_set_option('use_crm_accel', use_crm_accel_tmp )
Expand Down
15 changes: 14 additions & 1 deletion components/eam/src/physics/crm/pam/pam_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "pam_statistics.h"
#include "pam_output.h"
#include "pam_accelerate.h"
#include "pam_variance_transport.h"
#include "sponge_layer.h"
#include "surface_friction.h"
#include "scream_cxx_interface_finalize.h"
Expand Down Expand Up @@ -46,6 +47,7 @@ extern "C" void pam_driver() {
auto is_first_step = coupler.get_option<bool>("is_first_step");
auto is_restart = coupler.get_option<bool>("is_restart");
bool use_crm_accel = coupler.get_option<bool>("use_crm_accel");
bool use_MMF_VT = coupler.get_option<bool>("use_MMF_VT");
bool enable_physics_tend_stats = coupler.get_option<bool>("enable_physics_tend_stats");
//------------------------------------------------------------------------------------------------
// set various coupler options
Expand Down Expand Up @@ -111,6 +113,11 @@ extern "C" void pam_driver() {
// initialize variables for CRM mean-state acceleration
if (use_crm_accel) { pam_accelerate_init(coupler); }

if (use_MMF_VT) {
pam_variance_transport_init(coupler);
pam_variance_transport_compute_forcing(coupler);
}

// initilize surface "psuedo-friction" (psuedo => doesn't match "real" GCM friction)
auto input_tau = dm_host.get<real const,1>("input_tau00").createDeviceCopy();
auto input_bflx = dm_host.get<real const,1>("input_bflxls").createDeviceCopy();
Expand Down Expand Up @@ -166,7 +173,8 @@ extern "C" void pam_driver() {

if (enable_check_state) { pam_debug_check_state(coupler, 1, nstep); }

// run a PAM time step
// Apply forcing tendencies
if (use_MMF_VT) { pam_variance_transport_apply_forcing(coupler); }
coupler.run_module( "apply_gcm_forcing_tendencies" , modules::apply_gcm_forcing_tendencies );
coupler.run_module( "radiation" , [&] (pam::PamCoupler &coupler) {rad .timeStep(coupler);} );
if (enable_check_state) { pam_debug_check_state(coupler, 2, nstep); }
Expand Down Expand Up @@ -237,6 +245,11 @@ extern "C" void pam_driver() {
pam_statistics_compute_means(coupler);
pam_statistics_copy_to_host(coupler);

if (use_MMF_VT) {
pam_variance_transport_compute_feedback(coupler);
pam_variance_transport_copy_to_host(coupler);
}

//------------------------------------------------------------------------------------------------
// Finalize and clean up
micro .finalize(coupler);
Expand Down
Loading

0 comments on commit 9715a34

Please sign in to comment.