Skip to content

Commit 6d8919a

Browse files
committed
EAMxx: Fixing after rebasing against master.
1 parent 8ee3ba8 commit 6d8919a

File tree

1 file changed

+40
-56
lines changed

1 file changed

+40
-56
lines changed

components/eamxx/src/physics/mam/eamxx_mam_microphysics_process_interface.cpp

Lines changed: 40 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -236,28 +236,19 @@ void MAMMicrophysics::set_grids(
236236
add_field<Computed>("mam4_microphysics_tendency_renaming_cloud_borne", vector3d_num_gas_aerosol_constituents, nondim, grid_name);
237237
}
238238

239-
<<<<<<< HEAD
240239
// Creating a Linoz reader and setting Linoz parameters involves reading data
241240
// from a file and configuring the necessary parameters for the Linoz model.
242-
#ifdef USE_OLD_LINOZ_FILE_READ
243-
if (config_.linoz.compute) {
244241

245-
=======
246-
>>>>>>> b16a6664e4 (EAMxx: Fixing variable names and add comments.)
247-
// NOTE: order matches mam4xx:
248-
// names of variables in oxid file.
249-
var_names_oxi_={"O3", "OH", "NO3", "HO2"};
250242
// names of variables for linoz
251-
var_names_linoz_ = {
243+
if (config_.linoz.compute) {
244+
var_names_linoz_ = {
252245
"o3_clim", "o3col_clim", "t_clim", "PmL_clim",
253246
"dPmL_dO3", "dPmL_dT", "dPmL_dO3col", "cariolle_pscs"};
254-
<<<<<<< HEAD
255-
std::cout << "Using former reader..." << "\n";
256-
=======
257-
247+
}
258248
#ifdef USE_OLD_LINOZ_FILE_READ
259-
{
260-
>>>>>>> b16a6664e4 (EAMxx: Fixing variable names and add comments.)
249+
if (config_.linoz.compute) {
250+
251+
std::cout << "Using former reader..." << "\n";
261252
linoz_file_name_ = m_params.get<std::string>("mam4_linoz_file_name");
262253
const std::string linoz_map_file =
263254
m_params.get<std::string>("aero_microphys_remap_file", "");
@@ -281,7 +272,9 @@ void MAMMicrophysics::set_grids(
281272
linoz_data_.init(num_cols_io_linoz, num_levs_io_linoz, nvars);
282273
linoz_data_.allocate_temporary_views();
283274
} // LINOZ reader
284-
275+
// NOTE: order matches mam4xx:
276+
// names of variables in oxid file.
277+
var_names_oxi_={"O3", "OH", "NO3", "HO2"};
285278
{
286279
oxid_file_name_ = m_params.get<std::string>("mam4_oxid_file_name");
287280
const std::string oxid_map_file =
@@ -311,9 +304,11 @@ void MAMMicrophysics::set_grids(
311304
} // oxid file reader
312305

313306
#else
314-
// The DataInterpolation class uses Field. We save these fields in FM.
315-
for(const auto &field_name : var_names_linoz_) {
307+
if (config_.linoz.compute) {
308+
// The DataInterpolation class uses Field. We save these fields in FM.
309+
for(const auto &field_name : var_names_linoz_) {
316310
add_field<Computed>(field_name, scalar3d_mid, nondim, grid_name);
311+
}
317312
}
318313
for(const auto &field_name : var_names_oxi_) {
319314
add_field<Computed>(field_name, scalar3d_mid, nondim, grid_name);
@@ -735,7 +730,7 @@ void MAMMicrophysics::initialize_impl(const RunType run_type) {
735730
add_postcondition_check<Interval>(get_field_out("cldfrac_liq"),m_grid,0.0,1.0,false);
736731
add_postcondition_check<LowerBound>(get_field_out("tke"),m_grid,0);
737732
*/
738-
733+
#ifdef USE_OLD_LINOZ_FILE_READ
739734
if (config_.linoz.compute) {
740735
// climatology data for linear stratospheric chemistry
741736
auto linoz_o3_clim = buffer_.scratch[0]; // ozone (climatology) [vmr]
@@ -753,7 +748,7 @@ void MAMMicrophysics::initialize_impl(const RunType run_type) {
753748
// overhead O3 column [vmr/DU]
754749
auto linoz_cariolle_pscs =
755750
buffer_.scratch[7]; // Cariolle parameter for PSC loss of ozone [1/s]
756-
#endif
751+
757752
auto ts = start_of_step_ts();
758753
std::string linoz_chlorine_file =
759754
m_params.get<std::string>("mam4_linoz_chlorine_file");
@@ -762,7 +757,7 @@ void MAMMicrophysics::initialize_impl(const RunType run_type) {
762757
linoz_chlorine_file, ts, chlorine_loading_ymd, chlorine_values_,
763758
chlorine_time_secs_);
764759
}
765-
760+
#endif
766761
init_temporary_views();
767762
// FIXME : why are we only using nlev_ instead of ncol_xnlev?
768763
cmfdqr_ = view_1d("cmfdqr_", nlev_);
@@ -779,7 +774,9 @@ void MAMMicrophysics::initialize_impl(const RunType run_type) {
779774
TracerDataReader_, curr_month, *TracerHorizInterp_, tracer_data_);
780775
#else
781776
set_oxid_reader();
782-
set_linoz_reader();
777+
if (config_.linoz.compute) {
778+
set_linoz_reader();
779+
}
783780
#endif
784781

785782
#ifdef USE_OLD_VERTICAL_FILE_READ
@@ -915,8 +912,8 @@ void MAMMicrophysics::run_impl(const double dt) {
915912
}
916913

917914

918-
view_2d linoz_output[8];
919-
if (config_.linoz.compute) {
915+
916+
#ifdef USE_OLD_LINOZ_FILE_READ
920917
// climatology data for linear stratospheric chemistry
921918
// ozone (climatology) [vmr]
922919
view_2d linoz_o3_clim;
@@ -934,39 +931,20 @@ void MAMMicrophysics::run_impl(const double dt) {
934931
view_2d linoz_dPmL_dO3col;
935932
// Cariolle parameter for PSC loss of ozone [1/s]
936933
view_2d linoz_cariolle_pscs;
937-
938-
939-
linoz_output[0] = linoz_o3_clim;
940-
linoz_output[1] = linoz_o3col_clim;
941-
linoz_output[2] = linoz_t_clim;
942-
linoz_output[3] = linoz_PmL_clim;
943-
linoz_output[4] = linoz_dPmL_dO3;
944-
linoz_output[5] = linoz_dPmL_dT;
945-
linoz_output[6] = linoz_dPmL_dO3col;
946-
linoz_output[7] = linoz_cariolle_pscs;
947-
}
948934
#else
949-
//FIXME: I will need to modify perform_atmospheric_chemistry_and_microphysics in MAM4xx.
950-
// Let's do that after we have tested the new interface for DataInterpolation.
951-
// const auto linoz_o3_clim = get_field_in("o3_clim").get_view<const Real **>();
952-
// const auto linoz_o3col_clim = get_field_in("o3col_clim").get_view<const Real **>();
953-
// const auto linoz_t_clim = get_field_in("t_clim").get_view<const Real **>();
954-
// const auto linoz_PmL_clim = get_field_in("PmL_clim").get_view<const Real **>();
955-
// const auto linoz_dPmL_dO3 = get_field_in("dPmL_dO3").get_view<const Real **>();
956-
// const auto linoz_dPmL_dT = get_field_in("dPmL_dT").get_view<const Real **>();
957-
// const auto linoz_dPmL_dO3col = get_field_in("dPmL_dO3col").get_view<const Real **>();
958-
// const auto linoz_cariolle_pscs = get_field_in("cariolle_pscs").get_view<const Real **>();
959935
data_interp_oxid_->run(end_of_step_ts());
960-
data_interp_linoz_->run(end_of_step_ts());
961936

962-
const auto linoz_o3_clim = get_field_out("o3_clim").get_view<Real **>();
963-
const auto linoz_o3col_clim = get_field_out("o3col_clim").get_view<Real **>();
964-
const auto linoz_t_clim = get_field_out("t_clim").get_view<Real **>();
965-
const auto linoz_PmL_clim = get_field_out("PmL_clim").get_view<Real **>();
966-
const auto linoz_dPmL_dO3 = get_field_out("dPmL_dO3").get_view<Real **>();
967-
const auto linoz_dPmL_dT = get_field_out("dPmL_dT").get_view<Real **>();
968-
const auto linoz_dPmL_dO3col = get_field_out("dPmL_dO3col").get_view<Real **>();
969-
const auto linoz_cariolle_pscs = get_field_out("cariolle_pscs").get_view<Real **>();
937+
if (config_.linoz.compute) {
938+
data_interp_linoz_->run(end_of_step_ts());
939+
linoz_o3_clim = get_field_out("o3_clim").get_view<Real **>();
940+
linoz_o3col_clim = get_field_out("o3col_clim").get_view<Real **>();
941+
linoz_t_clim = get_field_out("t_clim").get_view<Real **>();
942+
linoz_PmL_clim = get_field_out("PmL_clim").get_view<Real **>();
943+
linoz_dPmL_dO3 = get_field_out("dPmL_dO3").get_view<Real **>();
944+
linoz_dPmL_dT = get_field_out("dPmL_dT").get_view<Real **>();
945+
linoz_dPmL_dO3col = get_field_out("dPmL_dO3col").get_view<Real **>();
946+
linoz_cariolle_pscs = get_field_out("cariolle_pscs").get_view<Real **>();
947+
}
970948

971949
const auto oxid_O3 = get_field_out("O3").get_view<Real **>();
972950
const auto oxid_OH = get_field_out("OH").get_view<Real **>();
@@ -988,6 +966,7 @@ void MAMMicrophysics::run_impl(const double dt) {
988966
}
989967

990968
#ifdef USE_OLD_LINOZ_FILE_READ
969+
const auto &cnst_offline = cnst_offline_;
991970
// Update the TracerTimeState to reflect the current time
992971
trace_time_state_.t_now = ts.frac_of_year_in_days();
993972
scream::mam_coupling::advance_tracer_data(
@@ -998,7 +977,6 @@ void MAMMicrophysics::run_impl(const double dt) {
998977
dry_atm_.p_mid, dry_atm_.z_iface, // in
999978
cnst_offline_); // out
1000979
Kokkos::fence();
1001-
const auto &cnst_offline = cnst_offline_;
1002980

1003981
if (config_.linoz.compute) {
1004982
view_2d linoz_output[8];
@@ -1010,7 +988,6 @@ void MAMMicrophysics::run_impl(const double dt) {
1010988
linoz_output[5] = linoz_dPmL_dT;
1011989
linoz_output[6] = linoz_dPmL_dO3col;
1012990
linoz_output[7] = linoz_cariolle_pscs;
1013-
1014991
scream::mam_coupling::advance_tracer_data(
1015992
LinozDataReader_, // in
1016993
*LinozHorizInterp_, // out
@@ -1021,6 +998,7 @@ void MAMMicrophysics::run_impl(const double dt) {
1021998
Kokkos::fence();
1022999
}
10231000
#endif
1001+
10241002
#ifdef USE_OLD_VERTICAL_FILE_READ
10251003
int i = 0;
10261004
for(const auto &var_name : extfrc_lst_) {
@@ -1188,6 +1166,12 @@ void MAMMicrophysics::run_impl(const double dt) {
11881166
for(int i = 0; i < mam4::mo_setinv::num_tracer_cnst; ++i) {
11891167
cnst_offline_icol[i] = ekat::subview(cnst_offline[i], icol);
11901168
}
1169+
#else
1170+
cnst_offline_icol[0] = ekat::subview(oxid_O3, icol);;
1171+
cnst_offline_icol[1] = ekat::subview(oxid_OH, icol);;
1172+
cnst_offline_icol[2] = ekat::subview(oxid_NO3, icol);;
1173+
cnst_offline_icol[3] = ekat::subview(oxid_HO2, icol);;
1174+
#endif
11911175
// calculate o3 column densities (first component of col_dens in Fortran
11921176
// code)
11931177
auto o3_col_dens_i = ekat::subview(o3_col_dens, icol);

0 commit comments

Comments
 (0)