Skip to content

Commit 6165581

Browse files
committed
Merge branch 'tcclevenger/eamxx/iop_as_atm' (PR #6787)
2 parents 765f5c8 + 8a9ea32 commit 6165581

27 files changed

+792
-758
lines changed

components/eamxx/cime_config/namelist_defaults_scream.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,9 @@ be lost if SCREAM_HACK_XML is not enabled.
427427
<ML_correction_unit_test type="logical">false</ML_correction_unit_test>
428428
</mlcorrection>
429429

430+
<!-- IOPForcing -->
431+
<iop_forcing inherit="atm_proc_base" />
432+
430433
<!-- For internal testing only -->
431434
<testOnly inherit="atm_proc_base">
432435
<my_param type="array(integer)">1,2</my_param>
@@ -556,6 +559,7 @@ be lost if SCREAM_HACK_XML is not enabled.
556559

557560
<physics inherit="atm_proc_group">
558561
<atm_procs_list>mac_aero_mic,rrtmgp</atm_procs_list>
562+
<atm_procs_list COMPSET=".*DP-EAMxx">iop_forcing,mac_aero_mic,rrtmgp</atm_procs_list>
559563
</physics>
560564
</atmosphere_processes_defaults>
561565

components/eamxx/src/control/atmosphere_driver.cpp

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -180,24 +180,24 @@ init_time_stamps (const util::TimeStamp& run_t0, const util::TimeStamp& case_t0,
180180
}
181181

182182
void AtmosphereDriver::
183-
setup_iop ()
183+
setup_iop_data_manager ()
184184
{
185185
// At this point, must have comm, params, initialized timestamps created.
186186
check_ad_status(s_comm_set | s_params_set | s_ts_inited);
187187

188188
// Check to make sure iop is not already initialized
189-
EKAT_REQUIRE_MSG(not m_iop, "Error! setup_iop() is called, but IOP already set up.\n");
189+
EKAT_REQUIRE_MSG(not m_iop_data_manager, "Error! setup_iop_data_manager() is called, but IOP already set up.\n");
190190

191191
// This function should only be called if we are enabling IOP
192192
const bool enable_iop =
193193
m_atm_params.sublist("driver_options").get("enable_iop", false);
194-
EKAT_REQUIRE_MSG(enable_iop, "Error! setup_iop() is called, but enable_iop=false "
194+
EKAT_REQUIRE_MSG(enable_iop, "Error! setup_iop_data_manager() is called, but enable_iop=false "
195195
"in driver_options parameters.\n");
196196

197197
// Params must include iop_options sublist.
198198
const auto iop_sublist_exists = m_atm_params.isSublist("iop_options");
199199
EKAT_REQUIRE_MSG(iop_sublist_exists,
200-
"Error! setup_iop() is called, but no iop_options "
200+
"Error! setup_iop_data_manager() is called, but no iop_options "
201201
"defined in parameters.\n");
202202

203203
const auto iop_params = m_atm_params.sublist("iop_options");
@@ -206,15 +206,15 @@ setup_iop ()
206206
const auto hyam = phys_grid->get_geometry_data("hyam");
207207
const auto hybm = phys_grid->get_geometry_data("hybm");
208208

209-
m_iop = std::make_shared<IntensiveObservationPeriod>(m_atm_comm,
210-
iop_params,
211-
m_run_t0,
212-
nlevs,
213-
hyam,
214-
hybm);
209+
m_iop_data_manager = std::make_shared<IOPDataManager>(m_atm_comm,
210+
iop_params,
211+
m_run_t0,
212+
nlevs,
213+
hyam,
214+
hybm);
215215

216216
// Set IOP object in atm processes
217-
m_atm_process_group->set_iop(m_iop);
217+
m_atm_process_group->set_iop_data_manager(m_iop_data_manager);
218218
}
219219

220220
void AtmosphereDriver::create_atm_processes()
@@ -295,7 +295,7 @@ void AtmosphereDriver::create_grids()
295295
const bool enable_iop =
296296
m_atm_params.sublist("driver_options").get("enable_iop", false);
297297
if (enable_iop) {
298-
setup_iop ();
298+
setup_iop_data_manager ();
299299
}
300300

301301
// Set the grids in the processes. Do this by passing the grids manager.
@@ -1244,7 +1244,7 @@ void AtmosphereDriver::set_initial_conditions ()
12441244
}
12451245
}
12461246

