Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add procedure to include metadata in FieldSet #126

Merged
merged 2 commits into from
Apr 21, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/atlas/field/FieldSet.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* (C) Copyright 2013 ECMWF.
* (C) Copyright 2013-2023 ECMWF.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not necessary to add "2023" (here and other file). We assume an open-ended approach.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... done

*
* This software is licensed under the terms of the Apache Licence Version 2.0
* which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
Expand Down Expand Up @@ -152,6 +152,14 @@ FieldSet::FieldSet(const Field& field): Handle(new Implementation()) {
get()->add(field);
}

const util::Metadata& FieldSet::metadata() const {
return get()->metadata();
}

util::Metadata& FieldSet::metadata() {
return get()->metadata();
}

void FieldSet::set_dirty(bool value) const {
get()->set_dirty(value);
}
Expand Down
10 changes: 9 additions & 1 deletion src/atlas/field/FieldSet.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* (C) Copyright 2013 ECMWF.
* (C) Copyright 2013-2023 ECMWF.
*
* This software is licensed under the terms of the Apache Licence Version 2.0
* which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
Expand Down Expand Up @@ -27,6 +27,7 @@
#include "atlas/field/Field.h"
#include "atlas/library/config.h"
#include "atlas/runtime/Exception.h"
#include "atlas/util/Metadata.h"
#include "atlas/util/Object.h"
#include "atlas/util/ObjectHandle.h"

Expand Down Expand Up @@ -112,13 +113,17 @@ class FieldSetImpl : public util::Object {
const_iterator cbegin() const { return fields_.begin(); }
const_iterator cend() const { return fields_.end(); }

const util::Metadata& metadata() const { return metadata_; }
util::Metadata& metadata() { return metadata_; }

void haloExchange(bool on_device = false) const;
void adjointHaloExchange(bool on_device = false) const;
void set_dirty(bool = true) const;

protected: // data
std::vector<Field> fields_; ///< field storage
std::string name_; ///< internal name
util::Metadata metadata_; ///< metadata associated with the FieldSet
std::map<std::string, idx_t> index_; ///< name-to-index map, to refer fields by name
};

Expand Down Expand Up @@ -209,6 +214,9 @@ class FieldSet : DOXYGEN_HIDE(public util::ObjectHandle<field::FieldSetImpl>) {
const_iterator cbegin() const { return get()->begin(); }
const_iterator cend() const { return get()->end(); }

const util::Metadata& metadata() const;
util::Metadata& metadata();

void haloExchange(bool on_device = false) const { get()->haloExchange(on_device); }
void set_dirty(bool = true) const;

Expand Down