Skip to content

Commit

Permalink
EAMxx: refactor SPA to use DataInterpolation
Browse files Browse the repository at this point in the history
Also remove the unit tests, since SPA is simply a wrapper
of a DataInterpolation instance
  • Loading branch information
bartgol committed Jan 21, 2025
1 parent 2ae78e6 commit 7aabbe9
Show file tree
Hide file tree
Showing 10 changed files with 85 additions and 1,826 deletions.
4 changes: 0 additions & 4 deletions components/eamxx/src/physics/spa/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,5 @@ add_library(spa eamxx_spa_process_interface.cpp)
target_compile_definitions(spa PUBLIC EAMXX_HAS_SPA)
target_link_libraries(spa physics_share scream_share)

if (NOT SCREAM_LIB_ONLY)
add_subdirectory(tests)
endif()

# Add this library to eamxx_physics
target_link_libraries(eamxx_physics INTERFACE spa)
283 changes: 80 additions & 203 deletions components/eamxx/src/physics/spa/eamxx_spa_process_interface.cpp

Large diffs are not rendered by default.

59 changes: 5 additions & 54 deletions components/eamxx/src/physics/spa/eamxx_spa_process_interface.hpp
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
#ifndef SCREAM_PRESCRIBED_AEROSOL_HPP
#define SCREAM_PRESCRIBED_AEROSOL_HPP

#include "physics/spa/spa_functions.hpp"
#include "share/atm_process/atmosphere_process.hpp"
#include "share/io/scorpio_input.hpp"
#include "share/grid/remap/abstract_remapper.hpp"
#include <ekat/ekat_parameter_list.hpp>

#include <string>

namespace scream
{

class DataInterpolation;

/*
* The class responsible to handle the calculation of the subgrid cloud fractions
*
Expand All @@ -22,16 +18,6 @@ namespace scream
class SPA : public AtmosphereProcess
{
public:
using SPAFunc = spa::SPAFunctions<Real, DefaultDevice>;
using Spack = SPAFunc::Spack;
using KT = ekat::KokkosTypes<DefaultDevice>;

using view_1d = typename SPAFunc::view_1d<Spack>;
using view_2d = typename SPAFunc::view_2d<Spack>;

template<typename ScalarT>
using uview_2d = Unmanaged<typename KT::template view_2d<ScalarT>>;

// Constructors
SPA (const ekat::Comm& comm, const ekat::ParameterList& params);

Expand All @@ -44,51 +30,16 @@ class SPA : public AtmosphereProcess
// Set the grid
void set_grids (const std::shared_ptr<const GridsManager> grids_manager);

// Structure for storing local variables initialized using the ATMBufferManager
struct Buffer {
// Used to store temporary data during spa_main
SPAFunc::SPAInput spa_temp;

// Temporary to use
uview_2d<Spack> p_mid_src;
};
protected:

// The three main overrides for the subcomponent
void initialize_impl (const RunType run_type);
void initialize_spa_impl ();
void run_impl (const double dt);
void finalize_impl ();

// Computes total number of bytes needed for local variables
size_t requested_buffer_size_in_bytes() const;

// Set local variables using memory provided by
// the ATMBufferManager
void init_buffers(const ATMBufferManager &buffer_manager);

// Keep track of field dimensions and the iteration count
int m_num_cols;
int m_num_levs;
int m_num_src_levs;
int m_nswbands = 14;
int m_nlwbands = 16;

// Struct which contains temporary variables used during spa_main
Buffer m_buffer;

// IO structure to read in data for standard grids (keep it around to avoid re-creating PIO decomps)
std::shared_ptr<AtmosphereInput> SPADataReader;

// Structures to store the data used for interpolation
std::shared_ptr<AbstractRemapper> SPAHorizInterp;
void finalize_impl () { /* Nothing to do */ }

SPAFunc::SPATimeState SPATimeState;
SPAFunc::SPAInput SPAData_start;
SPAFunc::SPAInput SPAData_end;
SPAFunc::SPAOutput SPAData_out;
std::shared_ptr<const AbstractGrid> m_model_grid;

std::shared_ptr<const AbstractGrid> m_grid;
std::shared_ptr<DataInterpolation> m_data_interpolation;
}; // class SPA

} // namespace scream
Expand Down
216 changes: 0 additions & 216 deletions components/eamxx/src/physics/spa/spa_functions.hpp

This file was deleted.

Loading

0 comments on commit 7aabbe9

Please sign in to comment.