1247-
if (m_iop) {
1247+
if (m_iop_data_manager) {
12481248
// For runs with IOP, call to setup io grids and lat
12491249
// lon information needed for reading from file
12501250
// We use a single topo file for both GLL and PG2 runs. All
@@ -1254,13 +1254,13 @@ void AtmosphereDriver::set_initial_conditions ()
12541254
for (const auto& it : m_field_mgrs) {
12551255
const auto& grid_name = it.first;
12561256
if (ic_fields_names[grid_name].size() > 0 or
1257-
topography_eamxx_fields_names[grid_name].size() > 0) {
1257+
topography_eamxx_fields_names[grid_name].size() > 0) {
12581258
const auto& file_name = grid_name == "Physics GLL"
12591259
?
12601260
ic_pl.get<std::string>("Filename")
12611261
:
12621262
ic_pl.get<std::string>("topography_filename");
1263-
m_iop->setup_io_info(file_name, it.second->get_grid());
1263+
m_iop_data_manager->setup_io_info(file_name, it.second->get_grid());
12641264
}
12651265
}
12661266
}
@@ -1272,12 +1272,12 @@ void AtmosphereDriver::set_initial_conditions ()
12721272
m_atm_logger->info(" [EAMxx] IC filename: " + file_name);
12731273
for (const auto& it : m_field_mgrs) {
12741274
const auto& grid_name = it.first;
1275-
if (not m_iop) {
1275+
if (not m_iop_data_manager) {
12761276
read_fields_from_file (ic_fields_names[grid_name],it.second->get_grid(),file_name,m_current_ts);
12771277
} else {
12781278
// For IOP enabled, we load from file and copy data from the closest
12791279
// lat/lon column to every other column
1280-
m_iop->read_fields_from_file_for_iop(file_name,
1280+
m_iop_data_manager->read_fields_from_file_for_iop(file_name,
12811281
ic_fields_names[grid_name],
12821282
m_current_ts,
12831283
it.second);
@@ -1347,7 +1347,7 @@ void AtmosphereDriver::set_initial_conditions ()
13471347
m_atm_logger->info(" filename: " + file_name);
13481348
for (const auto& it : m_field_mgrs) {
13491349
const auto& grid_name = it.first;
1350-
if (not m_iop) {
1350+
if (not m_iop_data_manager) {
13511351
// Topography files always use "ncol_d" for the GLL grid value of ncol.
13521352
// To ensure we read in the correct value, we must change the name for that dimension
13531353
auto io_grid = it.second->get_grid();
@@ -1363,7 +1363,7 @@ void AtmosphereDriver::set_initial_conditions ()
13631363
} else {
13641364
// For IOP enabled, we load from file and copy data from the closest
13651365
// lat/lon column to every other column
1366-
m_iop->read_fields_from_file_for_iop(file_name,
1366+
m_iop_data_manager->read_fields_from_file_for_iop(file_name,
13671367
topography_file_fields_names[grid_name],
13681368
topography_eamxx_fields_names[grid_name],
13691369
m_current_ts,
@@ -1388,16 +1388,16 @@ void AtmosphereDriver::set_initial_conditions ()
13881388
m_atm_params.sublist("provenance").set<std::string>("topography_file","NONE");
13891389
}
13901390

1391-
if (m_iop) {
1391+
if (m_iop_data_manager) {
13921392
// Load IOP data file data for initial time stamp
1393-
m_iop->read_iop_file_data(m_current_ts);
1393+
m_iop_data_manager->read_iop_file_data(m_current_ts);
13941394

13951395
// Now that ICs are processed, set appropriate fields using IOP file data.
13961396
// Since ICs are loaded on GLL grid, we set those fields only and dynamics
13971397
// will take care of the rest (for PG2 case).
13981398
if (m_field_mgrs.count("Physics GLL") > 0) {
13991399
const auto& fm = m_field_mgrs.at("Physics GLL");
1400-
m_iop->set_fields_from_iop_data(fm);
1400+
m_iop_data_manager->set_fields_from_iop_data(fm);
14011401
}
14021402
}
14031403

@@ -1795,7 +1795,7 @@ void AtmosphereDriver::finalize ( /* inputs? */ ) {
17951795
}
17961796

17971797
// Destroy iop
1798-
m_iop = nullptr;
1798+
m_iop_data_manager = nullptr;
17991799

18001800
// Destroy the buffer manager
18011801
m_memory_buffer = nullptr;

components/eamxx/src/control/atmosphere_driver.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
#define SCREAM_ATMOSPHERE_DRIVER_HPP
33

44
#include "control/surface_coupling_utils.hpp"
5-
#include "share/iop/intensive_observation_period.hpp"
65
#include "share/field/field_manager.hpp"
76
#include "share/grid/grids_manager.hpp"
87
#include "share/util/scream_time_stamp.hpp"
@@ -11,6 +10,7 @@
1110
#include "share/io/scorpio_input.hpp"
1211
#include "share/atm_process/ATMBufferManager.hpp"
1312
#include "share/atm_process/SCDataManager.hpp"
13+
#include "share/atm_process/IOPDataManager.hpp"
1414

1515
#include "ekat/logging/ekat_logger.hpp"
1616
#include "ekat/mpi/ekat_comm.hpp"
@@ -72,8 +72,8 @@ class AtmosphereDriver
7272
// Set AD params
7373
void init_scorpio (const int atm_id = 0);
7474

75-
// Setup IntensiveObservationPeriod
76-
void setup_iop ();
75+
// Setup IOPDataManager
76+
void setup_iop_data_manager ();
7777

7878
// Create atm processes, without initializing them
7979
void create_atm_processes ();
@@ -217,7 +217,7 @@ class AtmosphereDriver
217217
std::shared_ptr<SCDataManager> m_surface_coupling_import_data_manager;
218218
std::shared_ptr<SCDataManager> m_surface_coupling_export_data_manager;
219219

220-
std::shared_ptr<IntensiveObservationPeriod> m_iop;
220+
std::shared_ptr<IOPDataManager> m_iop_data_manager;
221221

222222
// This is the time stamp at the beginning of the time step.
223223
util::TimeStamp m_current_ts;

components/eamxx/src/control/atmosphere_surface_coupling_importer.cpp

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,8 @@ void SurfaceCouplingImporter::do_import(const bool called_during_initialization)
208208
});
209209
#endif
210210

211-
if (m_iop) {
212-
if (m_iop->get_params().get<bool>("iop_srf_prop")) {
211+
if (m_iop_data_manager) {
212+
if (m_iop_data_manager->get_params().get<bool>("iop_srf_prop")) {
213213
// Overwrite imports with data from IOP file
214214
overwrite_iop_imports(called_during_initialization);
215215
}
@@ -221,9 +221,12 @@ void SurfaceCouplingImporter::overwrite_iop_imports (const bool called_during_in
221221
using policy_type = KokkosTypes<DefaultDevice>::RangePolicy;
222222
using C = physics::Constants<Real>;
223223

224-
const auto has_lhflx = m_iop->has_iop_field("lhflx");
225-
const auto has_shflx = m_iop->has_iop_field("shflx");
226-
const auto has_Tg = m_iop->has_iop_field("Tg");
224+
const auto has_lhflx = m_iop_data_manager->has_iop_field("lhflx");
225+
const auto has_shflx = m_iop_data_manager->has_iop_field("shflx");
226+
const auto has_Tg = m_iop_data_manager->has_iop_field("Tg");
227+
228+
// Read IOP file for current time step, if necessary
229+
m_iop_data_manager->read_iop_file_data(timestamp());
227230

228231
static constexpr Real latvap = C::LatVap;
229232
static constexpr Real stebol = C::stebol;
@@ -243,19 +246,19 @@ void SurfaceCouplingImporter::overwrite_iop_imports (const bool called_during_in
243246
// Store IOP surf data into col_val
244247
Real col_val(std::nan(""));
245248
if (fname == "surf_evap" && has_lhflx) {
246-
const auto f = m_iop->get_iop_field("lhflx");
249+
const auto f = m_iop_data_manager->get_iop_field("lhflx");
247250
f.sync_to_host();
248251
col_val = f.get_view<Real, Host>()()/latvap;
249252
} else if (fname == "surf_sens_flux" && has_shflx) {
250-
const auto f = m_iop->get_iop_field("shflx");
253+
const auto f = m_iop_data_manager->get_iop_field("shflx");
251254
f.sync_to_host();
252255
col_val = f.get_view<Real, Host>()();
253256
} else if (fname == "surf_radiative_T" && has_Tg) {
254-
const auto f = m_iop->get_iop_field("Tg");
257+
const auto f = m_iop_data_manager->get_iop_field("Tg");
255258
f.sync_to_host();
256259
col_val = f.get_view<Real, Host>()();
257260
} else if (fname == "surf_lw_flux_up" && has_Tg) {
258-
const auto f = m_iop->get_iop_field("Tg");
261+
const auto f = m_iop_data_manager->get_iop_field("Tg");
259262
f.sync_to_host();
260263
col_val = stebol*std::pow(f.get_view<Real, Host>()(), 4);
261264
} else {

components/eamxx/src/dynamics/homme/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,6 @@ macro (CreateDynamicsLib HOMME_TARGET NP PLEV QSIZE)
146146
${SCREAM_DYNAMICS_SRC_DIR}/eamxx_homme_process_interface.cpp
147147
${SCREAM_DYNAMICS_SRC_DIR}/eamxx_homme_fv_phys.cpp
148148
${SCREAM_DYNAMICS_SRC_DIR}/eamxx_homme_rayleigh_friction.cpp
149-
${SCREAM_DYNAMICS_SRC_DIR}/eamxx_homme_iop.cpp
150149
${SCREAM_DYNAMICS_SRC_DIR}/physics_dynamics_remapper.cpp
151150
${SCREAM_DYNAMICS_SRC_DIR}/homme_grids_manager.cpp
152151
${SCREAM_DYNAMICS_SRC_DIR}/interface/homme_context_mod.F90

0 commit comments

Comments
 (0)