Skip to content

Commit

Permalink
Merge pull request #156 from E3SM-Project/whannah/updates-for-scream
Browse files Browse the repository at this point in the history
fixes for updates from SCREAM downstream merge
  • Loading branch information
whannah1 authored Jul 31, 2024
2 parents 5931666 + aefd254 commit 3ea20ad
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 9 deletions.
8 changes: 5 additions & 3 deletions pam_core/modules/gcm_forcing.h
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,11 @@ namespace modules {
if (i == 0 && j == 0) {
if (rho_x_neg_mass(k,iens) > rho_x_pos_mass(k,iens)) neg_too_large = true;
}
// Subtract mass proportional to this cells' portion of the total mass at the vertical level
real factor = rho_x(k,j,i,iens)*dz(k,iens) / rho_x_pos_mass(k,iens);
rho_x(k,j,i,iens) = max( 0._fp , rho_x(k,j,i,iens) - (rho_x_neg_mass(k,iens) * factor)/dz(k,iens) );
if (rho_x_pos_mass(k,iens)>0){
// Subtract mass proportional to this cells' portion of the total mass at the vertical level
real factor = rho_x(k,j,i,iens)*dz(k,iens) / rho_x_pos_mass(k,iens);
rho_x(k,j,i,iens) = max( 0._fp , rho_x(k,j,i,iens) - (rho_x_neg_mass(k,iens) * factor)/dz(k,iens) );
}
});

if (neg_too_large.hostRead()) {
Expand Down
5 changes: 2 additions & 3 deletions physics/scream_cxx_interfaces/scream_cxx_interface_p3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,8 @@ namespace pam {
p3_main_cxx_mutex.unlock();

// hardcode runtime options to match common scream settings for now
P3F::P3Runtime runtime_options{
740.0e3 // max_total_ni
};
P3F::P3Runtime runtime_options;
runtime_options.max_total_ni = 740.0e3;

const int nlev_pack = ekat::npack<Spack>(nlev);
const auto policy = ekat::ExeSpaceUtils<KT::ExeSpace>::get_default_team_policy(ncol, nlev_pack);
Expand Down
6 changes: 5 additions & 1 deletion physics/scream_cxx_interfaces/scream_cxx_interface_shoc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ namespace pam {
array_ir::ArrayIR<double,2> const & w3, // out
array_ir::ArrayIR<double,2> const & wqls_sec, // out
array_ir::ArrayIR<double,2> const & brunt, // out
array_ir::ArrayIR<double,2> const & shoc_ql2 ) { // out
array_ir::ArrayIR<double,2> const & shoc_ql2, // out
array_ir::ArrayIR<double,2> const & shoc_tkh ) { // out
using ScreamCXX::ArrayIR_to_View_of_Packs;
using ScreamCXX::ArrayIR_to_View;
using namespace scream;
Expand Down Expand Up @@ -136,10 +137,13 @@ namespace pam {

auto pblh_1d = ArrayIR_to_View (pblh );
auto shoc_ql2_2d = ArrayIR_to_View_of_Packs(shoc_ql2);
auto shoc_tkh_2d = ArrayIR_to_View_of_Packs(shoc_tkh);

SHOC::SHOCOutput shoc_output;
shoc_output.pblh = pblh_1d;
shoc_output.shoc_ql2 = shoc_ql2_2d;
shoc_output.tkh = shoc_tkh_2d;


//--------------------------------------------------------------------------
// Diagnostic Output
Expand Down
3 changes: 2 additions & 1 deletion physics/scream_cxx_interfaces/scream_cxx_interface_shoc.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ namespace pam {
array_ir::ArrayIR<double,2> const & w3, // out
array_ir::ArrayIR<double,2> const & wqls_sec, // out
array_ir::ArrayIR<double,2> const & brunt, // out
array_ir::ArrayIR<double,2> const & shoc_ql2 ); // out
array_ir::ArrayIR<double,2> const & shoc_ql2, // out
array_ir::ArrayIR<double,2> const & shoc_tkh ); // out

}

Expand Down
5 changes: 4 additions & 1 deletion physics/sgs/shoc/SGS.h
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,7 @@ class SGS {
auto transposed_shoc_wqls_sec = shoc_wqls_sec .createDeviceCopy().reshape(shoc_wqls_sec .extent(1),shoc_wqls_sec .extent(0));
auto transposed_shoc_brunt = shoc_brunt .createDeviceCopy().reshape(shoc_brunt .extent(1),shoc_brunt .extent(0));
auto transposed_shoc_ql2 = shoc_ql2 .createDeviceCopy().reshape(shoc_ql2 .extent(1),shoc_ql2 .extent(0));
auto transposed_shoc_tkh = shoc_tkh .createDeviceCopy().reshape(shoc_tkh .extent(1),shoc_tkh .extent(0));
auto transposed_shoc_qtracers = shoc_qtracers.createDeviceCopy().reshape(shoc_qtracers.extent(2),shoc_qtracers.extent(0),shoc_qtracers.extent(1));
auto transposed_shoc_hwind = real3d("transposed_shoc_hwind",shoc_u_wind.extent(1),2,shoc_u_wind.extent(0));

Expand Down Expand Up @@ -528,7 +529,8 @@ class SGS {
transposed_shoc_w3 .create_ArrayIR() , // out
transposed_shoc_wqls_sec .create_ArrayIR() , // out
transposed_shoc_brunt .create_ArrayIR() , // out
transposed_shoc_ql2 .create_ArrayIR() ); // out
transposed_shoc_ql2 .create_ArrayIR() , // out
transposed_shoc_tkh .create_ArrayIR() ); // out

// Store transposed outputs (one kernel for efficiency)
parallel_for( SimpleBounds<2>(nz+1,ncol) , YAKL_LAMBDA (int k, int i) {
Expand Down Expand Up @@ -556,6 +558,7 @@ class SGS {
shoc_wqls_sec(k,i) = transposed_shoc_wqls_sec(i,k);
shoc_brunt (k,i) = transposed_shoc_brunt (i,k);
shoc_ql2 (k,i) = transposed_shoc_ql2 (i,k);
shoc_tkh (k,i) = transposed_shoc_tkh (i,k);
shoc_u_wind (k,i) = transposed_shoc_hwind (i,0,k);
shoc_v_wind (k,i) = transposed_shoc_hwind (i,1,k);
for (int tr=0; tr < num_qtracers; tr++) {
Expand Down

0 comments on commit 3ea20ad

Please sign in to comment.