Skip to content

Commit

Permalink
Make deep_copy const
Browse files Browse the repository at this point in the history
  • Loading branch information
tcclevenger committed Oct 4, 2024
1 parent c265fb5 commit e5e8a10
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions components/eamxx/src/share/field/field.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,11 +198,11 @@ class Field {

// Set the field to a constant value (on host or device)
template<typename T, HostOrDevice HD = Device>
void deep_copy (const T value);
void deep_copy (const T value) const;

// Copy the data from one field to this field
template<HostOrDevice HD = Device>
void deep_copy (const Field& src);
void deep_copy (const Field& src) const;

// Updates this field y as y=alpha*x+beta*y
// NOTE: ST=void is just so we can give a default to HD,
Expand Down Expand Up @@ -314,10 +314,10 @@ class Field {
void sync_views_impl () const;

template<HostOrDevice HD, typename ST>
void deep_copy_impl (const ST value);
void deep_copy_impl (const ST value) const;

template<HostOrDevice HD, typename ST>
void deep_copy_impl (const Field& src);
void deep_copy_impl (const Field& src) const;

template<CombineMode CM, HostOrDevice HD, typename ST>
void update_impl (const Field& x, const ST alpha, const ST beta, const ST fill_val);
Expand Down
8 changes: 4 additions & 4 deletions components/eamxx/src/share/field/field_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ void Field::sync_views_impl () const {

template<HostOrDevice HD>
void Field::
deep_copy (const Field& src) {
deep_copy (const Field& src) const {
EKAT_REQUIRE_MSG (not m_is_read_only,
"Error! Cannot call deep_copy on read-only fields.\n");

Expand All @@ -350,7 +350,7 @@ deep_copy (const Field& src) {

template<typename ST, HostOrDevice HD>
void Field::
deep_copy (const ST value) {
deep_copy (const ST value) const {
EKAT_REQUIRE_MSG (not m_is_read_only,
"Error! Cannot call deep_copy on read-only fields.\n");

Expand Down Expand Up @@ -384,7 +384,7 @@ deep_copy (const ST value) {

template<HostOrDevice HD, typename ST>
void Field::
deep_copy_impl (const Field& src) {
deep_copy_impl (const Field& src) const {

const auto& layout = get_header().get_identifier().get_layout();
const auto& layout_src = src.get_header().get_identifier().get_layout();
Expand Down Expand Up @@ -528,7 +528,7 @@ deep_copy_impl (const Field& src) {
}

template<HostOrDevice HD, typename ST>
void Field::deep_copy_impl (const ST value) {
void Field::deep_copy_impl (const ST value) const {

// Note: we can't just do a deep copy on get_view_impl<HD>(), since this
// field might be a subfield of another. Instead, get the
Expand Down

0 comments on commit e5e8a10

Please sign in to comment.