atlas
ArraySpec.h
1 /*
2  * (C) Copyright 2013 ECMWF.
3  *
4  * This software is licensed under the terms of the Apache Licence Version 2.0
5  * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
6  * In applying this licence, ECMWF does not waive the privileges and immunities
7  * granted to it by virtue of its status as an intergovernmental organisation
8  * nor does it submit to any jurisdiction.
9  */
10 
11 #pragma once
12 
13 #include <stddef.h>
14 #include <vector>
15 
16 #include "atlas/array/ArrayIdx.h"
17 #include "atlas/array/ArrayLayout.h"
18 #include "atlas/array/ArrayShape.h"
19 #include "atlas/array/ArrayStrides.h"
20 #include "atlas/library/config.h"
21 
22 //------------------------------------------------------------------------------------------------------
23 
24 namespace atlas {
25 namespace array {
26 
27 class ArraySpec {
28 private:
29  size_t size_;
30  idx_t rank_;
31  size_t allocated_size_;
32  ArrayShape shape_;
33  ArrayStrides strides_;
34  ArrayLayout layout_;
35  ArrayAlignment alignment_;
36  std::vector<int> shapef_;
37  std::vector<int> stridesf_;
38  bool contiguous_;
39  bool default_layout_;
40 
41 public:
42  ArraySpec();
43  ArraySpec( const ArrayShape& );
44  ArraySpec( const ArrayShape&, const ArrayStrides& );
45  ArraySpec( const ArrayShape&, const ArrayStrides&, const ArrayLayout& );
46  ArraySpec( const ArrayShape&, const ArrayAlignment& );
47  ArraySpec( const ArrayShape&, const ArrayStrides&, const ArrayAlignment& );
48  ArraySpec( const ArrayShape&, const ArrayStrides&, const ArrayLayout&, const ArrayAlignment& );
49  size_t allocatedSize() const { return allocated_size_; }
50  size_t size() const { return size_; }
51  idx_t rank() const { return rank_; }
52  const ArrayShape& shape() const { return shape_; }
53  const ArrayAlignment& alignment() const { return alignment_; }
54  const ArrayStrides& strides() const { return strides_; }
55  const ArrayLayout& layout() const { return layout_; }
56  const std::vector<int>& shapef() const;
57  const std::vector<int>& stridesf() const;
58  bool contiguous() const { return contiguous_; }
59  bool hasDefaultLayout() const { return default_layout_; }
60 
61 private:
62  void allocate_fortran_specs();
63 };
64 
65 //------------------------------------------------------------------------------------------------------
66 
67 } // namespace array
68 } // namespace atlas
Definition: ArrayShape.h:33
Definition: ArraySpec.h:27
Definition: ArrayShape.h:23
Definition: ArrayStrides.h:23
Contains all atlas classes and methods.
Definition: atlas-grids.cc:33
long idx_t
Integer type for indices in connectivity tables.
Definition: config.h:42
Definition: ArrayLayout.h:22