Skip to content

Commit

Permalink
Adds linoz src sink function and namelist variables plus code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
singhbalwinder committed Oct 12, 2024
1 parent 04132e8 commit dac5eb8
Show file tree
Hide file tree
Showing 8 changed files with 361 additions and 329 deletions.
18 changes: 14 additions & 4 deletions components/eamxx/cime_config/namelist_defaults_scream.xml
Original file line number Diff line number Diff line change
Expand Up @@ -252,18 +252,28 @@ be lost if SCREAM_HACK_XML is not enabled.

<!-- MAM4xx-Aerosol-Microphysics -->
<mam4_aero_microphys inherit="atm_proc_base">
<!--Aerosol Microphysics processes on/off switches -->
<mam4_do_cond type="logical" doc="">true</mam4_do_cond>
<mam4_do_newnuc type="logical" doc="">true</mam4_do_newnuc>
<mam4_do_coag type="logical" doc="">true</mam4_do_coag>
<mam4_do_rename type="logical" doc="">true</mam4_do_rename>
<!-- LINOZ parameters -->
<mam4_o3_tau type="real" doc="">172800.0</mam4_o3_tau>
<mam4_o3_sfc type="real" doc="">3.0E-008</mam4_o3_sfc>
<mam4_o3_lbl type="integer" doc="">4</mam4_o3_lbl>
<mam4_linoz_ymd type="integer" > 20100101</mam4_linoz_ymd>
<mam4_linoz_file_name type="file" doc=""> ${DIN_LOC_ROOT}/atm/scream/mam4xx/linoz/ne30pg2/linoz1850-2015_2010JPL_CMIP6_10deg_58km_ne30pg2_c20240724.nc</mam4_linoz_file_name>
<mam4_linoz_file_name hgrid="ne4np4.pg2" type="file" doc=""> ${DIN_LOC_ROOT}/atm/scream/mam4xx/linoz/ne4pg2/linoz1850-2015_2010JPL_CMIP6_10deg_58km_ne4pg2_c20240724.nc</mam4_linoz_file_name>
<mam4_linoz_file_name type="file" doc=""> ${DIN_LOC_ROOT}/atm/scream/mam4xx/linoz/ne30pg2/linoz1850-2015_2010JPL_CMIP6_10deg_58km_ne30pg2_c20240724.nc</mam4_linoz_file_name>
<!--Invariants-->
<mam4_oxid_ymd type="integer" > 20150101 </mam4_oxid_ymd>
<mam4_oxid_file_name type="file" doc="">${DIN_LOC_ROOT}/atm/scream/mam4xx/invariants/ne30pg2/oxid_1.9x2.5_L26_1850-2015_ne30pg2_c20241009.nc</mam4_oxid_file_name>
<mam4_oxid_file_name hgrid="ne4np4.pg2" type="file" doc="">${DIN_LOC_ROOT}/atm/scream/mam4xx/invariants/ne4pg2/oxid_1.9x2.5_L26_1850-2015_ne4pg2_c20241009.nc</mam4_oxid_file_name>

<mam4_oxid_file_name type="file" doc="">${DIN_LOC_ROOT}/atm/scream/mam4xx/invariants/ne30pg2/oxid_1.9x2.5_L26_1850-2015_ne30pg2_c20241009.nc</mam4_oxid_file_name>
<mam4_chlorine_loading_ymd type="integer" doc=""> 20100101 </mam4_chlorine_loading_ymd>
<mam4_linoz_chlorine_file type="file" doc=""> ${DIN_LOC_ROOT}/atm/scream/mam4xx/linoz/Linoz_Chlorine_Loading_CMIP6_0003-2017_c20171114.nc</mam4_linoz_chlorine_file>
<!--Photolysis-->
<mam4_rsf_file type="file" doc=""> ${DIN_LOC_ROOT}/atm/scream/mam4xx/photolysis/RSF_GT200nm_v3.0_c080811.nc</mam4_rsf_file>
<mam4_xs_long_file type="file" doc=""> ${DIN_LOC_ROOT}/atm/scream/mam4xx/photolysis/temp_prs_GT200nm_JPL10_c130206.nc</mam4_xs_long_file>

