20 #include "atlas/util/Object.h" 22 #include "atlas/array.h" 23 #include "atlas/array/ArrayUtil.h" 24 #include "atlas/array/DataType.h" 25 #include "atlas/util/Metadata.h" 28 class Parametrisation;
43 static FieldImpl* create(
const eckit::Parametrisation& );
53 template <
typename DATATYPE>
61 template <
typename DATATYPE>
66 template <
typename DATATYPE>
94 void*
storage() {
return array_->storage(); }
100 const std::string& name()
const;
103 void rename(
const std::string& name ) { metadata().set(
"name", name ); }
115 const std::vector<int>&
shapef()
const {
return array_->shapef(); }
118 const std::vector<int>&
stridesf()
const {
return array_->stridesf(); }
133 size_t size()
const {
return array_->size(); }
139 size_t bytes()
const {
return array_->bytes(); }
142 friend std::ostream& operator<<( std::ostream& os,
const FieldImpl& v );
145 void dump( std::ostream& os )
const;
149 void set_variables(
idx_t n ) { metadata().set(
"variables", n ); }
150 idx_t levels()
const {
return metadata().get<
idx_t>(
"levels" ); }
151 idx_t variables()
const {
return metadata().get<
idx_t>(
"variables" ); }
157 size_t footprint()
const;
161 void set_dirty(
bool =
true )
const;
164 template <
typename DATATYPE>
165 DATATYPE
const* host_data()
const {
166 return array_->host_data<DATATYPE>();
168 template <
typename DATATYPE>
169 DATATYPE* host_data() {
170 return array_->host_data<DATATYPE>();
172 template <
typename DATATYPE>
173 DATATYPE
const* device_data()
const {
174 return array_->device_data<DATATYPE>();
176 template <
typename DATATYPE>
177 DATATYPE* device_data() {
178 return array_->device_data<DATATYPE>();
180 template <
typename DATATYPE>
181 DATATYPE
const* data()
const {
182 return array_->host_data<DATATYPE>();
184 template <
typename DATATYPE>
186 return array_->host_data<DATATYPE>();
191 void updateHost()
const { array_->updateHost(); }
192 void updateDevice()
const { array_->updateDevice(); }
193 void syncHostDevice()
const { array_->syncHostDevice(); }
194 bool hostNeedsUpdate()
const {
return array_->hostNeedsUpdate(); }
195 bool deviceNeedsUpdate()
const {
return array_->deviceNeedsUpdate(); }
196 void reactivateDeviceWriteViews()
const { array_->reactivateDeviceWriteViews(); }
197 void reactivateHostWriteViews()
const { array_->reactivateHostWriteViews(); }
199 void haloExchange(
bool on_device =
false )
const;
200 void adjointHaloExchange(
bool on_device =
false )
const;
203 void callbackOnDestruction( std::function<
void()>&& f ) { callback_on_destruction_.emplace_back( std::move( f ) ); }
206 void print( std::ostream& os,
bool dump =
false )
const;
209 mutable std::string name_;
213 std::vector<std::function<void()>> callback_on_destruction_;
218 template <
typename DATATYPE>
220 return create( name, array::DataType::create<DATATYPE>(), shape );
223 template <
typename DATATYPE>
225 FieldImpl* wrapped = create( name, array::Array::wrap( data, spec ) );
226 wrapped->set_dirty(
false );
230 template <
typename DATATYPE>
232 FieldImpl* wrapped = create( name, array::Array::wrap( data, shape ) );
233 wrapped->set_dirty(
false );
array::DataType datatype() const
Internal data type of field.
Definition: FieldImpl.h:97
void * storage()
Access to raw data.
Definition: FieldImpl.h:94
Definition: ArrayShape.h:33
idx_t shape(idx_t i) const
Shape of this field associated to index 'i'.
Definition: FieldImpl.h:127
const array::ArrayStrides & strides() const
Strides of this field.
Definition: FieldImpl.h:124
const std::vector< int > & stridesf() const
Strides of this field in Fortran style (reverse order of C style)
Definition: FieldImpl.h:118
Definition: ArraySpec.h:27
const util::Metadata & metadata() const
Access to metadata associated to this field.
Definition: FieldImpl.h:106
Definition: ArrayStrides.h:23
void set_levels(idx_t n)
Metadata that is more intrinsic to the Field, and queried often.
Definition: FieldImpl.h:148
idx_t stride(idx_t i) const
Stride of this field associated to index 'i'.
Definition: FieldImpl.h:130
Definition: DataType.h:40
size_t bytes() const
Number of bytes occupied by the values of this field.
Definition: FieldImpl.h:139
size_t size() const
Number of values stored in this field.
Definition: FieldImpl.h:133
idx_t rank() const
Rank of field.
Definition: FieldImpl.h:136
const std::vector< int > & shapef() const
Shape of this field in Fortran style (reverse order of C style)
Definition: FieldImpl.h:115
Contains all atlas classes and methods.
Definition: atlas-grids.cc:33
void rename(const std::string &name)
Rename this field.
Definition: FieldImpl.h:103
Definition: FieldImpl.h:40
long idx_t
Integer type for indices in connectivity tables.
Definition: config.h:42
const array::ArrayShape & shape() const
Shape of this field (reverse order of Fortran style)
Definition: FieldImpl.h:121
Definition: FunctionSpace.h:39