Skip to content

Commit 6cc351e

Browse files
committed
EAMxx: switch from ekat::enable_shared_from_this to the std version
1 parent e0a7882 commit 6cc351e

File tree

11 files changed

+13
-43
lines changed

11 files changed

+13
-43
lines changed

components/eamxx/src/dynamics/homme/homme_grids_manager.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,6 @@ void HommeGridsManager::build_dynamics_grid () {
147147
const int nlev = get_nlev_f90();
148148

149149
auto dyn_grid = std::make_shared<SEGrid>("dynamics",nlelem,HOMMEXX_NP,nlev,m_comm);
150-
dyn_grid->setSelfPointer(dyn_grid);
151150

152151
const auto layout2d = dyn_grid->get_2d_scalar_layout();
153152
const Units rad (Units::nondimensional(),"rad");
@@ -215,7 +214,6 @@ build_physics_grid (const ci_string& type, const ci_string& rebalance) {
215214
const int nlcols = get_num_local_columns_f90 (pg_code % 10);
216215

217216
auto phys_grid = std::make_shared<PointGrid>(name,nlcols,nlev,m_comm);
218-
phys_grid->setSelfPointer(phys_grid);
219217

220218
// Create the gids, coords, area views
221219
using namespace ShortFieldTagsNames;

components/eamxx/src/share/atm_process/atmosphere_diagnostic.hpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,7 @@ using AtmosphereDiagnosticFactory =
9494
template <typename AtmDiagType>
9595
inline std::shared_ptr<AtmosphereDiagnostic>
9696
create_atmosphere_diagnostic (const ekat::Comm& comm, const ekat::ParameterList& p) {
97-
auto ptr = std::make_shared<AtmDiagType>(comm,p);
98-
ptr->setSelfPointer(ptr);
99-
return ptr;
97+
return std::make_shared<AtmDiagType>(comm,p);
10098
}
10199
} //namespace scream
102100

components/eamxx/src/share/atm_process/atmosphere_process.hpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@
1717
#include <ekat_parameter_list.hpp>
1818
#include <ekat_factory.hpp>
1919
#include <ekat_string_utils.hpp>
20-
#include <ekat_std_enable_shared_from_this.hpp>
2120
#include <ekat_logger.hpp>
2221

2322
#include <memory>
2423
#include <string>
2524
#include <set>
25+
#include <any>
2626
#include <list>
2727

2828
namespace scream
@@ -69,7 +69,7 @@ namespace scream
6969
* to override the get_internal_fields method.
7070
*/
7171

72-
class AtmosphereProcess : public ekat::enable_shared_from_this<AtmosphereProcess>
72+
class AtmosphereProcess : public std::enable_shared_from_this<AtmosphereProcess>
7373
{
7474
public:
7575
using TimeStamp = util::TimeStamp;
@@ -657,9 +657,7 @@ using AtmosphereProcessFactory =
657657
template <typename AtmProcType>
658658
inline std::shared_ptr<AtmosphereProcess>
659659
create_atmosphere_process (const ekat::Comm& comm, const ekat::ParameterList& p) {
660-
auto ptr = std::make_shared<AtmProcType>(comm,p);
661-
ptr->setSelfPointer(ptr);
662-
return ptr;
660+
return std::make_shared<AtmProcType>(comm,p);
663661
}
664662

665663
} // namespace scream

components/eamxx/src/share/field/field.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@ namespace scream
66

77
Field::
88
Field (const identifier_type& id)
9-
: m_header (create_header(id))
109
{
11-
// Nothing to do here
10+
m_header = std::make_shared<FieldHeader>(id);
1211
}
1312

1413
Field

components/eamxx/src/share/field/field_header.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ namespace scream {
66

77
FieldHeader::FieldHeader (const identifier_type& id)
88
: m_identifier (id)
9-
, m_tracking (create_tracking())
109
{
10+
m_tracking = std::make_shared<FieldTracking>();
1111
m_alloc_prop = std::make_shared<FieldAllocProp>(get_type_size(id.data_type()));
1212
m_extra_data = std::make_shared<extra_data_type>();
1313

@@ -33,7 +33,7 @@ set_extra_data (const std::string& key,
3333
}
3434

3535
std::shared_ptr<FieldHeader> FieldHeader::alias(const std::string& name) const {
36-
auto fh = create_header(get_identifier().alias(name));
36+
auto fh = std::make_shared<FieldHeader>(get_identifier().alias(name));
3737
fh->m_tracking = m_tracking;
3838
fh->m_alloc_prop = m_alloc_prop;
3939
fh->m_extra_data = m_extra_data;
@@ -72,11 +72,11 @@ create_subfield_header (const FieldIdentifier& id,
7272
"Error! Invalid pointer for parent header.\n");
7373

7474
// Create header, and set up parent/child
75-
auto fh = create_header(id);
75+
auto fh = std::make_shared<FieldHeader>(id);
7676
fh->create_parent_child_link(parent);
7777

7878
// Create tracking, and set up parent/child
79-
fh->m_tracking = create_tracking();
79+
fh->m_tracking = std::make_shared<FieldTracking>();
8080
fh->m_tracking->create_parent_child_link(parent->get_tracking_ptr());
8181
if (parent->get_tracking().get_time_stamp().is_valid()) {
8282
fh->m_tracking->update_time_stamp(parent->get_tracking().get_time_stamp());
@@ -100,11 +100,11 @@ create_subfield_header(const FieldIdentifier& id,
100100
"Error! Slice indices are invalid (non-increasing).\n");
101101

102102
// Create header, and set up parent/child
103-
auto fh = create_header(id);
103+
auto fh = std::make_shared<FieldHeader>(id);
104104
fh->create_parent_child_link(parent);
105105

106106
// Create tracking, and set up parent/child
107-
fh->m_tracking = create_tracking();
107+
fh->m_tracking = std::make_shared<FieldTracking>();
108108
fh->m_tracking->create_parent_child_link(parent->get_tracking_ptr());
109109
if (parent->get_tracking().get_time_stamp().is_valid()) {
110110
fh->m_tracking->update_time_stamp(parent->get_tracking().get_time_stamp());

components/eamxx/src/share/field/field_header.hpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -161,15 +161,6 @@ has_extra_data (const std::string& key) const
161161
return m_extra_data->find(key)!=m_extra_data->end();
162162
}
163163

164-
// Use this free function to exploit features of enable_from_this
165-
template<typename... Args>
166-
inline std::shared_ptr<FieldHeader>
167-
create_header(const Args&... args) {
168-
auto ptr = std::make_shared<FieldHeader>(args...);
169-
ptr->setSelfPointer(ptr);
170-
return ptr;
171-
}
172-
173164
// Use this free function to create a header for a field that
174165
// is the subfield of another field, that is, for something
175166
// that (in matlab syntax) looks like sf = f(:,1,:)

components/eamxx/src/share/field/field_tracking.hpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -93,17 +93,6 @@ class FieldTracking : public FamilyTracking<FieldTracking> {
9393
ekat::WeakPtrSet<const FieldGroupInfo> m_groups;
9494
};
9595

96-
// Use this free function to exploit features of enable_shared_from_this,
97-
// as well as features from FamilyTracking.
98-
template<typename... Args>
99-
inline std::shared_ptr<FieldTracking>
100-
create_tracking(const Args&... args) {
101-
auto ptr = std::make_shared<FieldTracking>(args...);
102-
ptr->setSelfPointer(ptr);
103-
return ptr;
104-
}
105-
106-
10796
} // namespace scream
10897

10998
#endif // SCREAM_FIELD_TRACKING_HPP

components/eamxx/src/share/grid/abstract_grid.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ namespace scream
3838
* like spatial dimension or "physical" rank.
3939
*/
4040

41-
class AbstractGrid : public ekat::enable_shared_from_this<AbstractGrid>
41+
class AbstractGrid : public std::enable_shared_from_this<AbstractGrid>
4242
{
4343
public:
4444
// TODO: use int64_t? int? template class on gid_type?

components/eamxx/src/share/grid/mesh_free_grids_manager.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ build_se_grid (const std::string& name, ekat::ParameterList& params)
6868
// Create the grid
6969
std::shared_ptr<SEGrid> se_grid;
7070
se_grid = std::make_shared<SEGrid>(name,num_local_elems,num_gp,num_vertical_levels,m_comm);
71-
se_grid->setSelfPointer(se_grid);
7271

7372
// Set up the degrees of freedom.
7473
auto dof_gids = se_grid->get_dofs_gids();

components/eamxx/src/share/grid/point_grid.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,6 @@ create_point_grid (const std::string& grid_name,
160160
}
161161

162162
auto grid = std::make_shared<PointGrid>(grid_name,num_my_cols,num_vertical_lev,comm);
163-
grid->setSelfPointer(grid);
164163

165164
auto dofs_gids = grid->get_dofs_gids();
166165
auto h_dofs_gids = dofs_gids.get_view<AbstractGrid::gid_type*,Host>();

0 commit comments

Comments
 (0)