Skip to content

Commit afeffd1

Browse files
Fixes optics test, this commit has ACI single grid cell printouts
1 parent 83a46c0 commit afeffd1

File tree

5 files changed

+263
-23
lines changed

5 files changed

+263
-23
lines changed

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

Lines changed: 249 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include <physics/mam/eamxx_mam_aci_process_interface.hpp>
2+
#include <iomanip>
23

34
/*
45
-----------------------------------------------------------------
@@ -21,6 +22,222 @@ namespace scream {
2122

2223
namespace {
2324

25+
void print_output(const Real w0, const Real rho, const Real tke,
26+
const Real wsub, const Real wice, const Real wsig,
27+
const Real naai_hom, const Real naai, const Real rpdel,
28+
MAMAci::view_3d factnum, const Real tendnd,
29+
MAMAci::view_2d ptend_q[mam4::aero_model::pcnst],
30+
MAMAci::view_2d qqcw_fld_work[mam4::ndrop::ncnst_tot],
31+
const Real hetfrz_immersion_nucleation_tend,
32+
const Real hetfrz_contact_nucleation_tend,
33+
const Real hetfrz_depostion_nucleation_tend,
34+
const mam_coupling::AerosolState &dry_aero, const int kb) {
35+
36+
std::cout << "w0:" << std::setprecision (15) << w0 << std::endl;
37+
std::cout << "rho: " << rho << std::endl;
38+
std::cout << "TKE:" << tke << std::endl;
39+
std::cout << "wsub:" << wsub << std::endl;
40+
std::cout << "wsubi:" << wice << std::endl;
41+
std::cout << "wsig:" << wsig << std::endl;
42+
std::cout << "dgnum_ait:"<< std::endl;
43+
std::cout << "naai_:" << naai << std::endl;
44+
std::cout << "naai_hom:" << naai_hom << std::endl;
45+
//std::cout << "rpdel_:" << rpdel << std::endl;
46+
std::cout << "factnum:" << factnum(0, 0, kb) << " " << factnum(0, 1, kb)
47+
<< " : " << factnum(0, 2, kb) << " : " << factnum(0, 3, kb)
48+
<< std::endl;
49+
std::cout << "nctend_mixnuc:" << tendnd << std::endl;
50+
51+
for(int m = 0; m < mam_coupling::num_aero_modes(); ++m) {
52+
std::cout << "inter_num:" << dry_aero.int_aero_nmr[m](0, kb) << std::endl;
53+
for(int a = 0; a < mam_coupling::num_aero_species(); ++a) {
54+
if(dry_aero.int_aero_mmr[m][a].data()) {
55+
std::cout << "inter-mmr:" << dry_aero.int_aero_mmr[m][a](0, kb)
56+
<< std::endl;
57+
}
58+
}
59+
}
60+
61+
for(int ic = 9; ic < 40; ++ic) {
62+
std::cout << "ptend_q_:" << ic << ": " << ptend_q[ic](0, kb) << std::endl;
63+
}
64+
/*for(int ic = 0; ic < 25; ++ic) {
65+
std::cout << "qqcw_:" << ic << ": " << qqcw_fld_work[ic](0, kb)
66+
<< std::endl;
67+
}*/
68+
for(int m = 0; m < mam_coupling::num_aero_modes(); ++m) {
69+
std::cout << "cldbrn_num:" << dry_aero.cld_aero_nmr[m](0, kb) << std::endl;
70+
for(int a = 0; a < mam_coupling::num_aero_species(); ++a) {
71+
if(dry_aero.cld_aero_mmr[m][a].data()) {
72+
std::cout << "cldbrn-mmr:" << dry_aero.cld_aero_mmr[m][a](0, kb)
73+
<< std::endl;
74+
}
75+
}
76+
}
77+
78+
79+
/*for(int m = 0; m < mam_coupling::num_aero_modes(); ++m) {
80+
std::cout << "cld_num:" << dry_aero.cld_aero_nmr[m](0, kb) << std::endl;
81+
for(int a = 0; a < mam_coupling::num_aero_species(); ++a) {
82+
if(dry_aero.cld_aero_mmr[m][a].data()) {
83+
std::cout << "cld-mmr:" << dry_aero.cld_aero_mmr[m][a](0, kb)
84+
<< std::endl;
85+
}
86+
}
87+
}*/
88+
89+
std::cout << "hetfrz_immersion_nucleation_tend_:"
90+
<< hetfrz_immersion_nucleation_tend << ":"
91+
<< hetfrz_immersion_nucleation_tend << std::endl;
92+
std::cout << "hetfrz_contact_nucleation_tend_:"
93+
<< hetfrz_contact_nucleation_tend << std::endl;
94+
std::cout << "hetfrz_depostion_nucleation_tend_:"
95+
<< hetfrz_depostion_nucleation_tend << std::endl;
96+
}
97+
98+
void set_input(MAMAci::view_2d w_sec_int_, MAMAci::view_2d kvh_int_,
99+
const int ncol_, const int nlev_) {
100+
const Real w_sec_e3sm[73] = {
101+
0.40000000000000002E-003, 0.40000000000000002E-003,
102+
0.40000000000000002E-003, 0.40000000000000002E-003,
103+
0.40000000000000002E-003, 0.40000000000000002E-003,
104+
0.40000000000000002E-003, 0.40000000000000002E-003,
105+
0.40000000000000002E-003, 0.40000000000000002E-003,
106+
0.40000000000000002E-003, 0.40000000000000002E-003,
107+
0.40000000000000002E-003, 0.40000000000000002E-003,
108+
0.40000000000000002E-003, 0.40000000000000002E-003,
109+
0.40000000000000002E-003, 0.40000000000000002E-003,
110+
0.40000000000000002E-003, 0.40000000000000002E-003,
111+
0.40000000000000002E-003, 0.40000000000000002E-003,
112+
0.40000000000000002E-003, 0.40000000000000002E-003,
113+
0.40000000000000002E-003, 0.40000000000000002E-003,
114+
0.40000000000000002E-003, 0.40000000000000002E-003,
115+
0.40000000000000002E-003, 0.40000000000000002E-003,
116+
0.40000000000000002E-003, 0.40000000000000002E-003,
117+
0.40000000000000002E-003, 0.40000000000000002E-003,
118+
0.40000000000000002E-003, 0.40000000000000002E-003,
119+
0.40000000000000002E-003, 0.40000000000000002E-003,
120+
0.40000000000000002E-003, 0.40000000000000002E-003,
121+
0.40000000000000002E-003, 0.40000000000000002E-003,
122+
0.40000000000000002E-003, 0.40000000000000002E-003,
123+
0.40000000000000002E-003, 0.40000000000000002E-003,
124+
0.40000000000000002E-003, 0.40000000000000002E-003,
125+
0.40000000000000002E-003, 0.40000000000000002E-003,
126+
0.40000000000000002E-003, 0.40000000000000002E-003,
127+
0.40000000000000002E-003, 0.40000000000000002E-003,
128+
0.40000000000000002E-003, 0.40000000000000002E-003,
129+
0.40000000000000002E-003, 0.40000000000000002E-003,
130+
0.40000000000000002E-003, 0.44201892319518146E-003,
131+
0.77315620137962326E-003, 0.24806301482800117E-002,
132+
0.11109772692898754E-001, 0.40651094032490273E-001,
133+
0.82156694426095800E-001, 0.12207124453993526E+000,
134+
0.15516728994634110E+000, 0.17775318086169636E+000,
135+
0.18549817250146838E+000, 0.17184548286554119E+000,
136+
0.12741230682196053E+000, 0.65495229516041628E-001,
137+
0.26909155217660592E-001};
138+
139+
for(int icol = 0; icol < ncol_; ++icol) {
140+
for(int kk = 0; kk < nlev_; ++kk) {
141+
w_sec_int_(icol, kk) = w_sec_e3sm[kk];
142+
// w_sec_int_(icol, kk) = w_sec_mid_(icol, kk);
143+
}
144+
// w_sec_int_(icol, nlev_ + 1) = w_sec_mid_(icol, nlev_);
145+
w_sec_int_(icol, nlev_ + 1) = w_sec_e3sm[nlev_ + 1];
146+
}
147+
const Real kvh_e3sm[73] = {0.25020913575496480E-002, 0.25021052914616470E-002,
148+
0.75991761081225006E-002, 0.12291092068185365E-001,
149+
0.11484807652762415E-001, 0.10856880396302943E-001,
150+
0.10500384508819637E-001, 0.10361486171738229E-001,
151+
0.10333325067964508E-001, 0.10258838031435397E-001,
152+
0.10027325248446619E-001, 0.97784259072973521E-002,
153+
0.96611845055866539E-002, 0.96249746122327937E-002,
154+
0.95773431515696512E-002, 0.95180614513688099E-002,
155+
0.94713233348487150E-002, 0.94503864489758338E-002,
156+
0.94536294366578833E-002, 0.94575972194308883E-002,
157+
0.94403767489615684E-002, 0.93975694769176284E-002,
158+
0.93322843554751022E-002, 0.92777070192527501E-002,
159+
0.92456776697171228E-002, 0.92266924824142716E-002,
160+
0.92123025773060436E-002, 0.91888715633294191E-002,
161+
0.91516797753615851E-002, 0.90958299606649744E-002,
162+
0.89988037524983237E-002, 0.88220984587642423E-002,
163+
0.85231270833157156E-002, 0.81397522619395188E-002,
164+
0.79160421807845088E-002, 0.81206851117902653E-002,
165+
0.86526891616674779E-002, 0.91682975412125615E-002,
166+
0.96043394254592580E-002, 0.10033689085881327E-001,
167+
0.10428656694074272E-001, 0.10715913043864789E-001,
168+
0.10919631245454951E-001, 0.11250937075285789E-001,
169+
0.11829292157343831E-001, 0.12413311776454055E-001,
170+
0.12851317662157077E-001, 0.13175523677700330E-001,
171+
0.13224182907540188E-001, 0.13085937680733115E-001,
172+
0.12615055546741534E-001, 0.11995423733019836E-001,
173+
0.12346556881757400E-001, 0.13433752971524651E-001,
174+
0.13904308240950175E-001, 0.13539811748121957E-001,
175+
0.12555099320041433E-001, 0.11519643673351362E-001,
176+
0.11414071302852231E-001, 0.13409756835238139E-001,
177+
0.24071962815959351E-001, 0.75489419450816414E-001,
178+
0.62082011878960308E+000, 0.63952862312816796E+001,
179+
0.16226857944175123E+002, 0.21882852534279891E+002,
180+
0.24966173574402408E+002, 0.25710753126453692E+002,
181+
0.24069881024271943E+002, 0.19743922403487922E+002,
182+
0.98667814246712027E+001, 0.25633359450143991E+001,
183+
0.14682471685037493E+001};
184+
// compute eddy diffusivity of heat at the interfaces
185+
for(int icol = 0; icol < ncol_; ++icol) {
186+
for(int kk = 0; kk < nlev_; ++kk) {
187+
// kvh_int_(icol, kk) = kvh_mid_(icol, kk);
188+
kvh_int_(icol, kk) = kvh_e3sm[kk];
189+
}
190+
// kvh_int_(icol, nlev_ + 1) = kvh_mid_(icol, nlev_);
191+
kvh_int_(icol, nlev_ + 1) = kvh_e3sm[nlev_ + 1];
192+
}
193+
}
194+
195+
void set_dgait(MAMAci::view_2d aitken_dry_dia_, const int ncol_,
196+
const int nlev_) {
197+
const Real dgnum_ait_e3sm[72] = {
198+
0.20877713336487552E-007, 0.21782230353342090E-007,
199+
0.21688324003865861E-007, 0.21112855042342451E-007,
200+
0.19162058462939536E-007, 0.18102979880838476E-007,
201+
0.17906980715477606E-007, 0.20271254074583327E-007,
202+
0.22698983422181942E-007, 0.24134835117044986E-007,
203+
0.25498156808001372E-007, 0.29796738799905547E-007,
204+
0.35822987394021908E-007, 0.41170963764365215E-007,
205+
0.44892726528330642E-007, 0.47217231342203107E-007,
206+
0.48928661807108766E-007, 0.50170939816128735E-007,
207+
0.51078750853732200E-007, 0.52247333465736065E-007,
208+
0.53190758580174931E-007, 0.53576491941850044E-007,
209+
0.53915614473890715E-007, 0.54510964775236826E-007,
210+
0.55643231691556703E-007, 0.57057811112589899E-007,
211+
0.58177383586181116E-007, 0.58209849180850108E-007,
212+
0.57976751598840998E-007, 0.52000000000000002E-007,
213+
0.50728746567226150E-007, 0.49119902704480870E-007,
214+
0.48212162162050883E-007, 0.49227715213506454E-007,
215+
0.46876827233752246E-007, 0.45360603896257791E-007,
216+
0.49986783979004747E-007, 0.51186879246229022E-007,
217+
0.50009353247048599E-007, 0.48250264542204811E-007,
218+
0.47560278748093609E-007, 0.48298089720730957E-007,
219+
0.49095935613468768E-007, 0.49493024126912931E-007,
220+
0.50250797590476007E-007, 0.51949267668322422E-007,
221+
0.53778727208416418E-007, 0.53563593301099588E-007,
222+
0.51218136771199298E-007, 0.43171429694325200E-007,
223+
0.39019610039033895E-007, 0.36175109143257051E-007,
224+
0.42731638777892750E-007, 0.38060728507221777E-007,
225+
0.44046323901481340E-007, 0.39216732751330010E-007,
226+
0.34842233953609988E-007, 0.34068804733226066E-007,
227+
0.30636043694263528E-007, 0.28302341686131413E-007,
228+
0.33023014309036320E-007, 0.34745748365385196E-007,
229+
0.43623545003583371E-007, 0.48206451795644064E-007,
230+
0.49854490325455530E-007, 0.50346335647724146E-007,
231+
0.50661560988561763E-007, 0.50986261962838767E-007,
232+
0.51256955985111086E-007, 0.51482578449096488E-007,
233+
0.51684364851091471E-007, 0.51849719162939729E-007};
234+
for(int icol = 0; icol < ncol_; ++icol) {
235+
for(int kk = 0; kk < nlev_; ++kk) {
236+
aitken_dry_dia_(icol, kk) = dgnum_ait_e3sm[kk];
237+
}
238+
}
239+
}
240+
24241
KOKKOS_INLINE_FUNCTION
25242
void compute_w0_and_rho(const haero::ThreadTeam &team,
26243
const MAMAci::const_view_2d omega,
@@ -490,7 +707,7 @@ void call_function_dropmixnuc(
490707

491708
// get qqcw at a grid cell (col,lev)
492709
// NOTE: The layout for qqcw array is based on mam_idx in
493-
// dropmixnuc To mimic that, we are using the following for-loops
710+
// dropmixnuc. To mimic that, we are using the following for-loops
494711
int ind_qqcw = 0;
495712
for(int m = 0; m < mam_coupling::num_aero_modes(); ++m) {
496713
qqcw_view[ind_qqcw](klev) =
@@ -834,7 +1051,8 @@ void MAMAci::set_grids(
8341051
// and we might need to revisit this.
8351052

8361053
// Vertical velocity variance at midpoints
837-
add_field<Required>("w_variance", scalar3d_layout_mid, m2 / s2, grid_name);
1054+
//add_field<Required>("w_variance", scalar3d_layout_mid, m2 / s2, grid_name);
1055+
add_field<Required>("w_variance", scalar3d_layout_int, m2 / s2, grid_name);
8381056

8391057
// NOTE: "cldfrac_liq" is updated in SHOC. "cldfrac_liq" in C++ code is
8401058
// equivalent to "alst" in the shoc_intr.F90. In the C++ code, it is used as
@@ -848,8 +1066,8 @@ void MAMAci::set_grids(
8481066
grid_name);
8491067

8501068
// Eddy diffusivity for heat
851-
add_field<Required>("eddy_diff_heat", scalar3d_layout_mid, m2 / s, grid_name);
852-
1069+
//add_field<Required>("eddy_diff_heat", scalar3d_layout_mid, m2 / s, grid_name);
1070+
add_field<Required>("eddy_diff_heat", scalar3d_layout_int, m2 / s, grid_name);
8531071
// Layout for 4D (2d horiz X 1d vertical x number of modes) variables
8541072
const int num_aero_modes = mam_coupling::num_aero_modes();
8551073
FieldLayout scalar4d_layout_mid =
@@ -1054,12 +1272,14 @@ void MAMAci::initialize_impl(const RunType run_type) {
10541272
wet_aero_.int_aero_nmr[m] =
10551273
get_field_out(int_nmr_field_name).get_view<Real **>();
10561274
dry_aero_.int_aero_nmr[m] = buffer_.dry_int_aero_nmr[m];
1275+
//std::cout<<"index:"<<m<<" "<<int_nmr_field_name<<std::endl;
10571276

10581277
// cloudborne aerosol tracers of interest: number (n) mixing ratios
10591278
const char *cld_nmr_field_name = mam_coupling::cld_aero_nmr_field_name(m);
10601279
wet_aero_.cld_aero_nmr[m] =
10611280
get_field_out(cld_nmr_field_name).get_view<Real **>();
10621281
dry_aero_.cld_aero_nmr[m] = buffer_.dry_cld_aero_nmr[m];
1282+
//std::cout<<"index:"<<m<<" species-CLD:"<<cld_nmr_field_name<<std::endl;
10631283

10641284
for(int a = 0; a < mam_coupling::num_aero_species(); ++a) {
10651285
// (interstitial) aerosol tracers of interest: mass (q) mixing ratios
@@ -1069,6 +1289,7 @@ void MAMAci::initialize_impl(const RunType run_type) {
10691289
if(strlen(int_mmr_field_name) > 0) {
10701290
wet_aero_.int_aero_mmr[m][a] =
10711291
get_field_out(int_mmr_field_name).get_view<Real **>();
1292+
//std::cout<<"indices:"<<m<<", "<<a<<" "<<int_mmr_field_name<<std::endl;
10721293
dry_aero_.int_aero_mmr[m][a] = buffer_.dry_int_aero_mmr[m][a];
10731294
}
10741295

@@ -1078,6 +1299,7 @@ void MAMAci::initialize_impl(const RunType run_type) {
10781299
if(strlen(cld_mmr_field_name) > 0) {
10791300
wet_aero_.cld_aero_mmr[m][a] =
10801301
get_field_out(cld_mmr_field_name).get_view<Real **>();
1302+
//std::cout<<"indices:"<<m<<" "<<a<<" species-CLD:"<<int_mmr_field_name<<std::endl;
10811303
dry_aero_.cld_aero_mmr[m][a] = buffer_.dry_cld_aero_mmr[m][a];
10821304
}
10831305
}
@@ -1250,15 +1472,22 @@ void MAMAci::initialize_impl(const RunType run_type) {
12501472
// RUN_IMPL
12511473
// ================================================================
12521474
void MAMAci::run_impl(const double dt) {
1475+
//const auto scan_policy = ekat::ExeSpaceUtils<
1476+
// KT::ExeSpace>::get_thread_range_parallel_scan_team_policy(ncol_, nlev_);
1477+
1478+
// FIXME: Remove set_input and print_input
1479+
set_input(w_sec_int_, kvh_int_, ncol_, nlev_);
1480+
12531481
const auto scan_policy = ekat::ExeSpaceUtils<
1254-
KT::ExeSpace>::get_thread_range_parallel_scan_team_policy(ncol_, nlev_);
1482+
KT::ExeSpace>::get_thread_range_parallel_scan_team_policy(1, nlev_);
12551483

12561484
// preprocess input -- needs a scan for the calculation of local derivied
12571485
// quantities
12581486
Kokkos::parallel_for("preprocess", scan_policy, preprocess_);
12591487
Kokkos::fence();
12601488

1261-
haero::ThreadTeamPolicy team_policy(ncol_, Kokkos::AUTO);
1489+
//haero::ThreadTeamPolicy team_policy(ncol_, Kokkos::AUTO);
1490+
haero::ThreadTeamPolicy team_policy(1, Kokkos::AUTO);
12621491

12631492
// FIXME: Temporary assignment of nc
12641493
// Kokkos::deep_copy(nc_inp_to_aci_, wet_atm_.nc);
@@ -1275,9 +1504,9 @@ void MAMAci::run_impl(const double dt) {
12751504
w0_, rho_);
12761505

12771506
// Get w_sec_int_ from w_sec_mid_
1278-
compute_values_at_interfaces(team_policy, w_sec_mid_, dry_atm_.dz, nlev_,
1507+
/*compute_values_at_interfaces(team_policy, w_sec_mid_, dry_atm_.dz, nlev_,
12791508
// output
1280-
w_sec_int_);
1509+
w_sec_int_);*/
12811510

12821511
compute_tke_using_w_sec(team_policy, w_sec_int_, nlev_,
12831512
// output
@@ -1294,6 +1523,8 @@ void MAMAci::run_impl(const double dt) {
12941523
compute_aitken_dry_diameter(team_policy, dgnum_, top_lev_, nlev_,
12951524
// output
12961525
aitken_dry_dia_);
1526+
// FIXME:Remove set_dgait
1527+
set_dgait(aitken_dry_dia_, ncol_, nlev_);
12971528

12981529
Kokkos::fence(); // wait for aitken_dry_dia_ to be computed.
12991530

@@ -1321,9 +1552,9 @@ void MAMAci::run_impl(const double dt) {
13211552
Kokkos::fence(); // wait for rpdel_ to be computed.
13221553

13231554
// Get kvh_int_ from kvh_mid_
1324-
compute_values_at_interfaces(team_policy, kvh_mid_, dry_atm_.dz, nlev_,
1555+
/*compute_values_at_interfaces(team_policy, kvh_mid_, dry_atm_.dz, nlev_,
13251556
// output
1326-
kvh_int_);
1557+
kvh_int_);*/
13271558

13281559
// Compute activated CCN number tendency (tendnd_) and updated
13291560
// cloud borne aerosols (stored in a work array) and interstitial
@@ -1385,6 +1616,14 @@ void MAMAci::run_impl(const double dt) {
13851616
// call post processing to convert dry mixing ratios to wet mixing ratios
13861617
Kokkos::parallel_for("postprocess", scan_policy, postprocess_);
13871618
Kokkos::fence(); // wait before returning to calling function
1619+
1620+
const int kb = 62;
1621+
print_output(w0_(0, kb), rho_(0, kb), tke_(0, kb), wsub_(0, kb),
1622+
wsubice_(0, kb), wsig_(0, kb), naai_hom_(0, kb), naai_(0, kb),
1623+
rpdel_(0, kb), factnum_, tendnd_(0, kb), ptend_q_,
1624+
qqcw_fld_work_, hetfrz_immersion_nucleation_tend_(0, kb),
1625+
hetfrz_contact_nucleation_tend_(0, kb),
1626+
hetfrz_depostion_nucleation_tend_(0, kb), dry_aero_, kb);
13881627
}
13891628

13901629
} // namespace scream

0 commit comments

Comments
 (0)