<!--Vertical emissions-->
<verti_emiss_ymd type="integer"> 20100101 </verti_emiss_ymd>
<!-- For all other grids -->
<mam4_so2_verti_emiss_file_name type="file" doc="">${DIN_LOC_ROOT}/atm/scream/mam4xx/emissions/ne30pg2/elevated/cmip6_mam4_so2_elev_1x1_2010_clim_ne30pg2_c20241008.nc </mam4_so2_verti_emiss_file_name>
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@ class MAMMicrophysics final : public scream::AtmosphereProcess {
// The name of the subcomponent
std::string name() const { return "mam_aero_microphysics"; }

// set aerosol microphysics configuration parameters (called by constructor)
void configure(const ekat::ParameterList &params);

// grid
void set_grids(
const std::shared_ptr<const GridsManager> grids_manager) override;
Expand All @@ -68,13 +65,14 @@ class MAMMicrophysics final : public scream::AtmosphereProcess {
// Finalize
void finalize_impl(){/*Do nothing*/};

// performs some checks on the tracers group
void set_computed_group_impl(const FieldGroup &group) override;

private:
// number of horizontal columns and vertical levels
int ncol_, nlev_;

// Namelist for LINOZ
int o3_lbl_;
Real o3_tau_, o3_sfc_;

// The orbital year, used for zenith angle calculations:
// If > 0, use constant orbital year for duration of simulation
// If < 0, use year from timestamp for orbital parameters
Expand Down Expand Up @@ -228,7 +226,7 @@ class MAMMicrophysics final : public scream::AtmosphereProcess {
std::shared_ptr<const AbstractGrid> grid_;

// sets defaults for "namelist parameters"
void set_defaults_();
void set_namelist_params_();

mam_coupling::TracerTimeState linoz_time_state_;
view_2d work_photo_table_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ void compute_o3_column_density(
// NOTE: if we need o2 column densities, set_ub_col and setcol must be changed
Kokkos::parallel_for(
Kokkos::TeamThreadRange(team, mam4::nlev), [&](const int k) {
Real pdel = atm.hydrostatic_dp(k);
const Real pdel = atm.hydrostatic_dp(k);
// extract aerosol state variables into "working arrays" (mass
// mixing ratios) (in EAM, this is done in the gas_phase_chemdr
// subroutine defined within
Expand All @@ -41,11 +41,12 @@ void compute_o3_column_density(
invariants_k[i] = invariants(k, i);
}
// compute the change in o3 density for this column above its neighbor
mam4::mo_photo::set_ub_col(o3_col_deltas[k + 1], vmr, invariants_k,
pdel);
mam4::mo_photo::set_ub_col(o3_col_deltas[k + 1], // out
vmr, invariants_k, pdel); // out
});
// sum the o3 column deltas to densities
mam4::mo_photo::setcol(o3_col_deltas, o3_col_dens);
mam4::mo_photo::setcol(o3_col_deltas, // in
o3_col_dens); // out
}

} // namespace scream::impl
7 changes: 4 additions & 3 deletions components/eamxx/src/physics/mam/impl/gas_phase_chemistry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,10 @@ void gas_phase_chemistry(

// solve chemical system implicitly
Real prod_out[clscnt4], loss_out[clscnt4];
mam4::gas_chemistry::imp_sol(qq, reaction_rates, het_rates, extfrc_rates, dt,
permute_4, clsmap_4, factor, epsilon, prod_out,
loss_out);
mam4::gas_chemistry::imp_sol(qq, // out
reaction_rates, het_rates, extfrc_rates, // in
dt, permute_4, clsmap_4, factor, // in
epsilon, prod_out, loss_out); // out

// save h2so4 change by gas phase chem (for later new particle nucleation)
if(ndx_h2so4 > 0) {
Expand Down
42 changes: 24 additions & 18 deletions components/eamxx/src/physics/mam/impl/helper_micro.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -395,15 +395,19 @@ inline std::shared_ptr<AbstractRemapper> create_horiz_remapper(
horiz_interp_tgt_grid, IdentityRemapper::SrcAliasTgt);
} else {
EKAT_REQUIRE_MSG(tracer_data.ncols_data <= ncols_model,
"Error! We do not allow to coarsen spa data to fit the "
"Error! We do not allow to coarsen tracer external "
"forcing data to fit the "
"model. We only allow\n"
" spa data to be at the same or coarser resolution "
" tracer external forcing data to be at the same or "
"coarser resolution "
"as the model.\n");
// We must have a valid map file
EKAT_REQUIRE_MSG(
map_file != "",
"ERROR: Spa data is on a different grid than the model one,\n"
" but spa_remap_file is missing from SPA parameter list.");
"ERROR: tracer external forcing data is on a different grid than the "
"model one,\n"
" but tracer external forcing data remap file is missing from "
"tracer external forcing data parameter list.");

remapper =
std::make_shared<RefiningRemapperP2P>(horiz_interp_tgt_grid, map_file);
Expand Down Expand Up @@ -447,13 +451,13 @@ inline std::shared_ptr<AtmosphereInput> create_tracer_data_reader(
} // create_tracer_data_reader

inline void update_tracer_data_from_file(
std::shared_ptr<AtmosphereInput> &scorpio_reader,
const std::shared_ptr<AtmosphereInput> &scorpio_reader,
const int time_index, // zero-based
AbstractRemapper &tracer_horiz_interp, TracerData &tracer_data) {
// 1. read from field
scorpio_reader->read_variables(time_index);
// 2. Run the horiz remapper (it is a do-nothing op if spa data is on same
// grid as model)
// 2. Run the horiz remapper (it is a do-nothing op if tracer external forcing
// data is on same grid as model)
tracer_horiz_interp.remap(/*forward = */ true);
//
const int nvars = tracer_data.nvars_;
Expand All @@ -472,19 +476,20 @@ inline void update_tracer_data_from_file(

} // update_tracer_data_from_file
inline void update_tracer_timestate(
std::shared_ptr<AtmosphereInput> &scorpio_reader, const util::TimeStamp &ts,
AbstractRemapper &tracer_horiz_interp, TracerTimeState &time_state,
TracerData &data_tracer) {
const std::shared_ptr<AtmosphereInput> &scorpio_reader,
const util::TimeStamp &ts, AbstractRemapper &tracer_horiz_interp,
TracerTimeState &time_state, TracerData &data_tracer) {
// Now we check if we have to update the data that changes monthly
// NOTE: This means that SPA assumes monthly data to update. Not
// NOTE: This means that tracer external forcing assumes monthly data to
// update. Not
// any other frequency.
const auto month = ts.get_month() - 1; // Make it 0-based
if(month != time_state.current_month) {
const auto tracer_data = data_tracer.data;
const int nvars = data_tracer.nvars_;
const auto ps = data_tracer.ps;

// Update the SPA time state information
// Update the tracer external forcing time state information
time_state.current_month = month;
time_state.t_beg_month =
util::TimeStamp({ts.get_year(), month + 1, 1}, {0, 0, 0})
Expand All @@ -505,7 +510,7 @@ inline void update_tracer_timestate(
// Assume the data is saved monthly and cycles in one year
// Add offset_time_index to support cases where data is saved
// from other periods of time.
// Update the SPA forcing data for this month and next month
// Update the tracer external forcing data for this month and next month
// Start by copying next months data to this months data structure.
// NOTE: If the timestep is bigger than monthly this could cause the wrong
// values
Expand Down Expand Up @@ -685,11 +690,12 @@ inline void perform_vertical_interpolation(const const_view_1d &altitude_int,
}

inline void advance_tracer_data(
std::shared_ptr<AtmosphereInput> &scorpio_reader,
AbstractRemapper &tracer_horiz_interp, const util::TimeStamp &ts,
TracerTimeState &time_state, TracerData &data_tracer,
const const_view_2d &p_tgt, const const_view_2d &zi_tgt,
const view_2d output[]) {
const std::shared_ptr<AtmosphereInput> &scorpio_reader, // in
AbstractRemapper &tracer_horiz_interp, // out
const util::TimeStamp &ts, // in
TracerTimeState &time_state, TracerData &data_tracer, // out
const const_view_2d &p_tgt, const const_view_2d &zi_tgt, // in
const view_2d output[]) { // out
/* Update the TracerTimeState to reflect the current time, note the addition
* of dt */
time_state.t_now = ts.frac_of_year_in_days();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ time_stepping:

atmosphere_processes:
atm_procs_list: [mam4_aero_microphys]
mam4_aero_microphys:
mam4_do_cond: true
mam4_do_newnuc: true
mam4_do_coag: true
mam4_do_rename: true
mam4_o3_tau: 172800.0
mam4_o3_sfc: 3.0E-008
mam4_o3_lbl: 4

mam4_aero_microphys:
mam4_linoz_ymd : 20100101
mam4_linoz_file_name : ${SCREAM_DATA_DIR}/mam4xx/linoz/ne2np4/linoz1850-2015_2010JPL_CMIP6_10deg_58km_ne2np4_c20240724.nc
Expand Down Expand Up @@ -46,10 +55,10 @@ initial_conditions:
topography_filename: ${TOPO_DATA_DIR}/${EAMxx_tests_TOPO_FILE}
phis : 1.0
pbl_height: 1.0
dgnum : [1.37146e-07 ,3.45899e-08 ,1.00000e-06 ,9.99601e-08]
dgnumwet : [1.37452e-07 ,3.46684e-08 ,1.00900e-06 ,9.99601e-08]
wetdens : [5.08262e-12 ,1.54035e-13 ,3.09018e-13 ,9.14710e-22]
#These should come from the input file
dgnum: [1.246662106183775E-007, 4.081134799487888E-008, 1.103139143795796E-006, 1.000000011686097E-007]
dgnumwet: [2.367209731605067E-007, 6.780643470563889E-008, 3.028011448344027E-006, 1.000000096285154E-007]
wetdens: [1038.67760516297, 1046.20002003441, 1031.74623165457, 1086.79731859184]

# The parameters for I/O control
Scorpio:
Expand Down
2 changes: 1 addition & 1 deletion externals/mam4xx

0 comments on commit dac5eb8

Please sign in to comment.