Skip to content

Commit 913e47c

Browse files
committed
EAMxx: Fixing after rebasing against master.
EAMxx: Fixing failing tests.
1 parent b9e2717 commit 913e47c

File tree

1 file changed

+49
-71
lines changed

1 file changed

+49
-71
lines changed

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

Lines changed: 49 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -238,28 +238,22 @@ void MAMMicrophysics::set_grids(
238238
add_field<Computed>("mam4_microphysics_tendency_renaming_cloud_borne", vector3d_num_gas_aerosol_constituents, nondim, grid_name);
239239
}
240240

241-
<<<<<<< HEAD
242241
// Creating a Linoz reader and setting Linoz parameters involves reading data
243242
// from a file and configuring the necessary parameters for the Linoz model.
244-
#ifdef USE_OLD_LINOZ_FILE_READ
245-
if (config_.linoz.compute) {
246243

247-
=======
248-
>>>>>>> b16a6664e4 (EAMxx: Fixing variable names and add comments.)
249-
// NOTE: order matches mam4xx:
250-
// names of variables in oxid file.
251-
var_names_oxi_={"O3", "OH", "NO3", "HO2"};
252244
// names of variables for linoz
253-
var_names_linoz_ = {
245+
if (config_.linoz.compute) {
246+
var_names_linoz_ = {
254247
"o3_clim", "o3col_clim", "t_clim", "PmL_clim",
255248
"dPmL_dO3", "dPmL_dT", "dPmL_dO3col", "cariolle_pscs"};
256-
<<<<<<< HEAD
257-
std::cout << "Using former reader..." << "\n";
258-
=======
259-
249+
}
250+
// NOTE: order matches mam4xx:
251+
// names of variables in oxid file.
252+
var_names_oxi_={"O3", "OH", "NO3", "HO2"};
260253
#ifdef USE_OLD_LINOZ_FILE_READ
261-
{
262-
>>>>>>> b16a6664e4 (EAMxx: Fixing variable names and add comments.)
254+
if (config_.linoz.compute) {
255+
256+
std::cout << "Using former reader..." << "\n";
263257
linoz_file_name_ = m_params.get<std::string>("mam4_linoz_file_name");
264258
const std::string linoz_map_file =
265259
m_params.get<std::string>("aero_microphys_remap_file", "");
@@ -283,7 +277,6 @@ void MAMMicrophysics::set_grids(
283277
linoz_data_.init(num_cols_io_linoz, num_levs_io_linoz, nvars);
284278
linoz_data_.allocate_temporary_views();
285279
} // LINOZ reader
286-
287280
{
288281
oxid_file_name_ = m_params.get<std::string>("mam4_oxid_file_name");
289282
const std::string oxid_map_file =
@@ -313,9 +306,11 @@ void MAMMicrophysics::set_grids(
313306
} // oxid file reader
314307

315308
#else
316-
// The DataInterpolation class uses Field. We save these fields in FM.
317-
for(const auto &field_name : var_names_linoz_) {
309+
if (config_.linoz.compute) {
310+
// The DataInterpolation class uses Field. We save these fields in FM.
311+
for(const auto &field_name : var_names_linoz_) {
318312
add_field<Computed>(field_name, scalar3d_mid, nondim, grid_name);
313+
}
319314
}
320315
for(const auto &field_name : var_names_oxi_) {
321316
add_field<Computed>(field_name, scalar3d_mid, nondim, grid_name);
@@ -544,7 +539,7 @@ void MAMMicrophysics::set_oxid_reader()
544539
VerticalRemapperMAM4::VertRemapType::MAM4_PSRef);
545540
remap_data_oxid.custom_remapper=vertical_remapper;
546541
}
547-
data_interp_oxid_->create_vert_remapper (remap_data);
542+
data_interp_oxid_->create_vert_remapper (remap_data_oxid);
548543
data_interp_oxid_->init_data_interval (start_of_step_ts());
549544
}
550545
// set DataInterpolation object for linoz reader.
@@ -738,23 +733,7 @@ void MAMMicrophysics::initialize_impl(const RunType run_type) {
738733
*/
739734

740735
if (config_.linoz.compute) {
741-
// climatology data for linear stratospheric chemistry
742-
auto linoz_o3_clim = buffer_.scratch[0]; // ozone (climatology) [vmr]
743-
auto linoz_o3col_clim =
744-
buffer_.scratch[1]; // column o3 above box (climatology) [Dobson Units
745-
// (DU)]
746-
auto linoz_t_clim = buffer_.scratch[2]; // temperature (climatology) [K]
747-
auto linoz_PmL_clim =
748-
buffer_.scratch[3]; // P minus L (climatology) [vmr/s]
749-
auto linoz_dPmL_dO3 =
750-
buffer_.scratch[4]; // sensitivity of P minus L to O3 [1/s]
751-
auto linoz_dPmL_dT =
752-
buffer_.scratch[5]; // sensitivity of P minus L to T3 [K]
753-
auto linoz_dPmL_dO3col = buffer_.scratch[6]; // sensitivity of P minus L to
754-
// overhead O3 column [vmr/DU]
755-
auto linoz_cariolle_pscs =
756-
buffer_.scratch[7]; // Cariolle parameter for PSC loss of ozone [1/s]
757-
#endif
736+
// // climatology data for linear stratospheric chemistry
758737
auto ts = start_of_step_ts();
759738
std::string linoz_chlorine_file =
760739
m_params.get<std::string>("mam4_linoz_chlorine_file");
@@ -763,7 +742,6 @@ void MAMMicrophysics::initialize_impl(const RunType run_type) {
763742
linoz_chlorine_file, ts, chlorine_loading_ymd, chlorine_values_,
764743
chlorine_time_secs_);
765744
}
766-
767745
init_temporary_views();
768746
// FIXME : why are we only using nlev_ instead of ncol_xnlev?
769747
cmfdqr_ = view_1d("cmfdqr_", nlev_);
@@ -780,7 +758,9 @@ void MAMMicrophysics::initialize_impl(const RunType run_type) {
780758
TracerDataReader_, curr_month, *TracerHorizInterp_, tracer_data_);
781759
#else
782760
set_oxid_reader();
783-
set_linoz_reader();
761+
if (config_.linoz.compute) {
762+
set_linoz_reader();
763+
}
784764
#endif
785765

786766
#ifdef USE_OLD_VERTICAL_FILE_READ
@@ -914,9 +894,6 @@ void MAMMicrophysics::run_impl(const double dt) {
914894
gas_aero_exchange_renaming_cloud_borne = get_field_out("mam4_microphysics_tendency_renaming_cloud_borne").get_view<Real***>();
915895
}
916896

917-
918-
view_2d linoz_output[8];
919-
if (config_.linoz.compute) {
920897
// climatology data for linear stratospheric chemistry
921898
// ozone (climatology) [vmr]
922899
view_2d linoz_o3_clim;
@@ -935,38 +912,33 @@ void MAMMicrophysics::run_impl(const double dt) {
935912
// Cariolle parameter for PSC loss of ozone [1/s]
936913
view_2d linoz_cariolle_pscs;
937914

915+
#ifdef USE_OLD_LINOZ_FILE_READ
916+
917+
linoz_o3_clim = buffer_.scratch[0]; // ozone (climatology) [vmr]
918+
linoz_o3col_clim = buffer_.scratch[1]; // column o3 above box (climatology) [Dobson Units
919+
// // (DU)]
920+
linoz_t_clim = buffer_.scratch[2]; // temperature (climatology) [K]
921+
linoz_PmL_clim = buffer_.scratch[3]; // P minus L (climatology) [vmr/s]
922+
linoz_dPmL_dO3 = buffer_.scratch[4]; // sensitivity of P minus L to O3 [1/s]
923+
linoz_dPmL_dT = buffer_.scratch[5]; // sensitivity of P minus L to T3 [K]
924+
linoz_dPmL_dO3col = buffer_.scratch[6]; // sensitivity of P minus L to
925+
// // overhead O3 column [vmr/DU]
926+
linoz_cariolle_pscs = buffer_.scratch[7]; // Cariolle parameter for PSC loss of ozone [1/s]
938927

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-
}
948928
#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 **>();
959929
data_interp_oxid_->run(end_of_step_ts());
960-
data_interp_linoz_->run(end_of_step_ts());
961930

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 **>();
931+
if (config_.linoz.compute) {
932+
data_interp_linoz_->run(end_of_step_ts());
933+
linoz_o3_clim = get_field_out("o3_clim").get_view<Real **>();
934+
linoz_o3col_clim = get_field_out("o3col_clim").get_view<Real **>();
935+
linoz_t_clim = get_field_out("t_clim").get_view<Real **>();
936+
linoz_PmL_clim = get_field_out("PmL_clim").get_view<Real **>();
937+
linoz_dPmL_dO3 = get_field_out("dPmL_dO3").get_view<Real **>();
938+
linoz_dPmL_dT = get_field_out("dPmL_dT").get_view<Real **>();
939+
linoz_dPmL_dO3col = get_field_out("dPmL_dO3col").get_view<Real **>();
940+
linoz_cariolle_pscs = get_field_out("cariolle_pscs").get_view<Real **>();
941+
}
970942

971943
const auto oxid_O3 = get_field_out("O3").get_view<Real **>();
972944
const auto oxid_OH = get_field_out("OH").get_view<Real **>();
@@ -988,6 +960,7 @@ void MAMMicrophysics::run_impl(const double dt) {
988960
}
989961

990962
#ifdef USE_OLD_LINOZ_FILE_READ
963+
const auto &cnst_offline = cnst_offline_;
991964
// Update the TracerTimeState to reflect the current time
992965
trace_time_state_.t_now = ts.frac_of_year_in_days();
993966
scream::mam_coupling::advance_tracer_data(
@@ -998,7 +971,6 @@ void MAMMicrophysics::run_impl(const double dt) {
998971
dry_atm_.p_mid, dry_atm_.z_iface, // in
999972
cnst_offline_); // out
1000973
Kokkos::fence();
1001-
const auto &cnst_offline = cnst_offline_;
1002974

1003975
if (config_.linoz.compute) {
1004976
view_2d linoz_output[8];
@@ -1010,7 +982,6 @@ void MAMMicrophysics::run_impl(const double dt) {
1010982
linoz_output[5] = linoz_dPmL_dT;
1011983
linoz_output[6] = linoz_dPmL_dO3col;
1012984
linoz_output[7] = linoz_cariolle_pscs;
1013-
1014985
scream::mam_coupling::advance_tracer_data(
1015986
LinozDataReader_, // in
1016987
*LinozHorizInterp_, // out
@@ -1021,6 +992,7 @@ void MAMMicrophysics::run_impl(const double dt) {
1021992
Kokkos::fence();
1022993
}
1023994
#endif
995+
1024996
#ifdef USE_OLD_VERTICAL_FILE_READ
1025997
int i = 0;
1026998
for(const auto &var_name : extfrc_lst_) {
@@ -1188,6 +1160,12 @@ void MAMMicrophysics::run_impl(const double dt) {
11881160
for(int i = 0; i < mam4::mo_setinv::num_tracer_cnst; ++i) {
11891161
cnst_offline_icol[i] = ekat::subview(cnst_offline[i], icol);
11901162
}
1163+
#else
1164+
cnst_offline_icol[0] = ekat::subview(oxid_O3, icol);;
1165+
cnst_offline_icol[1] = ekat::subview(oxid_OH, icol);;
1166+
cnst_offline_icol[2] = ekat::subview(oxid_NO3, icol);;
1167+
cnst_offline_icol[3] = ekat::subview(oxid_HO2, icol);;
1168+
#endif
11911169
// calculate o3 column densities (first component of col_dens in Fortran
11921170
// code)
11931171
auto o3_col_dens_i = ekat::subview(o3_col_dens, icol);

0 commit comments

Comments
 (0)