[219] | 1 | #ifndef __XMLIO_INETCDF4__ |
---|
| 2 | #define __XMLIO_INETCDF4__ |
---|
| 3 | |
---|
[335] | 4 | /// xios headers /// |
---|
[219] | 5 | #include "xmlioserver_spl.hpp" |
---|
| 6 | #include "exception.hpp" |
---|
[369] | 7 | #include "array_new.hpp" |
---|
[219] | 8 | |
---|
[382] | 9 | #include "mpi.hpp" |
---|
| 10 | #include "netcdf.hpp" |
---|
[219] | 11 | |
---|
| 12 | #ifndef UNLIMITED_DIM |
---|
| 13 | #define UNLIMITED_DIM (size_t)(-1) |
---|
| 14 | #endif //UNLIMITED_DIM |
---|
| 15 | |
---|
[335] | 16 | namespace xios |
---|
[219] | 17 | { |
---|
| 18 | /// ////////////////////// Déclarations ////////////////////// /// |
---|
| 19 | typedef std::vector<StdString> CVarPath; |
---|
| 20 | |
---|
| 21 | class CINetCDF4 |
---|
| 22 | { |
---|
| 23 | public : |
---|
| 24 | |
---|
| 25 | /// Constructeurs /// |
---|
| 26 | CINetCDF4(void); // Not implemented. |
---|
| 27 | CINetCDF4(const StdString & filename); |
---|
| 28 | CINetCDF4(const CINetCDF4 & inetcdf4); // Not implemented. |
---|
| 29 | CINetCDF4(const CINetCDF4 * const inetcdf4); // Not implemented. |
---|
| 30 | |
---|
| 31 | //------------------------------------------------------------- |
---|
| 32 | |
---|
| 33 | /// Accesseurs /// |
---|
| 34 | StdSize getNbOfTimestep(const CVarPath * const path = NULL); |
---|
| 35 | |
---|
| 36 | StdString getUnlimitedDimensionName(const CVarPath * const path = NULL); |
---|
| 37 | |
---|
| 38 | StdString getCoordinatesId(const StdString & name, |
---|
| 39 | const CVarPath * const path = NULL); |
---|
| 40 | |
---|
| 41 | StdString getBoundsId(const StdString & name, |
---|
| 42 | const CVarPath * const path = NULL); |
---|
| 43 | |
---|
| 44 | StdString getLonCoordName(const StdString & varname, |
---|
| 45 | const CVarPath * const path = NULL); |
---|
| 46 | StdString getLatCoordName(const StdString & varname, |
---|
| 47 | const CVarPath * const path = NULL); |
---|
| 48 | StdString getVertCoordName(const StdString & varname, |
---|
| 49 | const CVarPath * const path = NULL); |
---|
| 50 | |
---|
| 51 | std::set<StdString> getCoordVariables(const CVarPath * const path = NULL); |
---|
| 52 | std::set<StdString> getBoundVariables(const CVarPath * const path = NULL); |
---|
| 53 | |
---|
| 54 | std::list<StdString> getGroups (const CVarPath * const path = NULL); |
---|
| 55 | std::list<StdString> getVariables(const CVarPath * const path = NULL); |
---|
| 56 | |
---|
| 57 | std::list<StdString> getDataVariables(bool _is3D = true, |
---|
| 58 | bool _isRecti = true, |
---|
| 59 | bool _isCurvi = true, |
---|
| 60 | bool _isUnstr = true, |
---|
| 61 | bool _isCellData = true, |
---|
| 62 | bool _isTemporal = true, |
---|
| 63 | const CVarPath * const path = NULL); |
---|
| 64 | |
---|
| 65 | std::list<StdString> getAttributes |
---|
| 66 | (const StdString * const var = NULL, |
---|
| 67 | const CVarPath * const path = NULL); |
---|
| 68 | |
---|
| 69 | std::list<StdString> getDimensionsList |
---|
| 70 | (const StdString * const var = NULL, |
---|
| 71 | const CVarPath * const path = NULL); |
---|
| 72 | |
---|
| 73 | std::list<StdString> getCoordinatesIdList(const StdString & name, |
---|
| 74 | const CVarPath * const path = NULL); |
---|
| 75 | |
---|
| 76 | std::map<StdString, StdSize> getDimensions (const StdString * const var = NULL, |
---|
| 77 | const CVarPath * const path = NULL); |
---|
| 78 | |
---|
| 79 | StdSize getNbVertex(const StdString & name, |
---|
| 80 | const CVarPath * const path = NULL); |
---|
| 81 | //------------------------------------------------------------- |
---|
| 82 | |
---|
| 83 | template <class T> |
---|
| 84 | T getMissingValue(const StdString & name, |
---|
| 85 | const CVarPath * const path = NULL); |
---|
| 86 | |
---|
| 87 | template <class T> |
---|
| 88 | T getAttributeValue(const StdString & name, |
---|
| 89 | const StdString * const var = NULL, |
---|
| 90 | const CVarPath * const path = NULL); |
---|
| 91 | |
---|
| 92 | template <class T> |
---|
[369] | 93 | void getData(CArray<T, 1>& data, |
---|
[219] | 94 | const StdString & var, |
---|
| 95 | const CVarPath * const path = NULL, |
---|
| 96 | StdSize record = UNLIMITED_DIM); |
---|
| 97 | |
---|
| 98 | //------------------------------------------------------------- |
---|
| 99 | |
---|
| 100 | /// Tests /// |
---|
| 101 | bool hasMissingValue(const StdString & name, |
---|
| 102 | const CVarPath * const path = NULL); |
---|
| 103 | |
---|
| 104 | bool hasAttribute(const StdString & name, |
---|
| 105 | const StdString * const var = NULL, |
---|
| 106 | const CVarPath * const path = NULL); |
---|
| 107 | |
---|
| 108 | bool hasVariable(const StdString & name, |
---|
| 109 | const CVarPath * const path = NULL); |
---|
| 110 | |
---|
| 111 | bool hasCoordinates(const StdString & name, |
---|
| 112 | const CVarPath * const path = NULL); |
---|
| 113 | |
---|
| 114 | bool hasTemporalDim(const CVarPath * const path = NULL); |
---|
| 115 | |
---|
| 116 | bool hasBounds(const StdString & name, |
---|
| 117 | const CVarPath * const path = NULL); |
---|
| 118 | |
---|
| 119 | //------------------------------------------------------------- |
---|
| 120 | |
---|
| 121 | bool isBound(const StdString & name, |
---|
| 122 | const CVarPath * const path = NULL); |
---|
| 123 | bool isCoordinate(const StdString & name, |
---|
| 124 | const CVarPath * const path = NULL); |
---|
| 125 | bool isRectilinear(const StdString & name, |
---|
| 126 | const CVarPath * const path = NULL); |
---|
| 127 | bool isCurvilinear(const StdString & name, |
---|
| 128 | const CVarPath * const path = NULL); |
---|
| 129 | bool isUnknown(const StdString & name, |
---|
| 130 | const CVarPath * const path = NULL); |
---|
| 131 | bool isUnstructured(const StdString & name, |
---|
| 132 | const CVarPath * const path = NULL); |
---|
| 133 | |
---|
| 134 | bool isTemporal(const StdString & name, |
---|
| 135 | const CVarPath * const path = NULL); |
---|
| 136 | bool is3Dim(const StdString & name, |
---|
| 137 | const CVarPath * const path = NULL); |
---|
| 138 | bool isCellGrid(const StdString & name, |
---|
| 139 | const CVarPath * const path = NULL); |
---|
| 140 | |
---|
| 141 | //------------------------------------------------------------- |
---|
| 142 | |
---|
| 143 | /// Destructeur /// |
---|
| 144 | virtual ~CINetCDF4(void); |
---|
| 145 | |
---|
| 146 | protected : |
---|
| 147 | |
---|
| 148 | //------------------------------------------------------------- |
---|
| 149 | |
---|
| 150 | /// Accesseurs /// |
---|
| 151 | int getGroup (const CVarPath * const path = NULL); |
---|
| 152 | int getVariable(const StdString & varname, |
---|
| 153 | const CVarPath * const path = NULL); |
---|
| 154 | int getDimension(const StdString & dimname, |
---|
| 155 | const CVarPath * const path = NULL); |
---|
| 156 | int getUnlimitedDimension(const CVarPath * const path = NULL); |
---|
| 157 | int getAttributeId(const StdString & name, |
---|
| 158 | const StdString * const var = NULL, |
---|
| 159 | const CVarPath * const path = NULL); |
---|
| 160 | |
---|
| 161 | std::pair<nc_type , StdSize> getAttribute(const StdString & attname, |
---|
| 162 | const StdString * const var = NULL, |
---|
| 163 | const CVarPath * const path = NULL); |
---|
| 164 | |
---|
| 165 | //------------------------------------------------------------- |
---|
| 166 | |
---|
| 167 | void getDataInfo(const StdString & var, const CVarPath * const path, StdSize record, |
---|
| 168 | std::vector<StdSize> & start, std::vector<StdSize> & count, |
---|
| 169 | StdSize & array_size); |
---|
| 170 | |
---|
| 171 | private : |
---|
| 172 | |
---|
| 173 | /// Vérification des erreurs NetCDF /// |
---|
| 174 | static void CheckError(int status); |
---|
| 175 | |
---|
| 176 | int ncidp; // Identifiant de fichier netcdf. |
---|
| 177 | |
---|
| 178 | }; // class CINetCDF4 |
---|
| 179 | |
---|
| 180 | ///-------------------------------------------------------------- |
---|
| 181 | template <> |
---|
| 182 | StdString CINetCDF4::getAttributeValue |
---|
| 183 | (const StdString & name, const StdString * const var, |
---|
| 184 | const CVarPath * const path); |
---|
| 185 | |
---|
| 186 | template <> |
---|
| 187 | std::vector<double> CINetCDF4::getAttributeValue |
---|
| 188 | (const StdString & name, const StdString * const var, |
---|
| 189 | const CVarPath * const path); |
---|
| 190 | |
---|
| 191 | template <> |
---|
| 192 | std::vector<float> CINetCDF4::getAttributeValue |
---|
| 193 | (const StdString & name, const StdString * const var, |
---|
| 194 | const CVarPath * const path); |
---|
| 195 | |
---|
| 196 | template <> |
---|
| 197 | std::vector<int> CINetCDF4::getAttributeValue |
---|
| 198 | (const StdString & name, const StdString * const var, |
---|
| 199 | const CVarPath * const path); |
---|
| 200 | |
---|
| 201 | template <> |
---|
| 202 | std::vector<char> CINetCDF4::getAttributeValue |
---|
| 203 | (const StdString & name, const StdString * const var, |
---|
| 204 | const CVarPath * const path); |
---|
| 205 | |
---|
| 206 | //--------------------------------------------------------------- |
---|
| 207 | template <> |
---|
| 208 | int CINetCDF4::getMissingValue |
---|
| 209 | (const StdString & name, const CVarPath * const path); |
---|
| 210 | |
---|
| 211 | template <> |
---|
| 212 | double CINetCDF4::getMissingValue |
---|
| 213 | (const StdString & name, const CVarPath * const path); |
---|
| 214 | |
---|
| 215 | template <> |
---|
| 216 | float CINetCDF4::getMissingValue |
---|
| 217 | (const StdString & name, const CVarPath * const path); |
---|
| 218 | |
---|
| 219 | //--------------------------------------------------------------- |
---|
| 220 | template <> |
---|
[369] | 221 | void CINetCDF4::getData(CArray<int, 1>& data, const StdString & var, |
---|
[219] | 222 | const CVarPath * const path, StdSize record); |
---|
| 223 | |
---|
| 224 | template <> |
---|
[369] | 225 | void CINetCDF4::getData(CArray<double, 1>& data, const StdString & var, |
---|
[219] | 226 | const CVarPath * const path, StdSize record); |
---|
| 227 | |
---|
| 228 | template <> |
---|
[369] | 229 | void CINetCDF4::getData(CArray<float, 1>& data, const StdString & var, |
---|
[219] | 230 | const CVarPath * const path, StdSize record); |
---|
| 231 | ///-------------------------------------------------------------- |
---|
| 232 | |
---|
| 233 | } // namespace xmlioserver |
---|
| 234 | |
---|
| 235 | #endif //__XMLIO_INETCDF4__ |
---|