bes Updated for version 3.20.13
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
38#include <libdap/AttrTable.h>
39#include <libdap/D4Attributes.h>
40
41#include "FONcBaseType.h"
42
43class FONcDim;
44class FONcMap;
45
46namespace libdap {
47class BaseType;
48class Array;
49}
50
57class FONcArray: public FONcBaseType {
58private:
59 // The array being converted
60 libdap::Array *d_a;
61 // The type of data stored in the array
62 nc_type d_array_type;
63 // The number of dimensions to be stored in netcdf (if string, 2)
64 int d_ndims;
65 // The actual number of dimensions of this array (if string, 1)
66 int d_actual_ndims;
67 // The number of elements that will be stored in netcdf
68 int d_nelements;
69 // The FONcDim dimensions to be used for this variable
70 std::vector<FONcDim *> d_dims;
71 // The netcdf dimension ids for this array from DAP4
72 std::vector<int> d4_dim_ids;
73 std::vector<bool>use_d4_dim_ids;
74 std::vector<int> d4_rds_nums;
75 //std::vector<int> d4_rds_nums_visited;
76
77 // The netcdf dimension ids for this array
78 std::vector<int> d_dim_ids;
79 // The netcdf dimension sizes to be written
80 //size_t * d_dim_sizes; // changed int to size_t. jhrg 12.27.2011
81 std::vector<size_t> d_dim_sizes;
82 // If string data, we need to do some comparison, so instead of
83 // reading it more than once, read it once and save here
84 // FIXME std::vector<std::string> d_str_data;
85
86 // If the array is already a map in a grid, then we don't want to
87 // define it or write it.
88 bool d_dont_use_it;
89
90 // Make this a vector<> jhrg 10/12/15
91 // The netcdf chunk sizes for each dimension of this array.
92 std::vector<size_t> d_chunksizes;
93
94 // This is vector holds instances of FONcMap* that wrap existing Array
95 // objects that are pushed onto the global FONcGrid::Maps vector. These
96 // are hand made reference counting pointers. I'm not sure we need to
97 // store copies in this object, but it may be the case that without
98 // calling the FONcMap->decref() method they are not deleted. jhrg 8/28/13
99 std::vector<FONcMap*> d_grid_maps;
100
101 // if DAP4 dim. is defined
102 bool d4_def_dim;
103 FONcDim * find_dim(std::vector<std::string> &embed, const std::string &name, int size, bool ignore_size = false);
104
105 void write_for_nc4_types(int ncid);
106
107 // Used in write()
108 void write_nc_variable(int ncid, nc_type var_type);
109
110public:
111 explicit FONcArray(libdap::BaseType *b);
112 FONcArray(libdap::BaseType *b,const std::vector<int>&dim_ids,const std::vector<bool>&use_dim_ids,const std::vector<int>&rds_nums);
113 virtual ~FONcArray() override;
114
115 virtual void convert(std::vector<std::string> embed, bool _dap4=false, bool is_dap4_group=false) override;
116 virtual void define(int ncid) override;
117 virtual void write(int ncid)override ;
118
119 std::string name() override;
120 virtual libdap::Array *array()
121 {
122 return d_a;
123 }
124
125 virtual void dump(std::ostream &strm) const override;
126 // The below line is not necessary. Still keep it here for the future use.
127 // KY 2021-05-25
128#if 0
129 virtual libdap::AttrType getAttrType(nc_type nct) override;
130#endif
131
132 static std::vector<FONcDim *> Dimensions;
133};
134
135#endif // FONcArray_h_
136
A DAP Array with file out netcdf information included.
Definition: FONcArray.h:57
virtual void dump(std::ostream &strm) const override
dumps information about this object for debugging purposes
Definition: FONcArray.cc:774
virtual void define(int ncid) override
define the DAP Array in the netcdf file
Definition: FONcArray.cc:394
virtual ~FONcArray() override
Destructor that cleans up the array.
Definition: FONcArray.cc:110
virtual void convert(std::vector< std::string > embed, bool _dap4=false, bool is_dap4_group=false) override
Converts the DAP Array to a FONcArray.
Definition: FONcArray.cc:140
virtual void write(int ncid) override
Write the array out to the netcdf file.
Definition: FONcArray.cc:594
std::string name() override
returns the name of the DAP Array
Definition: FONcArray.cc:762
A DAP BaseType with file out netcdf information included.
Definition: FONcBaseType.h:60
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