1
1
#include " eamxx_cosp.hpp"
2
2
#include " cosp_functions.hpp"
3
3
#include " physics/share/physics_constants.hpp"
4
+ #include " share/util/eamxx_universal_constants.hpp"
4
5
#include " share/property_checks/field_within_interval_check.hpp"
5
6
#include " share/field/field_utils.hpp"
6
7
@@ -88,11 +89,11 @@ void Cosp::set_grids(const std::shared_ptr<const GridsManager> grids_manager)
88
89
add_field<Required>(" eff_radius_qc" , scalar3d_mid, micron, grid_name);
89
90
add_field<Required>(" eff_radius_qi" , scalar3d_mid, micron, grid_name);
90
91
// Set of fields used strictly as output
92
+ // NOTE we set their correspond masks in init impl
91
93
add_field<Computed>(" isccp_cldtot" , scalar2d, percent, grid_name);
92
94
add_field<Computed>(" isccp_ctptau" , scalar4d_ctptau, percent, grid_name, 1 );
93
95
add_field<Computed>(" modis_ctptau" , scalar4d_ctptau, percent, grid_name, 1 );
94
96
add_field<Computed>(" misr_cthtau" , scalar4d_cthtau, percent, grid_name, 1 );
95
- add_field<Computed>(" cosp_sunlit" , scalar2d, nondim, grid_name);
96
97
97
98
// We can allocate these now
98
99
m_z_mid = Field (FieldIdentifier (" z_mid" ,scalar3d_mid,m,grid_name));
@@ -107,15 +108,12 @@ void Cosp::initialize_impl (const RunType /* run_type */)
107
108
// Set property checks for fields in this process
108
109
CospFunc::initialize (m_num_cols, m_num_subcols, m_num_levs);
109
110
110
-
111
- // Add note to output files about processing ISCCP fields that are only valid during
112
- // daytime. This can go away once I/O can handle masked time averages.
111
+ // Set a mask field for each of the cosp computed fields
113
112
using stratts_t = std::map<std::string,std::string>;
114
113
std::list<std::string> vnames = {" isccp_cldtot" , " isccp_ctptau" , " modis_ctptau" , " misr_cthtau" };
115
114
for (const auto field_name : {" isccp_cldtot" , " isccp_ctptau" , " modis_ctptau" , " misr_cthtau" }) {
116
115
auto & f = get_field_out (field_name);
117
- auto & atts = f.get_header ().get_extra_data <stratts_t >(" io: string attributes" );
118
- atts[" note" ] = " Night values are zero; divide by cosp_sunlit to get daytime mean" ;
116
+ f.get_header ().set_extra_data (" mask_field" , f.clone (field_name + " _mask" ));
119
117
}
120
118
}
121
119
@@ -221,31 +219,50 @@ void Cosp::run_impl (const double dt)
221
219
const auto dtau105_h = get_field_in (" dtau105" ).get_view <const Real**, Host>();
222
220
223
221
auto isccp_cldtot_h = get_field_out (" isccp_cldtot" ).get_view <Real*, Host>();
222
+ auto isccp_cldtot_h_mask = get_field_out (" isccp_cldtot" ).get_header ().get_extra_data <Field>(" mask_field" ).get_view <Real*, Host>();
224
223
auto isccp_ctptau_h = get_field_out (" isccp_ctptau" ).get_view <Real***, Host>();
224
+ auto isccp_ctptau_h_mask = get_field_out (" isccp_ctptau" ).get_header ().get_extra_data <Field>(" mask_field" ).get_view <Real***, Host>();
225
225
auto modis_ctptau_h = get_field_out (" modis_ctptau" ).get_view <Real***, Host>();
226
+ auto modis_ctptau_h_mask = get_field_out (" modis_ctptau" ).get_header ().get_extra_data <Field>(" mask_field" ).get_view <Real***, Host>();
226
227
auto misr_cthtau_h = get_field_out (" misr_cthtau" ).get_view <Real***, Host>();
227
- auto cosp_sunlit_h = get_field_out (" cosp_sunlit " ).get_view <Real*, Host>(); // Copy of sunlit flag with COSP frequency for proper averaging
228
+ auto misr_cthtau_h_mask = get_field_out (" misr_cthtau " ).get_header (). get_extra_data <Field>( " mask_field " ). get_view <Real*** , Host>();
228
229
229
230
Real emsfc_lw = 0.99 ;
230
- Kokkos::deep_copy (cosp_sunlit_h, sunlit_h);
231
231
CospFunc::main (
232
232
m_num_cols, m_num_subcols, m_num_levs, m_num_tau, m_num_ctp, m_num_cth, emsfc_lw,
233
233
sunlit_h, skt_h, T_mid_h, p_mid_h, p_int_h, z_mid_h, qv_h, qc_h, qi_h,
234
234
cldfrac_h, reff_qc_h, reff_qi_h, dtau067_h, dtau105_h,
235
235
isccp_cldtot_h, isccp_ctptau_h, modis_ctptau_h, misr_cthtau_h
236
236
);
237
- // Remask night values to ZERO since our I/O does not know how to handle masked/missing values
238
- // in temporal averages; this is all host data, so we can just use host loops like its the 1980s
237
+ // Mask night values
238
+ constexpr auto fill_value = constants::fill_value<Real>;
239
239
for (int i = 0 ; i < m_num_cols; i++) {
240
240
if (sunlit_h (i) == 0 ) {
241
- isccp_cldtot_h (i) = 0 ;
241
+ // if night, set to fill val and set mask to 0
242
+ isccp_cldtot_h (i) = fill_value;
243
+ isccp_cldtot_h_mask (i) = 0 ;
244
+ for (int j = 0 ; j < m_num_tau; j++) {
245
+ for (int k = 0 ; k < m_num_ctp; k++) {
246
+ isccp_ctptau_h (i,j,k) = fill_value;
247
+ isccp_ctptau_h_mask (i,j,k) = 0 ;
248
+ modis_ctptau_h (i,j,k) = fill_value;
249
+ modis_ctptau_h_mask (i,j,k) = 0 ;
250
+ }
251
+ for (int k = 0 ; k < m_num_cth; k++) {
252
+ misr_cthtau_h (i,j,k) = fill_value;
253
+ misr_cthtau_h_mask (i,j,k) = 0 ;
254
+ }
255
+ }
256
+ } else {
257
+ // if NOT night, persist and set mask to 1
258
+ isccp_cldtot_h_mask (i) = 1 ;
242
259
for (int j = 0 ; j < m_num_tau; j++) {
243
260
for (int k = 0 ; k < m_num_ctp; k++) {
244
- isccp_ctptau_h (i,j,k) = 0 ;
245
- modis_ctptau_h (i,j,k) = 0 ;
261
+ isccp_ctptau_h_mask (i,j,k) = 1 ;
262
+ modis_ctptau_h_mask (i,j,k) = 1 ;
246
263
}
247
264
for (int k = 0 ; k < m_num_cth; k++) {
248
- misr_cthtau_h (i,j,k) = 0 ;
265
+ misr_cthtau_h_mask (i,j,k) = 1 ;
249
266
}
250
267
}
251
268
}
@@ -256,7 +273,6 @@ void Cosp::run_impl (const double dt)
256
273
get_field_out (" isccp_ctptau" ).sync_to_dev ();
257
274
get_field_out (" modis_ctptau" ).sync_to_dev ();
258
275
get_field_out (" misr_cthtau" ).sync_to_dev ();
259
- get_field_out (" cosp_sunlit" ).sync_to_dev ();
260
276
}
261
277
}
262
278
0 commit comments