Class emulator::EmulatorComp
ClassList > emulator > EmulatorComp
Abstract base class for all emulated E3SM components. More...
#include <emulator_comp.hpp>
Inherited by the following classes: emulator::EmulatorAtm
Public Functions
| Type | Name |
|---|---|
| EmulatorComp (CompType type) Construct an emulator component of the given type. |
|
| MPI_Comm | comm () const Get MPI communicator. |
| int | comp_id () const Get component ID. |
| void | create_instance (MPI_Comm comm, int comp_id, const char * input_file, int run_type, int start_ymd, int start_tod) Initialize the component instance. |
| void | finalize () Finalize and clean up the component. |
| void | get_cols_area (double * area) const Get area for local columns. |
| void | get_cols_latlon (double * lat, double * lon) const Get lat/lon for local columns. |
| void | get_local_col_gids (int * gids) const Get global IDs for local columns. |
| int | get_num_global_cols () const Get total number of columns globally. |
| int | get_num_local_cols () const Get number of columns on this MPI rank. |
| int | get_nx () const Get number of grid points in x-direction (longitude). |
| int | get_ny () const Get number of grid points in y-direction (latitude). |
| void | initialize () Initialize the component (phase 2). |
| bool | is_root () const Check if this is the root rank (rank 0). |
| int | rank () const Get MPI rank within component communicator. |
| void | run (int dt) Execute one time step. |
| void | set_grid_data (int nx, int ny, int num_local_cols, int num_global_cols, const int * col_gids, const double * lat, const double * lon, const double * area) Set grid decomposition data from the driver. |
| void | setup_coupling (double * import_data, double * export_data, int num_imports, int num_exports, int field_size) Set up coupling data buffers. |
| CompType | type () const Get component type. |
| virtual | ~EmulatorComp () = default |
Protected Attributes
| Type | Name |
|---|---|
| std::vector< double > | m_area Cell area [km²]. |
| std::vector< int > | m_col_gids Global IDs for local columns. |
| MPI_Comm | m_comm MPI communicator. |
| int | m_comp_id Component ID from driver. |
| int | m_current_tod = 0Current time of day [seconds]. |
| int | m_current_ymd = 0Current date as YYYYMMDD. |
| double * | m_export_data = nullptrExport buffer pointer (a2x) |
| int | m_field_size = 0Size per field (should = num_local_cols) |
| double * | m_import_data = nullptrImport buffer pointer (x2a) |
| std::string | m_input_file Path to configuration file. |
| std::vector< double > | m_lat Latitude [radians]. |
| Logger | m_logger Component logger. |
| std::vector< double > | m_lon Longitude [radians]. |
| int | m_nprocs Number of MPI processes. |
| int | m_num_exports = 0Number of export fields. |
| int | m_num_global_cols = 0Global column count. |
| int | m_num_imports = 0Number of import fields. |
| int | m_num_local_cols = 0Local column count. |
| int | m_nx = 0Grid points in x (longitude) |
| int | m_ny = 0Grid points in y (latitude) |
| int | m_rank MPI rank within component. |
| int | m_run_type Run type (startup/continue/branch) |
| int | m_step_count = 0Number of steps executed. |
| CompType | m_type Component type enum. |
Protected Functions
| Type | Name |
|---|---|
| virtual void | export_to_coupler () Export fields to coupler (override as needed). |
| virtual void | final_impl () = 0 Component-specific finalization. |
| virtual void | import_from_coupler () Import fields from coupler (override as needed). |
| virtual void | init_impl () = 0 Component-specific initialization. |
| virtual void | run_impl (int dt) = 0 Component-specific time step execution. |
| virtual void | run_inference (const std::vector< double > & inputs, std::vector< double > & outputs) = 0 Run AI inference on packed input/output vectors. |
Detailed Description
Public Functions Documentation
function EmulatorComp
Construct an emulator component of the given type.
explicit emulator::EmulatorComp::EmulatorComp (
CompType type
)
Parameters:
typeComponent type (ATM, OCN, ICE, LND)
function comm
Get MPI communicator.
inline MPI_Comm emulator::EmulatorComp::comm () const
function comp_id
Get component ID.
inline int emulator::EmulatorComp::comp_id () const
function create_instance
Initialize the component instance.
void emulator::EmulatorComp::create_instance (
MPI_Comm comm,
int comp_id,
const char * input_file,
int run_type,
int start_ymd,
int start_tod
)
Initialize the component instance with MPI and metadata.
Sets up MPI communicator, stores component metadata, and prepares for grid data and coupling setup.
Parameters:
commMPI communicator for this componentcomp_idComponent ID assigned by the driverinput_filePath to component configuration filerun_typeRun type (startup, continue, branch)start_ymdStart date as YYYYMMDDstart_todStart time of day in seconds
function finalize
Finalize and clean up the component.
void emulator::EmulatorComp::finalize ()
Finalize the component and release resources.
Releases resources, finalizes inference backend, and performs any necessary cleanup.
function get_cols_area
Get area for local columns.
void emulator::EmulatorComp::get_cols_area (
double * area
) const
Parameters:
areaOutput area array [km²]
function get_cols_latlon
Get lat/lon for local columns.
void emulator::EmulatorComp::get_cols_latlon (
double * lat,
double * lon
) const
Parameters:
latOutput latitude array [radians]lonOutput longitude array [radians]
function get_local_col_gids
Get global IDs for local columns.
void emulator::EmulatorComp::get_local_col_gids (
int * gids
) const
Parameters:
gidsOutput array (must be pre-allocated with num_local_cols)
function get_num_global_cols
Get total number of columns globally.
inline int emulator::EmulatorComp::get_num_global_cols () const
function get_num_local_cols
Get number of columns on this MPI rank.
inline int emulator::EmulatorComp::get_num_local_cols () const
function get_nx
Get number of grid points in x-direction (longitude).
inline int emulator::EmulatorComp::get_nx () const
function get_ny
Get number of grid points in y-direction (latitude).
inline int emulator::EmulatorComp::get_ny () const
function initialize
Initialize the component (phase 2).
void emulator::EmulatorComp::initialize ()
Initialize the component by calling the derived class implementation.
Called after grid and coupling setup. Loads AI model, reads initial conditions, and prepares for time stepping.
function is_root
Check if this is the root rank (rank 0).
inline bool emulator::EmulatorComp::is_root () const
function rank
Get MPI rank within component communicator.
inline int emulator::EmulatorComp::rank () const
function run
Execute one time step.
void emulator::EmulatorComp::run (
int dt
)
Execute one time step: import → run → export.
Performs the main computational cycle:
- Import fields from coupler
- Run AI inference
- Export fields to coupler
Parameters:
dtTime step size in seconds
function set_grid_data
Set grid decomposition data from the driver.
void emulator::EmulatorComp::set_grid_data (
int nx,
int ny,
int num_local_cols,
int num_global_cols,
const int * col_gids,
const double * lat,
const double * lon,
const double * area
)
Override grid data with values from Fortran driver.
Receives the local portion of the global grid as distributed by the E3SM driver's domain decomposition.
Parameters:
nxNumber of grid points in x-direction (longitude)nyNumber of grid points in y-direction (latitude)num_local_colsNumber of columns on this MPI ranknum_global_colsTotal number of columns globallycol_gidsGlobal IDs for each local columnlatLatitude values for each local column [radians]lonLongitude values for each local column [radians]areaGrid cell areas for each local column [km²]
Used when the driver provides grid decomposition directly instead of reading from a file.
function setup_coupling
Set up coupling data buffers.
void emulator::EmulatorComp::setup_coupling (
double * import_data,
double * export_data,
int num_imports,
int num_exports,
int field_size
)
Set up coupling buffer pointers from the MCT layer.
Receives pointers to the MCT attribute vector buffers for data exchange with other components via the coupler.
Parameters:
import_dataPointer to import buffer (x2a fields)export_dataPointer to export buffer (a2x fields)num_importsNumber of import fieldsnum_exportsNumber of export fieldsfield_sizeSize of each field (should equal num_local_cols)
function type
Get component type.
inline CompType emulator::EmulatorComp::type () const
function ~EmulatorComp
virtual emulator::EmulatorComp::~EmulatorComp () = default
Protected Attributes Documentation
variable m_area
Cell area [km²].
std::vector<double> emulator::EmulatorComp::m_area;
variable m_col_gids
Global IDs for local columns.
std::vector<int> emulator::EmulatorComp::m_col_gids;
variable m_comm
MPI communicator.
MPI_Comm emulator::EmulatorComp::m_comm;
variable m_comp_id
Component ID from driver.
int emulator::EmulatorComp::m_comp_id;
variable m_current_tod
Current time of day [seconds].
int emulator::EmulatorComp::m_current_tod;
variable m_current_ymd
Current date as YYYYMMDD.
int emulator::EmulatorComp::m_current_ymd;
variable m_export_data
Export buffer pointer (a2x)
double* emulator::EmulatorComp::m_export_data;
variable m_field_size
Size per field (should = num_local_cols)
int emulator::EmulatorComp::m_field_size;
variable m_import_data
Import buffer pointer (x2a)
double* emulator::EmulatorComp::m_import_data;
variable m_input_file
Path to configuration file.
std::string emulator::EmulatorComp::m_input_file;
variable m_lat
Latitude [radians].
std::vector<double> emulator::EmulatorComp::m_lat;
variable m_logger
Component logger.
Logger emulator::EmulatorComp::m_logger;
variable m_lon
Longitude [radians].
std::vector<double> emulator::EmulatorComp::m_lon;
variable m_nprocs
Number of MPI processes.
int emulator::EmulatorComp::m_nprocs;
variable m_num_exports
Number of export fields.
int emulator::EmulatorComp::m_num_exports;
variable m_num_global_cols
Global column count.
int emulator::EmulatorComp::m_num_global_cols;
variable m_num_imports
Number of import fields.
int emulator::EmulatorComp::m_num_imports;
variable m_num_local_cols
Local column count.
int emulator::EmulatorComp::m_num_local_cols;
variable m_nx
Grid points in x (longitude)
int emulator::EmulatorComp::m_nx;
variable m_ny
Grid points in y (latitude)
int emulator::EmulatorComp::m_ny;
variable m_rank
MPI rank within component.
int emulator::EmulatorComp::m_rank;
variable m_run_type
Run type (startup/continue/branch)
int emulator::EmulatorComp::m_run_type;
variable m_step_count
Number of steps executed.
int emulator::EmulatorComp::m_step_count;
variable m_type
Component type enum.
CompType emulator::EmulatorComp::m_type;
Protected Functions Documentation
function export_to_coupler
Export fields to coupler (override as needed).
inline virtual void emulator::EmulatorComp::export_to_coupler ()
function final_impl
Component-specific finalization.
virtual void emulator::EmulatorComp::final_impl () = 0
function import_from_coupler
Import fields from coupler (override as needed).
inline virtual void emulator::EmulatorComp::import_from_coupler ()
function init_impl
Component-specific initialization.
virtual void emulator::EmulatorComp::init_impl () = 0
function run_impl
Component-specific time step execution.
virtual void emulator::EmulatorComp::run_impl (
int dt
) = 0
function run_inference
Run AI inference on packed input/output vectors.
virtual void emulator::EmulatorComp::run_inference (
const std::vector< double > & inputs,
std::vector< double > & outputs
) = 0
Parameters:
inputsPacked input featuresoutputsPacked output features (will be resized as needed)
The documentation for this class was generated from the following file components/emulator_comps/common/src/emulator_comp.hpp