Skip to content

Commit

Permalink
Adding smagorinski code, but I can't test it because tests appear to …
Browse files Browse the repository at this point in the history
…be broken on current master, at least for PAM-A.
  • Loading branch information
mrnorman committed Jan 30, 2024
1 parent 87731d5 commit 9ba849a
Show file tree
Hide file tree
Showing 8 changed files with 482 additions and 11 deletions.
1 change: 1 addition & 0 deletions pam_core/MultipleFields.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ namespace pam {
}

YAKL_INLINE int get_num_fields() const { return num_fields; }
YAKL_INLINE int size() const { return num_fields; }

YAKL_INLINE auto operator() (int tr, int i1) const -> decltype(fields(tr)(i1)) {
return this->fields(tr)(i1);
Expand Down
3 changes: 2 additions & 1 deletion pam_core/Options.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ namespace pam {
int find_option_or_die( std::string key ) const {
int id = find_option(key);
if (id >= 0) return id;
endrun("ERROR: option not found");
std::cerr << "ERROR: Option (" << key << ") not found.";
endrun("");
return -1;
}

Expand Down
4 changes: 2 additions & 2 deletions pam_core/modules/gcm_forcing.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ namespace modules {
auto dt_gcm = coupler.get_option<real>("gcm_physics_dt");
real cp_d = coupler.get_option<real>("cp_d");
real grav = coupler.get_option<real>("grav");
real Lv = coupler.get_option<real>("latvap") ;
real Lf = coupler.get_option<real>("latice") ;
real Lv = coupler.get_option<real>("latvap",2501000.0) ;
real Lf = coupler.get_option<real>("latice",333700.0) ;

// Get current state from coupler
auto rho_d = dm.get<real const,4>( "density_dry" );
Expand Down
445 changes: 445 additions & 0 deletions pam_core/modules/les_smag.h

Large diffs are not rendered by default.

22 changes: 21 additions & 1 deletion pam_core/pam_coupler.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ namespace pam {
std::string desc;
bool positive;
bool adds_mass;
bool diffuse;
};
std::vector<Tracer> tracers;

Expand Down Expand Up @@ -203,7 +204,11 @@ namespace pam {



void add_tracer( std::string tracer_name , std::string tracer_desc , bool positive , bool adds_mass ) {
void add_tracer( std::string tracer_name ,
std::string tracer_desc ,
bool positive = true ,
bool adds_mass = true ,
bool diffuse = true ) {
int nz = get_nz ();
int ny = get_ny ();
int nx = get_nx ();
Expand Down Expand Up @@ -240,6 +245,21 @@ namespace pam {
}
tracer_found = false;
}
void get_tracer_info(std::string tracer_name , std::string &tracer_desc, bool &tracer_found ,
bool &positive , bool &adds_mass, bool &diffuse) const {
std::vector<std::string> ret;
for (int i=0; i < tracers.size(); i++) {
if (tracer_name == tracers[i].name) {
positive = tracers[i].positive ;
tracer_desc = tracers[i].desc ;
adds_mass = tracers[i].adds_mass;
diffuse = tracers[i].diffuse ;
tracer_found = true;
return;
}
}
tracer_found = false;
}



Expand Down
2 changes: 1 addition & 1 deletion standalone/mmf_simplified/build/cmakescript_pama.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ cmake \
-DPAM_DYCORE="awfl" \
-DPAM_MICRO="p3" \
-DPAM_RAD="none" \
-DPAM_SGS="shoc" \
-DPAM_SGS="none" \
-DPAM_RAD="none" \
-DPAM_NLEV=${PAM_NLEV} \
-DSCREAM_CXX_LIBS_DIR=${SCREAM_CXX_LIBS_DIR} \
Expand Down
14 changes: 9 additions & 5 deletions standalone/mmf_simplified/driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <chrono>
#include "scream_cxx_interface_finalize.h"
#include "pamc_init.h"
#include "les_smag.h"

void initialize_from_supercell_column(real1d zint_in, pam::PamCoupler &coupler) {
int crm_nz = coupler.get_nz();
Expand Down Expand Up @@ -182,12 +183,14 @@ int main(int argc, char** argv) {

// NORMALLY THIS WOULD BE DONE INSIDE THE CRM, BUT WE'RE USING CONSTANTS DEFINED BY THE CRM MICRO SCHEME
// Create the dycore and the microphysics
Dycore dycore;
Microphysics micro;
SGS sgs;
Dycore dycore;
Microphysics micro;
SGS sgs;
modules::LES_Closure smag;

micro .init( coupler );
sgs .init( coupler );
smag .init( coupler );
dycore.init( coupler, verbose);

#ifdef P3_CXX
Expand Down Expand Up @@ -243,14 +246,15 @@ int main(int argc, char** argv) {
for (int step_crm_phys = 0; step_crm_phys < nsteps_crm_phys; ++step_crm_phys) {

if (apply_gcm_forcing) {
coupler.run_module( "apply_gcm_forcing_tendencies" , modules::apply_gcm_forcing_tendencies );
coupler.run_module( "apply_gcm_forcing_tendencies" , modules::apply_gcm_forcing_tendencies );
}
coupler.run_module( "dycore" , [&] (pam::PamCoupler &coupler) { dycore.timeStep(coupler); } );
if (apply_sponge) {
coupler.run_module( "sponge_layer" , modules::sponge_layer );
coupler.run_module( "sponge_layer" , modules::sponge_layer );
}
coupler.run_module( "sgs" , [&] (pam::PamCoupler &coupler) { sgs .timeStep(coupler); } );
coupler.run_module( "micro" , [&] (pam::PamCoupler &coupler) { micro .timeStep(coupler); } );
coupler.run_module( "les_smag" , [&] (pam::PamCoupler &coupler) { smag .apply (coupler); } );

etime_gcm = step_gcm * dt_gcm + (step_crm_phys + 1) * dt_crm_phys;

Expand Down
2 changes: 1 addition & 1 deletion standalone/mmf_simplified/inputs/input_pama.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
sim_time : 86400

# Number of cells to use in the CRMs
crm_nx : 250
crm_nx : 64
crm_ny : 1

# Number of CRMs
Expand Down

0 comments on commit 9ba849a

Please sign in to comment.