bes  Updated for version 3.20.8
FONcArray.h
1 // FONcArray.h
2 
3 // This file is part of BES Netcdf File Out Module
4 
5 // Copyright (c) 2004,2005 University Corporation for Atmospheric Research
6 // Author: Patrick West <pwest@ucar.edu> and Jose Garcia <jgarcia@ucar.edu>
7 //
8 // This library is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU Lesser General Public
10 // License as published by the Free Software Foundation; either
11 // version 2.1 of the License, or (at your option) any later version.
12 //
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Lesser General Public License for more details.
17 //
18 // You should have received a copy of the GNU Lesser General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 //
22 // You can contact University Corporation for Atmospheric Research at
23 // 3080 Center Green Drive, Boulder, CO 80301
24 
25 // (c) COPYRIGHT University Corporation for Atmospheric Research 2004-2005
26 // Please read the full copyright statement in the file COPYRIGHT_UCAR.
27 //
28 // Authors:
29 // pwest Patrick West <pwest@ucar.edu>
30 // jgarcia Jose Garcia <jgarcia@ucar.edu>
31 
32 #ifndef FONcArray_h_
33 #define FONcArray_h_ 1
34 
35 #include <vector>
36 #include <string>
37 #include "AttrTable.h"
38 
39 #include "FONcBaseType.h"
40 
41 class FONcDim;
42 class FONcMap;
43 
44 namespace libdap {
45 class BaseType;
46 class Array;
47 }
48 
55 class FONcArray: public FONcBaseType {
56 private:
57  // The array being converted
58  libdap::Array * d_a;
59  // The type of data stored in the array
60  nc_type d_array_type;
61  // The number of dimensions to be stored in netcdf (if string, 2)
62  int d_ndims;
63  // The actual number of dimensions of this array (if string, 1)
64  int d_actual_ndims;
65  // The number of elements that will be stored in netcdf
66  int d_nelements;
67  // The FONcDim dimensions to be used for this variable
68  std::vector<FONcDim *> d_dims;
69  // The netcdf dimension ids for this array from DAP4
70  std::vector<int> d4_dim_ids;
71  std::vector<bool>use_d4_dim_ids;
72  std::vector<int> d4_rbs_nums;
73  //std::vector<int> d4_rbs_nums_visited;
74 
75  // The netcdf dimension ids for this array
76  std::vector<int> d_dim_ids;
77  // The netcdf dimension sizes to be written
78  //size_t * d_dim_sizes; // changed int to size_t. jhrg 12.27.2011
79  std::vector<size_t> d_dim_sizes;
80  // If string data, we need to do some comparison, so instead of
81  // reading it more than once, read it once and save here
82  std::vector<std::string> d_str_data;
83 
84  // If the array is already a map in a grid, then we don't want to
85  // define it or write it.
86  bool d_dont_use_it;
87 
88  // Make this a vector<> jhrg 10/12/15
89  // The netcdf chunk sizes for each dimension of this array.
90  std::vector<size_t> d_chunksizes;
91 
92  // This is vector holds instances of FONcMap* that wrap existing Array
93  // objects that are pushed onto the global FONcGrid::Maps vector. These
94  // are hand made reference counting pointers. I'm not sure we need to
95  // store copies in this object, but it may be the case that without
96  // calling the FONcMap->decref() method they are not deleted. jhrg 8/28/13
97  std::vector<FONcMap*> d_grid_maps;
98 
99  // if DAP4 dim. is defined
100  bool d4_def_dim;
101  FONcDim * find_dim(std::vector<std::string> &embed, const std::string &name, int size, bool ignore_size = false);
102 
103  void write_for_nc4_types(int ncid);
104 
105 public:
106  FONcArray(libdap::BaseType *b);
107  FONcArray(libdap::BaseType *b,const std::vector<int>&dim_ids,const std::vector<bool>&use_dim_ids,const std::vector<int>&rbs_nums);
108  virtual ~FONcArray();
109 
110  virtual void convert(std::vector<std::string> embed,bool is_dap4_group=false);
111  virtual void define(int ncid);
112  virtual void write(int ncid);
113 
114  virtual std::string name();
115  virtual libdap::Array *array()
116  {
117  return d_a;
118  }
119 
120  virtual void dump(std::ostream &strm) const;
121 
122  static std::vector<FONcDim *> Dimensions;
123  static libdap::AttrType getAttrType(nc_type t);
124 };
125 
126 #endif // FONcArray_h_
127 
A DAP Array with file out netcdf information included.
Definition: FONcArray.h:55
virtual void define(int ncid)
define the DAP Array in the netcdf file
Definition: FONcArray.cc:342
virtual void convert(std::vector< std::string > embed, bool is_dap4_group=false)
Converts the DAP Array to a FONcArray.
Definition: FONcArray.cc:132
virtual std::string name()
returns the name of the DAP Array
Definition: FONcArray.cc:666
virtual void dump(std::ostream &strm) const
dumps information about this object for debugging purposes
Definition: FONcArray.cc:679
virtual ~FONcArray()
Destructor that cleans up the array.
Definition: FONcArray.cc:101
virtual void write(int ncid)
Write the array out to the netcdf file.
Definition: FONcArray.cc:473
A DAP BaseType with file out netcdf information included.
Definition: FONcBaseType.h:61
A class that represents the dimension of an array.
Definition: FONcDim.h:45
A map of a DAP Grid with file out netcdf information included.
Definition: FONcMap.h:52