@@ -200,17 +200,17 @@ void MAMMicrophysics::set_grids(
200
200
201
201
// extents are [ncol, nlev, gas_pcnst, nq<...>]
202
202
FieldLayout tensor3d_gas_tend =
203
- grid_->get_3d_tensor_layout (true , {num_gas_spec_, mam4::microphysics::nqtendaa () },
204
- {" num_gas_spec" , " nqtendaa " });
203
+ grid_->get_3d_tensor_layout (true , {num_gas_spec_, num_gas_tend_ },
204
+ {" num_gas_spec" , " num_gas_tend_ " });
205
205
FieldLayout tensor3d_gas_tend_cw =
206
- grid_->get_3d_tensor_layout (true , {num_gas_spec_, mam4::microphysics::nqqcwtendaa () },
207
- {" num_gas_spec" , " nqqcwtendaa " });
206
+ grid_->get_3d_tensor_layout (true , {num_gas_spec_, num_gas_tend_cw_ },
207
+ {" num_gas_spec" , " num_gas_tend_cw_ " });
208
208
FieldLayout tensor2d_gas_tend =
209
- grid_->get_3d_tensor_layout (true , {num_gas_spec_, mam4::microphysics::nqtendaa () },
210
- {" num_gas_spec" , " nqtendaa " });
209
+ grid_->get_3d_tensor_layout (true , {num_gas_spec_, num_gas_tend_ },
210
+ {" num_gas_spec" , " num_gas_tend_ " });
211
211
FieldLayout tensor2d_gas_tend_cw =
212
- grid_->get_3d_tensor_layout (true , {num_gas_spec_, mam4::microphysics::nqqcwtendaa () },
213
- {" num_gas_spec" , " nqqcwtendaa " });
212
+ grid_->get_3d_tensor_layout (true , {num_gas_spec_, num_gas_tend_cw_ },
213
+ {" num_gas_spec" , " num_gas_tend_cw_ " });
214
214
FieldLayout vector3d_gas_tend = grid_->get_3d_vector_layout (true , num_gas_spec_, " num_gas_spec" );
215
215
216
216
// fields for holding diagnostic quantities relating to gas-species tendencies
@@ -225,16 +225,6 @@ void MAMMicrophysics::set_grids(
225
225
// and finally, the weights used by vert_contraction()
226
226
add_field<Computed>(" wts_gas_spec_tends" , vector3d_gas_tend, nondim, grid_name);
227
227
228
- // ===============================================================================================
229
- // mam::microphysics wants the full column of these tendencies
230
- // TODO: is it better for each column's threadTeam to have its own 3d view,
231
- // or subview into a 4d view that contains all 'ncol' columns of these?
232
- // view_3d qgcm_tendaa("diag_tendency-col", nlev, num_gas_spec_, mam4::microphysics::nqtendaa());
233
- // view_3d qqcwgcm_tendaa("diag_tendency_cw-col", nlev, num_gas_spec_, mam4::microphysics::nqqcwtendaa());
234
- // Kokkos::deep_copy(qgcm_tendaa, 0.0);
235
- // Kokkos::deep_copy(qqcwgcm_tendaa, 0.0);
236
- // ===============================================================================================
237
-
238
228
// Creating a Linoz reader and setting Linoz parameters involves reading data
239
229
// from a file and configuring the necessary parameters for the Linoz model.
240
230
{
@@ -438,6 +428,11 @@ int MAMMicrophysics::get_len_temporary_views() {
438
428
work_len += ncol_ * nlev_ * mam4::gas_chemistry::nfs;
439
429
// extfrc_
440
430
work_len += ncol_ * nlev_ * extcnt_;
431
+ // TODO: DIAGNOSTIC - will eventually be fenced off by a flag
432
+ // gas_spec_tend_col
433
+ work_len += nlev_ * num_gas_spec_ * num_gas_tend_;
434
+ // gas_spec_tend_cw_col
435
+ work_len += nlev_ * num_gas_spec_ * num_gas_tend_cw_;
441
436
return work_len;
442
437
}
443
438
void MAMMicrophysics::init_temporary_views () {
@@ -458,6 +453,11 @@ void MAMMicrophysics::init_temporary_views() {
458
453
work_ptr += ncol_ * nlev_ * mam4::gas_chemistry::nfs;
459
454
extfrc_ = view_3d (work_ptr, ncol_, nlev_, extcnt_);
460
455
work_ptr += ncol_ * nlev_ * extcnt_;
456
+ // TODO: DIAGNOSTIC - will eventually be fenced off by a flag
457
+ gas_spec_tend_col_ = view_3d (work_ptr, nlev_, num_gas_spec_, num_gas_tend_);
458
+ work_ptr += nlev_ * num_gas_spec_ * num_gas_tend_;
459
+ gas_spec_tend_cw_col_ = view_3d (work_ptr, nlev_, num_gas_spec_, num_gas_tend_cw_);
460
+ work_ptr += nlev_ * num_gas_spec_ * num_gas_tend_cw_;
461
461
462
462
// Error check
463
463
// NOTE: workspace_provided can be larger than workspace_used, but let's try
@@ -848,18 +848,17 @@ void MAMMicrophysics::run_impl(const double dt) {
848
848
molar_mass_g_per_mol_tmp[i] = mam4::gas_chemistry::adv_mass[i]; // host-only access
849
849
}
850
850
851
- // these are computed in the column loop and used afterward, so declare here
852
- // TODO: consider enabling/disabling this based on whether output is required--this would
853
- // require another version of perform_atmospheric_chemistry_and_microphysics(), potentially
854
- // templated on the forthcoming diagnostics struct
855
- // nonetheless, skip for now
856
- // Slice into the diagnostic fields to pass a single column to mam4xx::microphysics
851
+ // TODO: DIAGNOSTIC - will eventually be fenced off by a flag
857
852
auto gas_spec_tend = get_field_out (" gas_spec_tendencies" );
853
+ auto gas_spec_tend_v = gas_spec_tend.get_view <Real****>();
858
854
auto gas_spec_tend_cw = get_field_out (" gas_spec_tendencies_cw" );
855
+ auto gas_spec_tend_cw_v = gas_spec_tend_cw.get_view <Real****>();
859
856
auto gas_spec_tend_wts = get_field_out (" wts_gas_spec_tends" );
857
+ auto gas_spec_tend_wts_v = gas_spec_tend_wts.get_view <Real***>();
858
+
860
859
// NOTE: we need to initialize photo_rates_
861
860
Kokkos::deep_copy (photo_rates_, 0.0 );
862
- // loop over atmosphere columns and compute aerosol microphyscs
861
+ // loop over atmosphere columns and compute aerosol microphysics
863
862
Kokkos::parallel_for (
864
863
" MAMMicrophysics::run_impl" , policy,
865
864
KOKKOS_LAMBDA (const ThreadTeam &team) {
@@ -971,14 +970,19 @@ void MAMMicrophysics::run_impl(const double dt) {
971
970
}
972
971
}
973
972
974
- auto gas_spec_tend_V = gas_spec_tend.get_view <Real****>();
975
- auto gas_spec_tend_cw_V = gas_spec_tend_cw.get_view <Real****>();
976
- auto gas_spec_tend_wts_V = gas_spec_tend_wts.get_view <Real***>();
977
- // NOTE: these are called "qgcm_tendaa" and "qqcwgcm_tendaa" in mam4xx
978
- auto gas_spec_tend_col = ekat::subview (gas_spec_tend_V, icol);
979
- auto gas_spec_tend_cw_col = ekat::subview (gas_spec_tend_cw_V, icol);
973
+ // NOTE: we use these temporary views so that we can pass a column-view
974
+ // the way mam4xx expects it--the level index in the final dimension.
975
+ // This also means that mam4xx can subview into it by level and keep it
976
+ // layout-right
977
+ // TODO: DIAGNOSTIC - will eventually be fenced off by a flag
978
+ const auto &gas_spec_tend_col = gas_spec_tend_col_;
979
+ const auto &gas_spec_tend_cw_col = gas_spec_tend_cw_col_;
980
980
981
981
// These output values need to be put somewhere:
982
+ // deposition flux of so4 [mole/mole/s]
983
+ const auto aqso4_flx_col = ekat::subview (aqso4_flx, icol);
984
+ // deposition flux of h2so4 [mole/mole/s]
985
+ const auto aqh2so4_flx_col = ekat::subview (aqh2so4_flx, icol);
982
986
Real dflx_col[num_gas_spec_] = {}; // deposition velocity [1/cm/s]
983
987
Real dvel_col[num_gas_spec_] = {}; // deposition flux [1/cm^2/s]
984
988
// Output: values are dvel, dflx
@@ -1000,11 +1004,16 @@ void MAMMicrophysics::run_impl(const double dt) {
1000
1004
config.linoz .o3_lbl , dry_diameter_icol, wet_diameter_icol,
1001
1005
wetdens_icol, dry_atm.phis (icol), cmfdqr, prain_icol, nevapr_icol,
1002
1006
work_set_het_icol, drydep_data, aqso4_flx_col, aqh2so4_flx_col,
1003
- dvel_col, dflx_col, qgcm_tendaa, qqcwgcm_tendaa , progs);
1004
-
1007
+ dvel_col, dflx_col, gas_spec_tend_col, gas_spec_tend_cw_col , progs);
1008
+
1005
1009
team.team_barrier ();
1010
+ const auto gas_spec_tend_col_f = ekat::subview (gas_spec_tend_v, icol);
1011
+ const auto gas_spec_tend_cw_col_f = ekat::subview (gas_spec_tend_cw_v, icol);
1012
+ // shuffle the views from mam4xx into the corresponding field views
1013
+ transpose_mam_gas_tend_view (gas_spec_tend_col, gas_spec_tend_col_f, nlev_, num_gas_tend_);
1014
+ transpose_mam_gas_tend_view (gas_spec_tend_col, gas_spec_tend_col_f, nlev_, num_gas_tend_cw_);
1006
1015
const auto pdel_col = ekat::subview (dry_atm.p_del , icol);
1007
- auto wts_col = ekat::subview (gas_spec_tend_wts_V , icol);
1016
+ auto wts_col = ekat::subview (gas_spec_tend_wts_v , icol);
1008
1017
set_vert_contraction_weights (wts_col, molar_mass_g_per_mol_tmp, pdel_col, nlev_);
1009
1018
1010
1019
// Update constituent fluxes with gas drydep fluxes (dflx)
@@ -1017,6 +1026,7 @@ void MAMMicrophysics::run_impl(const double dt) {
1017
1026
}); // parallel_for for the column loop
1018
1027
Kokkos::fence ();
1019
1028
1029
+ // TODO: DIAGNOSTIC - will eventually be fenced off by a flag
1020
1030
// the variables in these column-integrated tendencies correspond to these MAM diagnostics:
1021
1031
// ['<xyz>_sfgaex1', '<xyz>_sfgaex2', '<xyz>_sfnnuc1', '<xyz>_sfcoag1']
1022
1032
auto col_int_gas_spec_tend = get_field_out (" col_int_gas_spec_tend" );
0 commit comments