[219] | 1 | #include "nc4_data_output.hpp" |
---|
| 2 | |
---|
[352] | 3 | #include "attribute_template.hpp" |
---|
| 4 | #include "group_template.hpp" |
---|
[219] | 5 | |
---|
| 6 | #include "file.hpp" |
---|
| 7 | #include "calendar.hpp" |
---|
[278] | 8 | #include "context.hpp" |
---|
[300] | 9 | #include "context_server.hpp" |
---|
[498] | 10 | #include "netCdfException.hpp" |
---|
| 11 | #include "exception.hpp" |
---|
[1158] | 12 | #include "timer.hpp" |
---|
| 13 | #include "uuid.hpp" |
---|
[335] | 14 | namespace xios |
---|
[219] | 15 | { |
---|
[878] | 16 | /// ////////////////////// Dfinitions ////////////////////// /// |
---|
[219] | 17 | CNc4DataOutput::CNc4DataOutput |
---|
[1158] | 18 | (CFile* file, const StdString & filename, bool exist) |
---|
[219] | 19 | : SuperClass() |
---|
| 20 | , SuperClassWriter(filename, exist) |
---|
| 21 | , filename(filename) |
---|
[1158] | 22 | , file(file),hasTimeInstant(false),hasTimeCentered(false), timeCounterType(none) |
---|
[219] | 23 | { |
---|
[1158] | 24 | SuperClass::type = MULTI_FILE; |
---|
[1456] | 25 | compressionLevel= file->compression_level.isEmpty() ? 0 :file->compression_level ; |
---|
[219] | 26 | } |
---|
| 27 | |
---|
| 28 | CNc4DataOutput::CNc4DataOutput |
---|
[1158] | 29 | (CFile* file, const StdString & filename, bool exist, bool useClassicFormat, bool useCFConvention, |
---|
[924] | 30 | MPI_Comm comm_file, bool multifile, bool isCollective, const StdString& timeCounterName) |
---|
[219] | 31 | : SuperClass() |
---|
[878] | 32 | , SuperClassWriter(filename, exist, useClassicFormat, useCFConvention, &comm_file, multifile, timeCounterName) |
---|
[379] | 33 | , comm_file(comm_file) |
---|
[219] | 34 | , filename(filename) |
---|
[335] | 35 | , isCollective(isCollective) |
---|
[1158] | 36 | , file(file),hasTimeInstant(false),hasTimeCentered(false), timeCounterType(none) |
---|
[219] | 37 | { |
---|
[1158] | 38 | SuperClass::type = (multifile) ? MULTI_FILE : ONE_FILE; |
---|
[1459] | 39 | if (file==NULL) compressionLevel = 0 ; |
---|
| 40 | else compressionLevel= file->compression_level.isEmpty() ? 0 :file->compression_level ; |
---|
[219] | 41 | } |
---|
| 42 | |
---|
| 43 | CNc4DataOutput::~CNc4DataOutput(void) |
---|
[879] | 44 | { /* Ne rien faire de plus */ } |
---|
[219] | 45 | |
---|
| 46 | ///-------------------------------------------------------------- |
---|
| 47 | |
---|
| 48 | const StdString & CNc4DataOutput::getFileName(void) const |
---|
| 49 | { |
---|
| 50 | return (this->filename); |
---|
| 51 | } |
---|
| 52 | |
---|
| 53 | //--------------------------------------------------------------- |
---|
| 54 | |
---|
[347] | 55 | void CNc4DataOutput::writeDomain_(CDomain* domain) |
---|
[219] | 56 | { |
---|
[1391] | 57 | StdString lonName,latName ; |
---|
| 58 | |
---|
[1129] | 59 | domain->computeWrittenIndex(); |
---|
[1249] | 60 | domain->computeWrittenCompressedIndex(comm_file); |
---|
| 61 | |
---|
[881] | 62 | if (domain->type == CDomain::type_attr::unstructured) |
---|
| 63 | { |
---|
| 64 | if (SuperClassWriter::useCFConvention) |
---|
| 65 | writeUnstructuredDomain(domain) ; |
---|
| 66 | else |
---|
| 67 | writeUnstructuredDomainUgrid(domain) ; |
---|
| 68 | return ; |
---|
| 69 | } |
---|
[488] | 70 | |
---|
[347] | 71 | CContext* context = CContext::getCurrent() ; |
---|
[300] | 72 | CContextServer* server=context->server ; |
---|
[488] | 73 | |
---|
[219] | 74 | if (domain->IsWritten(this->filename)) return; |
---|
| 75 | domain->checkAttributes(); |
---|
[488] | 76 | |
---|
| 77 | if (domain->isEmpty()) |
---|
[881] | 78 | if (SuperClass::type==MULTI_FILE) return; |
---|
[219] | 79 | |
---|
| 80 | std::vector<StdString> dim0, dim1; |
---|
[772] | 81 | StdString domid = domain->getDomainOutputName(); |
---|
[318] | 82 | StdString appendDomid = (singleDomain) ? "" : "_"+domid ; |
---|
[706] | 83 | if (isWrittenDomain(domid)) return ; |
---|
[774] | 84 | else setWrittenDomain(domid); |
---|
[1132] | 85 | |
---|
| 86 | int nvertex = (domain->nvertex.isEmpty()) ? 0 : domain->nvertex; |
---|
[449] | 87 | |
---|
[488] | 88 | |
---|
[1158] | 89 | StdString dimXid, dimYid ; |
---|
| 90 | |
---|
| 91 | nc_type typePrec ; |
---|
| 92 | if (domain->prec.isEmpty()) typePrec = NC_FLOAT ; |
---|
| 93 | else if (domain->prec==4) typePrec = NC_FLOAT ; |
---|
| 94 | else if (domain->prec==8) typePrec = NC_DOUBLE ; |
---|
| 95 | |
---|
[664] | 96 | bool isRegularDomain = (domain->type == CDomain::type_attr::rectilinear); |
---|
[449] | 97 | switch (domain->type) |
---|
[433] | 98 | { |
---|
[449] | 99 | case CDomain::type_attr::curvilinear : |
---|
[1391] | 100 | |
---|
| 101 | if (domain->lon_name.isEmpty()) lonName = "nav_lon"; |
---|
| 102 | else lonName = domain->lon_name; |
---|
| 103 | |
---|
| 104 | if (domain->lat_name.isEmpty()) latName = "nav_lat"; |
---|
| 105 | else latName = domain->lat_name; |
---|
| 106 | |
---|
[1430] | 107 | if (domain->dim_i_name.isEmpty()) dimXid=StdString("x").append(appendDomid); |
---|
| 108 | else dimXid=domain->dim_i_name.getValue() + appendDomid; |
---|
| 109 | |
---|
| 110 | if (domain->dim_j_name.isEmpty()) dimYid=StdString("y").append(appendDomid); |
---|
| 111 | else dimYid=domain->dim_j_name.getValue() + appendDomid; |
---|
| 112 | |
---|
[449] | 113 | break ; |
---|
[1391] | 114 | |
---|
[664] | 115 | case CDomain::type_attr::rectilinear : |
---|
[1391] | 116 | |
---|
[1430] | 117 | if (domain->lon_name.isEmpty()) |
---|
| 118 | { |
---|
| 119 | if (domain->dim_i_name.isEmpty()) |
---|
| 120 | lonName = "lon"; |
---|
| 121 | else |
---|
| 122 | lonName = domain->dim_i_name.getValue(); |
---|
| 123 | } |
---|
[1391] | 124 | else lonName = domain->lon_name; |
---|
| 125 | |
---|
[1430] | 126 | if (domain->lat_name.isEmpty()) |
---|
| 127 | { |
---|
| 128 | if (domain->dim_j_name.isEmpty()) |
---|
| 129 | latName = "lat"; |
---|
| 130 | else |
---|
| 131 | latName = domain->dim_j_name.getValue(); |
---|
| 132 | } |
---|
[1391] | 133 | else latName = domain->lat_name; |
---|
| 134 | |
---|
[1430] | 135 | if (domain->dim_i_name.isEmpty()) dimXid = lonName+appendDomid; |
---|
| 136 | else dimXid = domain->dim_i_name.getValue()+appendDomid; |
---|
| 137 | |
---|
| 138 | if (domain->dim_j_name.isEmpty()) dimYid = latName+appendDomid; |
---|
| 139 | else dimYid = domain->dim_j_name.getValue()+appendDomid; |
---|
[449] | 140 | break; |
---|
[488] | 141 | } |
---|
| 142 | |
---|
[617] | 143 | StdString dimVertId = StdString("nvertex").append(appendDomid); |
---|
| 144 | |
---|
[449] | 145 | string lonid,latid,bounds_lonid,bounds_latid ; |
---|
[611] | 146 | string areaId = "area" + appendDomid; |
---|
[391] | 147 | /* |
---|
[300] | 148 | StdString lonid_loc = (server->intraCommSize > 1) |
---|
[318] | 149 | ? StdString("lon").append(appendDomid).append("_local") |
---|
[278] | 150 | : lonid; |
---|
[300] | 151 | StdString latid_loc = (server->intraCommSize > 1) |
---|
[318] | 152 | ? StdString("lat").append(appendDomid).append("_local") |
---|
[278] | 153 | : latid; |
---|
[391] | 154 | */ |
---|
[219] | 155 | |
---|
[1624] | 156 | CArray<int, 1>& indexToWrite = domain->localIndexToWriteOnServer; |
---|
[1129] | 157 | int nbWritten = indexToWrite.numElements(); |
---|
| 158 | CArray<double,1> writtenLat, writtenLon; |
---|
| 159 | CArray<double,2> writtenBndsLat, writtenBndsLon; |
---|
| 160 | CArray<double,1> writtenArea; |
---|
| 161 | |
---|
| 162 | if (domain->hasLonLat) |
---|
| 163 | { |
---|
| 164 | writtenLat.resize(nbWritten); |
---|
| 165 | writtenLon.resize(nbWritten); |
---|
| 166 | for (int idx = 0; idx < nbWritten; ++idx) |
---|
| 167 | { |
---|
[1624] | 168 | if (indexToWrite(idx) < 0) |
---|
| 169 | { |
---|
| 170 | writtenLat(idx) = -1.; // hole |
---|
| 171 | writtenLon(idx) = -1.; |
---|
| 172 | } |
---|
| 173 | else |
---|
| 174 | { |
---|
| 175 | writtenLat(idx) = domain->latvalue(indexToWrite(idx)); |
---|
| 176 | writtenLon(idx) = domain->lonvalue(indexToWrite(idx)); |
---|
| 177 | } |
---|
[1129] | 178 | } |
---|
| 179 | |
---|
| 180 | if (domain->hasBounds) |
---|
| 181 | { |
---|
| 182 | int nvertex = domain->nvertex, idx; |
---|
| 183 | writtenBndsLat.resize(nvertex, nbWritten); |
---|
| 184 | writtenBndsLon.resize(nvertex, nbWritten); |
---|
| 185 | CArray<double,2>& boundslat = domain->bounds_latvalue; |
---|
| 186 | CArray<double,2>& boundslon = domain->bounds_lonvalue; |
---|
| 187 | for (idx = 0; idx < nbWritten; ++idx) |
---|
| 188 | for (int nv = 0; nv < nvertex; ++nv) |
---|
| 189 | { |
---|
[1624] | 190 | if (indexToWrite(idx) < 0) |
---|
| 191 | { |
---|
| 192 | writtenBndsLat(nv, idx) = -1.; // hole |
---|
| 193 | writtenBndsLon(nv, idx) = -1.; |
---|
| 194 | } |
---|
| 195 | else |
---|
| 196 | { |
---|
[1390] | 197 | writtenBndsLat(nv, idx) = boundslat(nv, int(indexToWrite(idx))); |
---|
| 198 | writtenBndsLon(nv, idx) = boundslon(nv, int(indexToWrite(idx))); |
---|
[1624] | 199 | } |
---|
[1129] | 200 | } |
---|
| 201 | } |
---|
| 202 | } |
---|
| 203 | |
---|
| 204 | if (domain->hasArea) |
---|
| 205 | { |
---|
| 206 | writtenArea.resize(nbWritten); |
---|
| 207 | for (int idx = 0; idx < nbWritten; ++idx) |
---|
| 208 | { |
---|
[1624] | 209 | if (indexToWrite(idx) < 0) |
---|
| 210 | writtenArea(idx) = -1.; |
---|
[1390] | 211 | else |
---|
[1624] | 212 | writtenArea(idx) = domain->areavalue(indexToWrite(idx)); |
---|
[1129] | 213 | } |
---|
| 214 | } |
---|
| 215 | |
---|
[498] | 216 | try |
---|
[219] | 217 | { |
---|
[498] | 218 | switch (SuperClass::type) |
---|
| 219 | { |
---|
| 220 | case (MULTI_FILE) : |
---|
| 221 | { |
---|
| 222 | switch (domain->type) |
---|
| 223 | { |
---|
| 224 | case CDomain::type_attr::curvilinear : |
---|
| 225 | dim0.push_back(dimYid); dim0.push_back(dimXid); |
---|
[1415] | 226 | lonid = lonName+appendDomid; |
---|
| 227 | latid = latName+appendDomid; |
---|
[498] | 228 | break ; |
---|
[664] | 229 | case CDomain::type_attr::rectilinear : |
---|
[1415] | 230 | lonid = lonName+appendDomid; |
---|
| 231 | latid = latName+appendDomid; |
---|
[498] | 232 | dim0.push_back(dimYid); |
---|
| 233 | dim1.push_back(dimXid); |
---|
| 234 | break; |
---|
| 235 | } |
---|
[1430] | 236 | if (!domain->bounds_lon_name.isEmpty()) bounds_lonid = domain->bounds_lon_name; |
---|
| 237 | else bounds_lonid = "bounds_"+lonName+appendDomid; |
---|
| 238 | if (!domain->bounds_lat_name.isEmpty()) bounds_latid = domain->bounds_lat_name; |
---|
| 239 | else bounds_latid = "bounds_"+latName+appendDomid; |
---|
[488] | 240 | |
---|
[1099] | 241 | SuperClassWriter::addDimension(dimXid, domain->zoom_ni); |
---|
| 242 | SuperClassWriter::addDimension(dimYid, domain->zoom_nj); |
---|
[488] | 243 | |
---|
[617] | 244 | if (domain->hasBounds) |
---|
| 245 | SuperClassWriter::addDimension(dimVertId, domain->nvertex); |
---|
| 246 | |
---|
[498] | 247 | if (server->intraCommSize > 1) |
---|
| 248 | { |
---|
[1099] | 249 | this->writeLocalAttributes(domain->zoom_ibegin, |
---|
| 250 | domain->zoom_ni, |
---|
| 251 | domain->zoom_jbegin, |
---|
| 252 | domain->zoom_nj, |
---|
[616] | 253 | appendDomid); |
---|
[488] | 254 | |
---|
[628] | 255 | if (singleDomain) |
---|
| 256 | this->writeLocalAttributes_IOIPSL(dimXid, dimYid, |
---|
[1099] | 257 | domain->zoom_ibegin, |
---|
| 258 | domain->zoom_ni, |
---|
| 259 | domain->zoom_jbegin, |
---|
| 260 | domain->zoom_nj, |
---|
[628] | 261 | domain->ni_glo,domain->nj_glo, |
---|
| 262 | server->intraCommRank,server->intraCommSize); |
---|
[449] | 263 | } |
---|
[488] | 264 | |
---|
[665] | 265 | if (domain->hasLonLat) |
---|
[498] | 266 | { |
---|
[665] | 267 | switch (domain->type) |
---|
| 268 | { |
---|
| 269 | case CDomain::type_attr::curvilinear : |
---|
[1456] | 270 | SuperClassWriter::addVariable(latid, typePrec, dim0, compressionLevel); |
---|
| 271 | SuperClassWriter::addVariable(lonid, typePrec, dim0, compressionLevel); |
---|
[665] | 272 | break ; |
---|
| 273 | case CDomain::type_attr::rectilinear : |
---|
[1456] | 274 | SuperClassWriter::addVariable(latid, typePrec, dim0, compressionLevel); |
---|
| 275 | SuperClassWriter::addVariable(lonid, typePrec, dim1, compressionLevel); |
---|
[665] | 276 | break ; |
---|
| 277 | } |
---|
[488] | 278 | |
---|
[665] | 279 | this->writeAxisAttributes(lonid, isRegularDomain ? "X" : "", "longitude", "Longitude", "degrees_east", domid); |
---|
| 280 | this->writeAxisAttributes(latid, isRegularDomain ? "Y" : "", "latitude", "Latitude", "degrees_north", domid); |
---|
[219] | 281 | |
---|
[665] | 282 | if (domain->hasBounds) |
---|
| 283 | { |
---|
| 284 | SuperClassWriter::addAttribute("bounds", bounds_lonid, &lonid); |
---|
| 285 | SuperClassWriter::addAttribute("bounds", bounds_latid, &latid); |
---|
[617] | 286 | |
---|
[665] | 287 | dim0.clear(); |
---|
| 288 | dim0.push_back(dimYid); |
---|
| 289 | dim0.push_back(dimXid); |
---|
| 290 | dim0.push_back(dimVertId); |
---|
[1456] | 291 | SuperClassWriter::addVariable(bounds_lonid, typePrec, dim0, compressionLevel); |
---|
| 292 | SuperClassWriter::addVariable(bounds_latid, typePrec, dim0, compressionLevel); |
---|
[665] | 293 | } |
---|
[617] | 294 | } |
---|
| 295 | |
---|
[498] | 296 | dim0.clear(); |
---|
[616] | 297 | dim0.push_back(dimYid); |
---|
[498] | 298 | dim0.push_back(dimXid); |
---|
[219] | 299 | |
---|
| 300 | |
---|
[498] | 301 | // supress mask if (server->intraCommSize > 1) |
---|
| 302 | // supress mask { |
---|
| 303 | // supress mask SuperClassWriter::addVariable(maskid, NC_INT, dim0); |
---|
| 304 | // supress mask |
---|
| 305 | // supress mask this->writeMaskAttributes(maskid, |
---|
| 306 | // supress mask domain->data_dim.getValue()/*, |
---|
| 307 | // supress mask domain->data_ni.getValue(), |
---|
| 308 | // supress mask domain->data_nj.getValue(), |
---|
| 309 | // supress mask domain->data_ibegin.getValue(), |
---|
| 310 | // supress mask domain->data_jbegin.getValue()*/); |
---|
| 311 | // supress mask } |
---|
[488] | 312 | |
---|
[498] | 313 | //SuperClassWriter::setDefaultValue(maskid, &dvm); |
---|
[219] | 314 | |
---|
[611] | 315 | if (domain->hasArea) |
---|
| 316 | { |
---|
[1456] | 317 | SuperClassWriter::addVariable(areaId, typePrec, dim0, compressionLevel); |
---|
[614] | 318 | SuperClassWriter::addAttribute("standard_name", StdString("cell_area"), &areaId); |
---|
[611] | 319 | SuperClassWriter::addAttribute("units", StdString("m2"), &areaId); |
---|
| 320 | } |
---|
| 321 | |
---|
[498] | 322 | SuperClassWriter::definition_end(); |
---|
[449] | 323 | |
---|
[665] | 324 | if (domain->hasLonLat) |
---|
[498] | 325 | { |
---|
[665] | 326 | switch (domain->type) |
---|
| 327 | { |
---|
[1129] | 328 | case CDomain::type_attr::curvilinear : |
---|
| 329 | SuperClassWriter::writeData(writtenLat, latid, isCollective, 0); |
---|
| 330 | SuperClassWriter::writeData(writtenLon, lonid, isCollective, 0); |
---|
[665] | 331 | break; |
---|
| 332 | case CDomain::type_attr::rectilinear : |
---|
[1129] | 333 | CArray<double,1> lat = writtenLat(Range(fromStart,toEnd,domain->zoom_ni)) ; |
---|
[665] | 334 | SuperClassWriter::writeData(CArray<double,1>(lat.copy()), latid, isCollective, 0); |
---|
[1129] | 335 | CArray<double,1> lon = writtenLon(Range(0,domain->zoom_ni-1)) ; |
---|
[665] | 336 | SuperClassWriter::writeData(CArray<double,1>(lon.copy()), lonid, isCollective, 0); |
---|
| 337 | break; |
---|
| 338 | } |
---|
[611] | 339 | |
---|
[665] | 340 | if (domain->hasBounds) |
---|
| 341 | { |
---|
[1129] | 342 | SuperClassWriter::writeData(writtenBndsLon, bounds_lonid, isCollective, 0); |
---|
| 343 | SuperClassWriter::writeData(writtenBndsLat, bounds_latid, isCollective, 0); |
---|
[665] | 344 | } |
---|
[617] | 345 | } |
---|
| 346 | |
---|
[611] | 347 | if (domain->hasArea) |
---|
[1129] | 348 | { |
---|
[1132] | 349 | SuperClassWriter::writeData(writtenArea, areaId, isCollective, 0); |
---|
[1129] | 350 | } |
---|
| 351 | |
---|
[498] | 352 | SuperClassWriter::definition_start(); |
---|
[219] | 353 | |
---|
[498] | 354 | break; |
---|
| 355 | } |
---|
| 356 | case (ONE_FILE) : |
---|
| 357 | { |
---|
[1099] | 358 | SuperClassWriter::addDimension(dimXid, domain->global_zoom_ni); |
---|
| 359 | SuperClassWriter::addDimension(dimYid, domain->global_zoom_nj); |
---|
[286] | 360 | |
---|
[617] | 361 | if (domain->hasBounds) |
---|
| 362 | SuperClassWriter::addDimension(dimVertId, domain->nvertex); |
---|
| 363 | |
---|
[665] | 364 | if (domain->hasLonLat) |
---|
[498] | 365 | { |
---|
[665] | 366 | switch (domain->type) |
---|
| 367 | { |
---|
| 368 | case CDomain::type_attr::curvilinear : |
---|
| 369 | dim0.push_back(dimYid); dim0.push_back(dimXid); |
---|
[1415] | 370 | lonid = lonName+appendDomid; |
---|
| 371 | latid = latName+appendDomid; |
---|
[1456] | 372 | SuperClassWriter::addVariable(latid, typePrec, dim0, compressionLevel); |
---|
| 373 | SuperClassWriter::addVariable(lonid, typePrec, dim0, compressionLevel); |
---|
[665] | 374 | break; |
---|
[449] | 375 | |
---|
[665] | 376 | case CDomain::type_attr::rectilinear : |
---|
| 377 | dim0.push_back(dimYid); |
---|
| 378 | dim1.push_back(dimXid); |
---|
[1415] | 379 | lonid = lonName+appendDomid; |
---|
| 380 | latid = latName+appendDomid; |
---|
[1456] | 381 | SuperClassWriter::addVariable(latid, typePrec, dim0, compressionLevel); |
---|
| 382 | SuperClassWriter::addVariable(lonid, typePrec, dim1, compressionLevel); |
---|
[665] | 383 | break; |
---|
| 384 | } |
---|
[1430] | 385 | if (!domain->bounds_lon_name.isEmpty()) bounds_lonid = domain->bounds_lon_name; |
---|
| 386 | else bounds_lonid = "bounds_"+lonName+appendDomid; |
---|
| 387 | if (!domain->bounds_lat_name.isEmpty()) bounds_latid = domain->bounds_lat_name; |
---|
| 388 | else bounds_latid = "bounds_"+latName+appendDomid; |
---|
[665] | 389 | |
---|
| 390 | this->writeAxisAttributes |
---|
| 391 | (lonid, isRegularDomain ? "X" : "", "longitude", "Longitude", "degrees_east", domid); |
---|
| 392 | this->writeAxisAttributes |
---|
| 393 | (latid, isRegularDomain ? "Y" : "", "latitude", "Latitude", "degrees_north", domid); |
---|
| 394 | |
---|
| 395 | if (domain->hasBounds) |
---|
| 396 | { |
---|
| 397 | SuperClassWriter::addAttribute("bounds", bounds_lonid, &lonid); |
---|
| 398 | SuperClassWriter::addAttribute("bounds", bounds_latid, &latid); |
---|
| 399 | |
---|
| 400 | dim0.clear(); |
---|
[498] | 401 | dim0.push_back(dimYid); |
---|
[665] | 402 | dim0.push_back(dimXid); |
---|
| 403 | dim0.push_back(dimVertId); |
---|
[1456] | 404 | SuperClassWriter::addVariable(bounds_lonid, typePrec, dim0, compressionLevel); |
---|
| 405 | SuperClassWriter::addVariable(bounds_latid, typePrec, dim0, compressionLevel); |
---|
[665] | 406 | } |
---|
[498] | 407 | } |
---|
[611] | 408 | |
---|
| 409 | if (domain->hasArea) |
---|
| 410 | { |
---|
| 411 | dim0.clear(); |
---|
| 412 | dim0.push_back(dimYid); dim0.push_back(dimXid); |
---|
[1456] | 413 | SuperClassWriter::addVariable(areaId, typePrec, dim0, compressionLevel); |
---|
[614] | 414 | SuperClassWriter::addAttribute("standard_name", StdString("cell_area"), &areaId); |
---|
[611] | 415 | SuperClassWriter::addAttribute("units", StdString("m2"), &areaId); |
---|
| 416 | dim0.clear(); |
---|
| 417 | } |
---|
| 418 | |
---|
| 419 | SuperClassWriter::definition_end(); |
---|
[286] | 420 | |
---|
[498] | 421 | switch (domain->type) |
---|
[384] | 422 | { |
---|
[498] | 423 | case CDomain::type_attr::curvilinear : |
---|
[449] | 424 | { |
---|
[498] | 425 | std::vector<StdSize> start(2) ; |
---|
| 426 | std::vector<StdSize> count(2) ; |
---|
[1624] | 427 | // Comment out because it is not working for a hole |
---|
| 428 | // if (domain->isEmpty()) |
---|
| 429 | // { |
---|
| 430 | // start[0]=0 ; start[1]=0 ; |
---|
| 431 | // count[0]=0 ; count[1]=0 ; |
---|
| 432 | // } |
---|
| 433 | // else |
---|
[498] | 434 | { |
---|
[1099] | 435 | start[1]=domain->zoom_ibegin-domain->global_zoom_ibegin; |
---|
| 436 | start[0]=domain->zoom_jbegin-domain->global_zoom_jbegin; |
---|
| 437 | count[1]=domain->zoom_ni ; count[0]=domain->zoom_nj ; |
---|
[498] | 438 | } |
---|
[488] | 439 | |
---|
[665] | 440 | if (domain->hasLonLat) |
---|
| 441 | { |
---|
[1129] | 442 | SuperClassWriter::writeData(writtenLat, latid, isCollective, 0,&start,&count); |
---|
| 443 | SuperClassWriter::writeData(writtenLon, lonid, isCollective, 0,&start,&count); |
---|
[665] | 444 | } |
---|
[498] | 445 | break; |
---|
| 446 | } |
---|
[664] | 447 | case CDomain::type_attr::rectilinear : |
---|
[449] | 448 | { |
---|
[665] | 449 | if (domain->hasLonLat) |
---|
[498] | 450 | { |
---|
[665] | 451 | std::vector<StdSize> start(1) ; |
---|
| 452 | std::vector<StdSize> count(1) ; |
---|
| 453 | if (domain->isEmpty()) |
---|
| 454 | { |
---|
| 455 | start[0]=0 ; |
---|
| 456 | count[0]=0 ; |
---|
[1129] | 457 | SuperClassWriter::writeData(writtenLat, latid, isCollective, 0,&start,&count); |
---|
| 458 | SuperClassWriter::writeData(writtenLon, lonid, isCollective, 0,&start,&count); |
---|
[665] | 459 | } |
---|
| 460 | else |
---|
[1129] | 461 | { |
---|
[1099] | 462 | start[0]=domain->zoom_jbegin-domain->global_zoom_jbegin; |
---|
[1143] | 463 | count[0]=domain->zoom_nj; |
---|
[1129] | 464 | CArray<double,1> lat = writtenLat(Range(fromStart,toEnd,domain->zoom_ni)); |
---|
[665] | 465 | SuperClassWriter::writeData(CArray<double,1>(lat.copy()), latid, isCollective, 0,&start,&count); |
---|
| 466 | |
---|
[1099] | 467 | start[0]=domain->zoom_ibegin-domain->global_zoom_ibegin; |
---|
[1143] | 468 | count[0]=domain->zoom_ni; |
---|
[1129] | 469 | CArray<double,1> lon = writtenLon(Range(0,domain->zoom_ni-1)); |
---|
[665] | 470 | SuperClassWriter::writeData(CArray<double,1>(lon.copy()), lonid, isCollective, 0,&start,&count); |
---|
| 471 | } |
---|
[498] | 472 | } |
---|
| 473 | break; |
---|
[449] | 474 | } |
---|
[384] | 475 | } |
---|
[611] | 476 | |
---|
[617] | 477 | if (domain->hasBounds) |
---|
| 478 | { |
---|
| 479 | std::vector<StdSize> start(3); |
---|
| 480 | std::vector<StdSize> count(3); |
---|
| 481 | if (domain->isEmpty()) |
---|
| 482 | { |
---|
| 483 | start[2] = start[1] = start[0] = 0; |
---|
| 484 | count[2] = count[1] = count[0] = 0; |
---|
| 485 | } |
---|
| 486 | else |
---|
| 487 | { |
---|
| 488 | start[2] = 0; |
---|
[1099] | 489 | start[1] = domain->zoom_ibegin - domain->global_zoom_ibegin; |
---|
| 490 | start[0] = domain->zoom_jbegin - domain->global_zoom_jbegin; |
---|
| 491 | count[2] = domain->nvertex; |
---|
| 492 | count[1] = domain->zoom_ni; |
---|
| 493 | count[0] = domain->zoom_nj; |
---|
[617] | 494 | } |
---|
[1143] | 495 | |
---|
[1129] | 496 | SuperClassWriter::writeData(writtenBndsLon, bounds_lonid, isCollective, 0, &start, &count); |
---|
| 497 | SuperClassWriter::writeData(writtenBndsLat, bounds_latid, isCollective, 0, &start, &count); |
---|
[617] | 498 | } |
---|
| 499 | |
---|
[611] | 500 | if (domain->hasArea) |
---|
| 501 | { |
---|
| 502 | std::vector<StdSize> start(2); |
---|
| 503 | std::vector<StdSize> count(2); |
---|
| 504 | |
---|
| 505 | if (domain->isEmpty()) |
---|
| 506 | { |
---|
| 507 | start[0] = 0; start[1] = 0; |
---|
| 508 | count[0] = 0; count[1] = 0; |
---|
| 509 | } |
---|
| 510 | else |
---|
| 511 | { |
---|
[1099] | 512 | start[1] = domain->zoom_ibegin - domain->global_zoom_ibegin; |
---|
| 513 | start[0] = domain->zoom_jbegin - domain->global_zoom_jbegin; |
---|
| 514 | count[1] = domain->zoom_ni; |
---|
| 515 | count[0] = domain->zoom_nj; |
---|
[611] | 516 | } |
---|
[1143] | 517 | |
---|
[1129] | 518 | SuperClassWriter::writeData(writtenArea, areaId, isCollective, 0, &start, &count); |
---|
[611] | 519 | } |
---|
| 520 | |
---|
[498] | 521 | SuperClassWriter::definition_start(); |
---|
| 522 | break; |
---|
| 523 | } |
---|
| 524 | default : |
---|
| 525 | ERROR("CNc4DataOutput::writeDomain(domain)", |
---|
| 526 | << "[ type = " << SuperClass::type << "]" |
---|
| 527 | << " not implemented yet !"); |
---|
| 528 | } |
---|
[449] | 529 | } |
---|
[498] | 530 | catch (CNetCdfException& e) |
---|
| 531 | { |
---|
| 532 | StdString msg("On writing the domain : "); |
---|
| 533 | msg.append(domid); msg.append("\n"); |
---|
| 534 | msg.append("In the context : "); |
---|
| 535 | msg.append(context->getId()); msg.append("\n"); |
---|
| 536 | msg.append(e.what()); |
---|
| 537 | ERROR("CNc4DataOutput::writeDomain_(CDomain* domain)", << msg); |
---|
| 538 | } |
---|
| 539 | |
---|
[449] | 540 | domain->addRelFile(this->filename); |
---|
| 541 | } |
---|
| 542 | |
---|
[879] | 543 | //-------------------------------------------------------------- |
---|
[878] | 544 | |
---|
[879] | 545 | void CNc4DataOutput::writeUnstructuredDomainUgrid(CDomain* domain) |
---|
| 546 | { |
---|
| 547 | CContext* context = CContext::getCurrent() ; |
---|
| 548 | CContextServer* server=context->server ; |
---|
[878] | 549 | |
---|
[879] | 550 | if (domain->IsWritten(this->filename)) return; |
---|
[1494] | 551 | |
---|
| 552 | StdString domid = domain->getDomainOutputName(); |
---|
| 553 | |
---|
| 554 | // The first domain for the same mesh that will be written is that with the highest value of nvertex. |
---|
| 555 | // Thus the entire mesh connectivity will be generated at once. |
---|
| 556 | if (isWrittenDomain(domid)) return ; |
---|
| 557 | else setWrittenDomain(domid); |
---|
| 558 | |
---|
[879] | 559 | domain->checkAttributes(); |
---|
| 560 | if (domain->isEmpty()) |
---|
| 561 | if (SuperClass::type==MULTI_FILE) return ; |
---|
[878] | 562 | |
---|
[1158] | 563 | nc_type typePrec ; |
---|
| 564 | if (domain->prec.isEmpty()) typePrec = NC_FLOAT ; |
---|
| 565 | else if (domain->prec==4) typePrec = NC_FLOAT ; |
---|
| 566 | else if (domain->prec==8) typePrec = NC_DOUBLE ; |
---|
| 567 | |
---|
[879] | 568 | std::vector<StdString> dim0; |
---|
| 569 | StdString domainName = domain->name; |
---|
[924] | 570 | domain->assignMesh(domainName, domain->nvertex); |
---|
[1025] | 571 | domain->mesh->createMeshEpsilon(server->intraComm, domain->lonvalue, domain->latvalue, domain->bounds_lonvalue, domain->bounds_latvalue); |
---|
[878] | 572 | |
---|
[879] | 573 | StdString node_x = domainName + "_node_x"; |
---|
| 574 | StdString node_y = domainName + "_node_y"; |
---|
[878] | 575 | |
---|
[879] | 576 | StdString edge_x = domainName + "_edge_x"; |
---|
| 577 | StdString edge_y = domainName + "_edge_y"; |
---|
| 578 | StdString edge_nodes = domainName + "_edge_nodes"; |
---|
[878] | 579 | |
---|
[879] | 580 | StdString face_x = domainName + "_face_x"; |
---|
| 581 | StdString face_y = domainName + "_face_y"; |
---|
| 582 | StdString face_nodes = domainName + "_face_nodes"; |
---|
[902] | 583 | StdString face_edges = domainName + "_face_edges"; |
---|
| 584 | StdString edge_faces = domainName + "_edge_face_links"; |
---|
| 585 | StdString face_faces = domainName + "_face_links"; |
---|
[878] | 586 | |
---|
[879] | 587 | StdString dimNode = "n" + domainName + "_node"; |
---|
| 588 | StdString dimEdge = "n" + domainName + "_edge"; |
---|
| 589 | StdString dimFace = "n" + domainName + "_face"; |
---|
| 590 | StdString dimVertex = "n" + domainName + "_vertex"; |
---|
| 591 | StdString dimTwo = "Two"; |
---|
[878] | 592 | |
---|
[879] | 593 | if (!SuperClassWriter::dimExist(dimTwo)) SuperClassWriter::addDimension(dimTwo, 2); |
---|
[1494] | 594 | dim0.clear(); |
---|
| 595 | SuperClassWriter::addVariable(domainName, NC_INT, dim0, compressionLevel); |
---|
| 596 | SuperClassWriter::addAttribute("cf_role", StdString("mesh_topology"), &domainName); |
---|
| 597 | SuperClassWriter::addAttribute("long_name", StdString("Topology data of 2D unstructured mesh"), &domainName); |
---|
| 598 | SuperClassWriter::addAttribute("topology_dimension", 2, &domainName); |
---|
| 599 | SuperClassWriter::addAttribute("node_coordinates", node_x + " " + node_y, &domainName); |
---|
[878] | 600 | |
---|
[879] | 601 | try |
---|
| 602 | { |
---|
| 603 | switch (SuperClass::type) |
---|
| 604 | { |
---|
| 605 | case (ONE_FILE) : |
---|
| 606 | { |
---|
| 607 | // Adding nodes |
---|
| 608 | if (domain->nvertex == 1) |
---|
| 609 | { |
---|
| 610 | if (!SuperClassWriter::varExist(node_x) || !SuperClassWriter::varExist(node_y)) |
---|
| 611 | { |
---|
[902] | 612 | SuperClassWriter::addDimension(dimNode, domain->ni_glo); |
---|
[879] | 613 | dim0.clear(); |
---|
| 614 | dim0.push_back(dimNode); |
---|
[1456] | 615 | SuperClassWriter::addVariable(node_x, typePrec, dim0, compressionLevel); |
---|
[879] | 616 | SuperClassWriter::addAttribute("standard_name", StdString("longitude"), &node_x); |
---|
[924] | 617 | SuperClassWriter::addAttribute("long_name", StdString("Longitude of mesh nodes."), &node_x); |
---|
[879] | 618 | SuperClassWriter::addAttribute("units", StdString("degrees_east"), &node_x); |
---|
[1456] | 619 | SuperClassWriter::addVariable(node_y, typePrec, dim0, compressionLevel); |
---|
[879] | 620 | SuperClassWriter::addAttribute("standard_name", StdString("latitude"), &node_y); |
---|
[924] | 621 | SuperClassWriter::addAttribute("long_name", StdString("Latitude of mesh nodes."), &node_y); |
---|
[879] | 622 | SuperClassWriter::addAttribute("units", StdString("degrees_north"), &node_y); |
---|
| 623 | } |
---|
| 624 | } // domain->nvertex == 1 |
---|
[878] | 625 | |
---|
[879] | 626 | // Adding edges and nodes, if nodes have not been defined previously |
---|
| 627 | if (domain->nvertex == 2) |
---|
| 628 | { |
---|
| 629 | if (!SuperClassWriter::varExist(node_x) || !SuperClassWriter::varExist(node_y)) |
---|
| 630 | { |
---|
[924] | 631 | SuperClassWriter::addDimension(dimNode, domain->mesh->nbNodesGlo); |
---|
[879] | 632 | dim0.clear(); |
---|
| 633 | dim0.push_back(dimNode); |
---|
[1456] | 634 | SuperClassWriter::addVariable(node_x, typePrec, dim0, compressionLevel); |
---|
[879] | 635 | SuperClassWriter::addAttribute("standard_name", StdString("longitude"), &node_x); |
---|
[924] | 636 | SuperClassWriter::addAttribute("long_name", StdString("Longitude of mesh nodes."), &node_x); |
---|
[879] | 637 | SuperClassWriter::addAttribute("units", StdString("degrees_east"), &node_x); |
---|
[1456] | 638 | SuperClassWriter::addVariable(node_y, typePrec, dim0, compressionLevel); |
---|
[879] | 639 | SuperClassWriter::addAttribute("standard_name", StdString("latitude"), &node_y); |
---|
[924] | 640 | SuperClassWriter::addAttribute("long_name", StdString("Latitude of mesh nodes."), &node_y); |
---|
[879] | 641 | SuperClassWriter::addAttribute("units", StdString("degrees_north"), &node_y); |
---|
| 642 | } |
---|
[924] | 643 | SuperClassWriter::addAttribute("edge_node_connectivity", edge_nodes, &domainName); |
---|
| 644 | SuperClassWriter::addAttribute("edge_coordinates", edge_x + " " + edge_y, &domainName); |
---|
| 645 | SuperClassWriter::addDimension(dimEdge, domain->ni_glo); |
---|
| 646 | dim0.clear(); |
---|
| 647 | dim0.push_back(dimEdge); |
---|
[1456] | 648 | SuperClassWriter::addVariable(edge_x, typePrec, dim0, compressionLevel); |
---|
[924] | 649 | SuperClassWriter::addAttribute("standard_name", StdString("longitude"), &edge_x); |
---|
| 650 | SuperClassWriter::addAttribute("long_name", StdString("Characteristic longitude of mesh edges."), &edge_x); |
---|
| 651 | SuperClassWriter::addAttribute("units", StdString("degrees_east"), &edge_x); |
---|
[1456] | 652 | SuperClassWriter::addVariable(edge_y, typePrec, dim0, compressionLevel); |
---|
[924] | 653 | SuperClassWriter::addAttribute("standard_name", StdString("latitude"), &edge_y); |
---|
| 654 | SuperClassWriter::addAttribute("long_name", StdString("Characteristic latitude of mesh edges."), &edge_y); |
---|
| 655 | SuperClassWriter::addAttribute("units", StdString("degrees_north"), &edge_y); |
---|
| 656 | dim0.clear(); |
---|
| 657 | dim0.push_back(dimEdge); |
---|
| 658 | dim0.push_back(dimTwo); |
---|
[1456] | 659 | SuperClassWriter::addVariable(edge_nodes, NC_INT, dim0, compressionLevel); |
---|
[924] | 660 | SuperClassWriter::addAttribute("cf_role", StdString("edge_node_connectivity"), &edge_nodes); |
---|
| 661 | SuperClassWriter::addAttribute("long_name", StdString("Maps every edge/link to two nodes that it connects."), &edge_nodes); |
---|
| 662 | SuperClassWriter::addAttribute("start_index", 0, &edge_nodes); |
---|
[879] | 663 | } // domain->nvertex == 2 |
---|
[878] | 664 | |
---|
[879] | 665 | // Adding faces, edges, and nodes, if edges and nodes have not been defined previously |
---|
| 666 | if (domain->nvertex > 2) |
---|
| 667 | { |
---|
| 668 | // Nodes |
---|
| 669 | if (!SuperClassWriter::varExist(node_x) || !SuperClassWriter::varExist(node_y)) |
---|
| 670 | { |
---|
[924] | 671 | SuperClassWriter::addDimension(dimNode, domain->mesh->nbNodesGlo); |
---|
[879] | 672 | dim0.clear(); |
---|
| 673 | dim0.push_back(dimNode); |
---|
[1456] | 674 | SuperClassWriter::addVariable(node_x, typePrec, dim0, compressionLevel); |
---|
[879] | 675 | SuperClassWriter::addAttribute("standard_name", StdString("longitude"), &node_x); |
---|
[924] | 676 | SuperClassWriter::addAttribute("long_name", StdString("Longitude of mesh nodes."), &node_x); |
---|
[879] | 677 | SuperClassWriter::addAttribute("units", StdString("degrees_east"), &node_x); |
---|
[1456] | 678 | SuperClassWriter::addVariable(node_y, typePrec, dim0, compressionLevel); |
---|
[879] | 679 | SuperClassWriter::addAttribute("standard_name", StdString("latitude"), &node_y); |
---|
[924] | 680 | SuperClassWriter::addAttribute("long_name", StdString("Latitude of mesh nodes."), &node_y); |
---|
[879] | 681 | SuperClassWriter::addAttribute("units", StdString("degrees_north"), &node_y); |
---|
| 682 | } |
---|
| 683 | if (!SuperClassWriter::varExist(edge_x) || !SuperClassWriter::varExist(edge_y)) |
---|
| 684 | { |
---|
| 685 | SuperClassWriter::addAttribute("edge_coordinates", edge_x + " " + edge_y, &domainName); |
---|
| 686 | SuperClassWriter::addAttribute("edge_node_connectivity", edge_nodes, &domainName); |
---|
[924] | 687 | SuperClassWriter::addDimension(dimEdge, domain->mesh->nbEdgesGlo); |
---|
[879] | 688 | dim0.clear(); |
---|
| 689 | dim0.push_back(dimEdge); |
---|
[1456] | 690 | SuperClassWriter::addVariable(edge_x, typePrec, dim0, compressionLevel); |
---|
[879] | 691 | SuperClassWriter::addAttribute("standard_name", StdString("longitude"), &edge_x); |
---|
[924] | 692 | SuperClassWriter::addAttribute("long_name", StdString("Characteristic longitude of mesh edges."), &edge_x); |
---|
[879] | 693 | SuperClassWriter::addAttribute("units", StdString("degrees_east"), &edge_x); |
---|
[1456] | 694 | SuperClassWriter::addVariable(edge_y, typePrec, dim0, compressionLevel); |
---|
[879] | 695 | SuperClassWriter::addAttribute("standard_name", StdString("latitude"), &edge_y); |
---|
[924] | 696 | SuperClassWriter::addAttribute("long_name", StdString("Characteristic latitude of mesh edges."), &edge_y); |
---|
[879] | 697 | SuperClassWriter::addAttribute("units", StdString("degrees_north"), &edge_y); |
---|
| 698 | dim0.clear(); |
---|
| 699 | dim0.push_back(dimEdge); |
---|
| 700 | dim0.push_back(dimTwo); |
---|
[1456] | 701 | SuperClassWriter::addVariable(edge_nodes, NC_INT, dim0, compressionLevel); |
---|
[879] | 702 | SuperClassWriter::addAttribute("cf_role", StdString("edge_node_connectivity"), &edge_nodes); |
---|
| 703 | SuperClassWriter::addAttribute("long_name", StdString("Maps every edge/link to two nodes that it connects."), &edge_nodes); |
---|
| 704 | SuperClassWriter::addAttribute("start_index", 0, &edge_nodes); |
---|
| 705 | } |
---|
[924] | 706 | SuperClassWriter::addAttribute("face_coordinates", face_x + " " + face_y, &domainName); |
---|
| 707 | SuperClassWriter::addAttribute("face_node_connectivity", face_nodes, &domainName); |
---|
| 708 | SuperClassWriter::addDimension(dimFace, domain->ni_glo); |
---|
| 709 | SuperClassWriter::addDimension(dimVertex, domain->nvertex); |
---|
| 710 | dim0.clear(); |
---|
| 711 | dim0.push_back(dimFace); |
---|
[1456] | 712 | SuperClassWriter::addVariable(face_x, typePrec, dim0, compressionLevel); |
---|
[924] | 713 | SuperClassWriter::addAttribute("standard_name", StdString("longitude"), &face_x); |
---|
| 714 | SuperClassWriter::addAttribute("long_name", StdString("Characteristic longitude of mesh faces."), &face_x); |
---|
| 715 | SuperClassWriter::addAttribute("units", StdString("degrees_east"), &face_x); |
---|
[1456] | 716 | SuperClassWriter::addVariable(face_y, typePrec, dim0, compressionLevel); |
---|
[924] | 717 | SuperClassWriter::addAttribute("standard_name", StdString("latitude"), &face_y); |
---|
| 718 | SuperClassWriter::addAttribute("long_name", StdString("Characteristic latitude of mesh faces."), &face_y); |
---|
| 719 | SuperClassWriter::addAttribute("units", StdString("degrees_north"), &face_y); |
---|
| 720 | dim0.clear(); |
---|
| 721 | dim0.push_back(dimFace); |
---|
| 722 | dim0.push_back(dimVertex); |
---|
[1456] | 723 | SuperClassWriter::addVariable(face_nodes, NC_INT, dim0, compressionLevel); |
---|
[924] | 724 | SuperClassWriter::addAttribute("cf_role", StdString("face_node_connectivity"), &face_nodes); |
---|
| 725 | SuperClassWriter::addAttribute("long_name", StdString("Maps every face to its corner nodes."), &face_nodes); |
---|
| 726 | SuperClassWriter::addAttribute("start_index", 0, &face_nodes); |
---|
| 727 | dim0.clear(); |
---|
| 728 | dim0.push_back(dimFace); |
---|
| 729 | dim0.push_back(dimVertex); |
---|
[1456] | 730 | SuperClassWriter::addVariable(face_edges, NC_INT, dim0, compressionLevel); |
---|
[924] | 731 | SuperClassWriter::addAttribute("cf_role", StdString("face_edge_connectivity"), &face_edges); |
---|
| 732 | SuperClassWriter::addAttribute("long_name", StdString("Maps every face to its edges."), &face_edges); |
---|
| 733 | SuperClassWriter::addAttribute("start_index", 0, &face_edges); |
---|
[929] | 734 | SuperClassWriter::addAttribute("_FillValue", 999999, &face_edges); |
---|
[924] | 735 | dim0.clear(); |
---|
| 736 | dim0.push_back(dimEdge); |
---|
| 737 | dim0.push_back(dimTwo); |
---|
[1456] | 738 | SuperClassWriter::addVariable(edge_faces, NC_INT, dim0, compressionLevel); |
---|
[924] | 739 | SuperClassWriter::addAttribute("cf_role", StdString("edge_face connectivity"), &edge_faces); |
---|
| 740 | SuperClassWriter::addAttribute("long_name", StdString("neighbor faces for edges"), &edge_faces); |
---|
| 741 | SuperClassWriter::addAttribute("start_index", 0, &edge_faces); |
---|
| 742 | SuperClassWriter::addAttribute("_FillValue", -999, &edge_faces); |
---|
| 743 | SuperClassWriter::addAttribute("comment", StdString("missing neighbor faces are indicated using _FillValue"), &edge_faces); |
---|
| 744 | dim0.clear(); |
---|
| 745 | dim0.push_back(dimFace); |
---|
| 746 | dim0.push_back(dimVertex); |
---|
[1456] | 747 | SuperClassWriter::addVariable(face_faces, NC_INT, dim0, compressionLevel); |
---|
[924] | 748 | SuperClassWriter::addAttribute("cf_role", StdString("face_face connectivity"), &face_faces); |
---|
| 749 | SuperClassWriter::addAttribute("long_name", StdString("Indicates which other faces neighbor each face"), &face_faces); |
---|
| 750 | SuperClassWriter::addAttribute("start_index", 0, &face_faces); |
---|
[929] | 751 | SuperClassWriter::addAttribute("_FillValue", 999999, &face_faces); |
---|
[924] | 752 | SuperClassWriter::addAttribute("flag_values", -1, &face_faces); |
---|
| 753 | SuperClassWriter::addAttribute("flag_meanings", StdString("out_of_mesh"), &face_faces); |
---|
[879] | 754 | } // domain->nvertex > 2 |
---|
[878] | 755 | |
---|
[879] | 756 | SuperClassWriter::definition_end(); |
---|
[878] | 757 | |
---|
[924] | 758 | std::vector<StdSize> startEdges(1) ; |
---|
| 759 | std::vector<StdSize> countEdges(1) ; |
---|
| 760 | std::vector<StdSize> startNodes(1) ; |
---|
| 761 | std::vector<StdSize> countNodes(1) ; |
---|
| 762 | std::vector<StdSize> startFaces(1) ; |
---|
| 763 | std::vector<StdSize> countFaces(1) ; |
---|
| 764 | std::vector<StdSize> startEdgeNodes(2) ; |
---|
| 765 | std::vector<StdSize> countEdgeNodes(2) ; |
---|
| 766 | std::vector<StdSize> startEdgeFaces(2) ; |
---|
| 767 | std::vector<StdSize> countEdgeFaces(2) ; |
---|
| 768 | std::vector<StdSize> startFaceConctv(2) ; |
---|
| 769 | std::vector<StdSize> countFaceConctv(2) ; |
---|
[902] | 770 | |
---|
[1494] | 771 | if (domain->nvertex == 1) |
---|
[879] | 772 | { |
---|
[1494] | 773 | if (domain->isEmpty()) |
---|
| 774 | { |
---|
| 775 | startNodes[0]=0 ; |
---|
| 776 | countNodes[0]=0 ; |
---|
| 777 | } |
---|
| 778 | else |
---|
| 779 | { |
---|
| 780 | startNodes[0] = domain->zoom_ibegin-domain->global_zoom_ibegin; |
---|
| 781 | countNodes[0] = domain->zoom_ni ; |
---|
| 782 | } |
---|
[924] | 783 | |
---|
[1494] | 784 | SuperClassWriter::writeData(domain->mesh->node_lat, node_y, isCollective, 0, &startNodes, &countNodes); |
---|
| 785 | SuperClassWriter::writeData(domain->mesh->node_lon, node_x, isCollective, 0, &startNodes, &countNodes); |
---|
| 786 | } |
---|
| 787 | else if (domain->nvertex == 2) |
---|
| 788 | { |
---|
| 789 | if (domain->isEmpty()) |
---|
| 790 | { |
---|
| 791 | startEdges[0]=0 ; |
---|
| 792 | countEdges[0]=0 ; |
---|
| 793 | startNodes[0]=0 ; |
---|
| 794 | countNodes[0]=0 ; |
---|
| 795 | startEdgeNodes[0]=0; |
---|
| 796 | startEdgeNodes[1]=0; |
---|
| 797 | countEdgeNodes[0]=0; |
---|
| 798 | countEdgeNodes[1]=0; |
---|
[924] | 799 | |
---|
[1494] | 800 | } |
---|
| 801 | else |
---|
| 802 | { |
---|
| 803 | startEdges[0] = domain->zoom_ibegin-domain->global_zoom_ibegin; |
---|
| 804 | countEdges[0] = domain->zoom_ni; |
---|
| 805 | startNodes[0] = domain->mesh->node_start; |
---|
| 806 | countNodes[0] = domain->mesh->node_count; |
---|
| 807 | startEdgeNodes[0] = domain->zoom_ibegin-domain->global_zoom_ibegin; |
---|
| 808 | startEdgeNodes[1] = 0; |
---|
| 809 | countEdgeNodes[0] = domain->zoom_ni; |
---|
| 810 | countEdgeNodes[1] = 2; |
---|
| 811 | } |
---|
| 812 | SuperClassWriter::writeData(domain->mesh->node_lat, node_y, isCollective, 0, &startNodes, &countNodes); |
---|
| 813 | SuperClassWriter::writeData(domain->mesh->node_lon, node_x, isCollective, 0, &startNodes, &countNodes); |
---|
| 814 | SuperClassWriter::writeData(domain->mesh->edge_lat, edge_y, isCollective, 0, &startEdges, &countEdges); |
---|
| 815 | SuperClassWriter::writeData(domain->mesh->edge_lon, edge_x, isCollective, 0, &startEdges, &countEdges); |
---|
| 816 | SuperClassWriter::writeData(domain->mesh->edge_nodes, edge_nodes, isCollective, 0, &startEdgeNodes, &countEdgeNodes); |
---|
| 817 | } |
---|
[879] | 818 | else |
---|
| 819 | { |
---|
[1494] | 820 | if (domain->isEmpty()) |
---|
| 821 | { |
---|
| 822 | startFaces[0] = 0 ; |
---|
| 823 | countFaces[0] = 0 ; |
---|
| 824 | startNodes[0] = 0; |
---|
| 825 | countNodes[0] = 0; |
---|
| 826 | startEdges[0] = 0; |
---|
| 827 | countEdges[0] = 0; |
---|
| 828 | startEdgeFaces[0] = 0; |
---|
| 829 | startEdgeFaces[1] = 0; |
---|
| 830 | countEdgeFaces[0] = 0; |
---|
| 831 | countEdgeFaces[1] = 0; |
---|
| 832 | startFaceConctv[0] = 0; |
---|
| 833 | startFaceConctv[1] = 0; |
---|
| 834 | countFaceConctv[0] = 0; |
---|
| 835 | countFaceConctv[1] = 0; |
---|
| 836 | } |
---|
| 837 | else |
---|
| 838 | { |
---|
| 839 | startFaces[0] = domain->zoom_ibegin-domain->global_zoom_ibegin; |
---|
| 840 | countFaces[0] = domain->zoom_ni ; |
---|
| 841 | startNodes[0] = domain->mesh->node_start; |
---|
| 842 | countNodes[0] = domain->mesh->node_count; |
---|
| 843 | startEdges[0] = domain->mesh->edge_start; |
---|
| 844 | countEdges[0] = domain->mesh->edge_count; |
---|
| 845 | startEdgeNodes[0] = domain->mesh->edge_start; |
---|
| 846 | startEdgeNodes[1] = 0; |
---|
| 847 | countEdgeNodes[0] = domain->mesh->edge_count; |
---|
| 848 | countEdgeNodes[1]= 2; |
---|
| 849 | startEdgeFaces[0] = domain->mesh->edge_start; |
---|
| 850 | startEdgeFaces[1]= 0; |
---|
| 851 | countEdgeFaces[0] = domain->mesh->edge_count; |
---|
| 852 | countEdgeFaces[1]= 2; |
---|
| 853 | startFaceConctv[0] = domain->zoom_ibegin-domain->global_zoom_ibegin; |
---|
| 854 | startFaceConctv[1] = 0; |
---|
| 855 | countFaceConctv[0] = domain->zoom_ni; |
---|
| 856 | countFaceConctv[1] = domain->nvertex; |
---|
| 857 | } |
---|
| 858 | SuperClassWriter::writeData(domain->mesh->node_lat, node_y, isCollective, 0, &startNodes, &countNodes); |
---|
| 859 | SuperClassWriter::writeData(domain->mesh->node_lon, node_x, isCollective, 0, &startNodes, &countNodes); |
---|
| 860 | SuperClassWriter::writeData(domain->mesh->edge_lat, edge_y, isCollective, 0, &startEdges, &countEdges); |
---|
| 861 | SuperClassWriter::writeData(domain->mesh->edge_lon, edge_x, isCollective, 0, &startEdges, &countEdges); |
---|
| 862 | SuperClassWriter::writeData(domain->mesh->edge_nodes, edge_nodes, isCollective, 0, &startEdgeNodes, &countEdgeNodes); |
---|
| 863 | SuperClassWriter::writeData(domain->mesh->face_lat, face_y, isCollective, 0, &startFaces, &countFaces); |
---|
| 864 | SuperClassWriter::writeData(domain->mesh->face_lon, face_x, isCollective, 0, &startFaces, &countFaces); |
---|
| 865 | SuperClassWriter::writeData(domain->mesh->face_nodes, face_nodes, isCollective, 0, &startFaceConctv, &countFaceConctv); |
---|
| 866 | SuperClassWriter::writeData(domain->mesh->face_edges, face_edges, isCollective, 0, &startFaceConctv, &countFaceConctv); |
---|
| 867 | SuperClassWriter::writeData(domain->mesh->edge_faces, edge_faces, isCollective, 0, &startEdgeFaces, &countEdgeFaces); |
---|
| 868 | SuperClassWriter::writeData(domain->mesh->face_faces, face_faces, isCollective, 0, &startFaceConctv, &countFaceConctv); |
---|
| 869 | } |
---|
[879] | 870 | SuperClassWriter::definition_start(); |
---|
[878] | 871 | |
---|
[879] | 872 | break; |
---|
| 873 | } // ONE_FILE |
---|
[878] | 874 | |
---|
[879] | 875 | case (MULTI_FILE) : |
---|
| 876 | { |
---|
[1624] | 877 | ERROR("CNc4DataOutput::writeDomain(domain)", |
---|
| 878 | << "[ type = multiple_file ]" |
---|
| 879 | << " is not yet implemented for UGRID files !"); |
---|
[879] | 880 | break; |
---|
| 881 | } |
---|
[878] | 882 | |
---|
[879] | 883 | default : |
---|
| 884 | ERROR("CNc4DataOutput::writeDomain(domain)", |
---|
| 885 | << "[ type = " << SuperClass::type << "]" |
---|
| 886 | << " not implemented yet !"); |
---|
| 887 | } // switch |
---|
| 888 | } // try |
---|
[878] | 889 | |
---|
[879] | 890 | catch (CNetCdfException& e) |
---|
| 891 | { |
---|
| 892 | StdString msg("On writing the domain : "); |
---|
| 893 | msg.append(domid); msg.append("\n"); |
---|
| 894 | msg.append("In the context : "); |
---|
| 895 | msg.append(context->getId()); msg.append("\n"); |
---|
| 896 | msg.append(e.what()); |
---|
[924] | 897 | ERROR("CNc4DataOutput::writeUnstructuredDomainUgrid(CDomain* domain)", << msg); |
---|
[879] | 898 | } |
---|
[878] | 899 | |
---|
[879] | 900 | domain->addRelFile(this->filename); |
---|
| 901 | } |
---|
[878] | 902 | |
---|
[879] | 903 | //-------------------------------------------------------------- |
---|
[878] | 904 | |
---|
[879] | 905 | void CNc4DataOutput::writeUnstructuredDomain(CDomain* domain) |
---|
[449] | 906 | { |
---|
| 907 | CContext* context = CContext::getCurrent() ; |
---|
| 908 | CContextServer* server=context->server ; |
---|
[488] | 909 | |
---|
[449] | 910 | if (domain->IsWritten(this->filename)) return; |
---|
| 911 | domain->checkAttributes(); |
---|
[488] | 912 | |
---|
| 913 | if (domain->isEmpty()) |
---|
[449] | 914 | if (SuperClass::type==MULTI_FILE) return ; |
---|
| 915 | |
---|
| 916 | std::vector<StdString> dim0, dim1; |
---|
[772] | 917 | StdString domid = domain->getDomainOutputName(); |
---|
[705] | 918 | if (isWrittenDomain(domid)) return ; |
---|
[774] | 919 | else setWrittenDomain(domid); |
---|
[705] | 920 | |
---|
[449] | 921 | StdString appendDomid = (singleDomain) ? "" : "_"+domid ; |
---|
| 922 | |
---|
[1430] | 923 | StdString lonName,latName, cellName ; |
---|
[1391] | 924 | if (domain->lon_name.isEmpty()) lonName = "lon"; |
---|
| 925 | else lonName = domain->lon_name; |
---|
| 926 | |
---|
| 927 | if (domain->lat_name.isEmpty()) latName = "lat"; |
---|
| 928 | else latName = domain->lat_name; |
---|
| 929 | |
---|
[1430] | 930 | if (!domain->dim_i_name.isEmpty()) cellName=domain->dim_i_name; |
---|
| 931 | else cellName="cell"; |
---|
| 932 | StdString dimXid = cellName+appendDomid; |
---|
[449] | 933 | StdString dimVertId = StdString("nvertex").append(appendDomid); |
---|
[488] | 934 | |
---|
[449] | 935 | string lonid,latid,bounds_lonid,bounds_latid ; |
---|
[611] | 936 | string areaId = "area" + appendDomid; |
---|
[449] | 937 | |
---|
[1158] | 938 | nc_type typePrec ; |
---|
| 939 | if (domain->prec.isEmpty()) typePrec = NC_FLOAT ; |
---|
| 940 | else if (domain->prec==4) typePrec = NC_FLOAT ; |
---|
| 941 | else if (domain->prec==8) typePrec = NC_DOUBLE ; |
---|
| 942 | |
---|
[1132] | 943 | int nvertex = (domain->nvertex.isEmpty()) ? 0 : domain->nvertex; |
---|
[1025] | 944 | |
---|
[1624] | 945 | CArray<int, 1>& indexToWrite = domain->localIndexToWriteOnServer; |
---|
[1132] | 946 | int nbWritten = indexToWrite.numElements(); |
---|
| 947 | CArray<double,1> writtenLat, writtenLon; |
---|
| 948 | CArray<double,2> writtenBndsLat, writtenBndsLon; |
---|
| 949 | CArray<double,1> writtenArea; |
---|
| 950 | |
---|
| 951 | if (domain->hasLonLat) |
---|
| 952 | { |
---|
| 953 | writtenLat.resize(nbWritten); |
---|
| 954 | writtenLon.resize(nbWritten); |
---|
| 955 | for (int idx = 0; idx < nbWritten; ++idx) |
---|
| 956 | { |
---|
[1624] | 957 | if (indexToWrite(idx) < 0) |
---|
| 958 | { |
---|
| 959 | writtenLat(idx) = -1.; |
---|
| 960 | writtenLon(idx) = -1.; |
---|
| 961 | } |
---|
| 962 | else |
---|
| 963 | { |
---|
| 964 | writtenLat(idx) = domain->latvalue(indexToWrite(idx)); |
---|
| 965 | writtenLon(idx) = domain->lonvalue(indexToWrite(idx)); |
---|
| 966 | } |
---|
[1132] | 967 | } |
---|
[1390] | 968 | } |
---|
[1132] | 969 | |
---|
[1390] | 970 | if (domain->hasBounds) |
---|
| 971 | { |
---|
| 972 | int nvertex = domain->nvertex, idx; |
---|
| 973 | writtenBndsLat.resize(nvertex, nbWritten); |
---|
| 974 | writtenBndsLon.resize(nvertex, nbWritten); |
---|
| 975 | CArray<double,2>& boundslat = domain->bounds_latvalue; |
---|
| 976 | CArray<double,2>& boundslon = domain->bounds_lonvalue; |
---|
| 977 | for (idx = 0; idx < nbWritten; ++idx) |
---|
| 978 | { |
---|
| 979 | for (int nv = 0; nv < nvertex; ++nv) |
---|
| 980 | { |
---|
[1624] | 981 | if (indexToWrite(idx) < 0) |
---|
[1132] | 982 | { |
---|
[1624] | 983 | writtenBndsLat(nv, idx) = -1.; |
---|
| 984 | writtenBndsLon(nv, idx) = -1.; |
---|
[1132] | 985 | } |
---|
[1390] | 986 | else |
---|
| 987 | { |
---|
[1624] | 988 | writtenBndsLat(nv, idx) = boundslat(nv, int(indexToWrite(idx))); |
---|
| 989 | writtenBndsLon(nv, idx) = boundslon(nv, int(indexToWrite(idx))); |
---|
[1390] | 990 | } |
---|
| 991 | } |
---|
[1132] | 992 | } |
---|
| 993 | } |
---|
| 994 | |
---|
| 995 | if (domain->hasArea) |
---|
| 996 | { |
---|
| 997 | writtenArea.resize(nbWritten); |
---|
| 998 | for (int idx = 0; idx < nbWritten; ++idx) |
---|
| 999 | { |
---|
[1624] | 1000 | if (indexToWrite(idx) < 0) |
---|
| 1001 | writtenArea(idx) = -1.; |
---|
| 1002 | else |
---|
| 1003 | writtenArea(idx) = domain->areavalue(indexToWrite(idx)); |
---|
[1132] | 1004 | } |
---|
| 1005 | } |
---|
| 1006 | |
---|
[498] | 1007 | try |
---|
[449] | 1008 | { |
---|
[498] | 1009 | switch (SuperClass::type) |
---|
| 1010 | { |
---|
| 1011 | case (MULTI_FILE) : |
---|
| 1012 | { |
---|
| 1013 | dim0.push_back(dimXid); |
---|
[1132] | 1014 | SuperClassWriter::addDimension(dimXid, domain->zoom_ni); |
---|
[488] | 1015 | |
---|
[1415] | 1016 | lonid = lonName+appendDomid; |
---|
| 1017 | latid = latName+appendDomid; |
---|
[1430] | 1018 | if (!domain->bounds_lon_name.isEmpty()) bounds_lonid = domain->bounds_lon_name; |
---|
| 1019 | else bounds_lonid = "bounds_"+lonName+appendDomid; |
---|
| 1020 | if (!domain->bounds_lat_name.isEmpty()) bounds_latid = domain->bounds_lat_name; |
---|
| 1021 | else bounds_latid = "bounds_"+latName+appendDomid; |
---|
| 1022 | |
---|
[665] | 1023 | if (domain->hasLonLat) |
---|
| 1024 | { |
---|
[1456] | 1025 | SuperClassWriter::addVariable(latid, typePrec, dim0, compressionLevel); |
---|
| 1026 | SuperClassWriter::addVariable(lonid, typePrec, dim0, compressionLevel); |
---|
[665] | 1027 | this->writeAxisAttributes(lonid, "", "longitude", "Longitude", "degrees_east", domid); |
---|
| 1028 | if (domain->hasBounds) SuperClassWriter::addAttribute("bounds",bounds_lonid, &lonid); |
---|
| 1029 | this->writeAxisAttributes(latid, "", "latitude", "Latitude", "degrees_north", domid); |
---|
| 1030 | if (domain->hasBounds) SuperClassWriter::addAttribute("bounds",bounds_latid, &latid); |
---|
| 1031 | if (domain->hasBounds) SuperClassWriter::addDimension(dimVertId, domain->nvertex); |
---|
| 1032 | } |
---|
[498] | 1033 | dim0.clear(); |
---|
| 1034 | if (domain->hasBounds) |
---|
| 1035 | { |
---|
| 1036 | dim0.push_back(dimXid); |
---|
| 1037 | dim0.push_back(dimVertId); |
---|
[1456] | 1038 | SuperClassWriter::addVariable(bounds_lonid, typePrec, dim0, compressionLevel); |
---|
| 1039 | SuperClassWriter::addVariable(bounds_latid, typePrec, dim0, compressionLevel); |
---|
[498] | 1040 | } |
---|
| 1041 | |
---|
| 1042 | dim0.clear(); |
---|
[449] | 1043 | dim0.push_back(dimXid); |
---|
[611] | 1044 | if (domain->hasArea) |
---|
| 1045 | { |
---|
[1456] | 1046 | SuperClassWriter::addVariable(areaId, typePrec, dim0, compressionLevel); |
---|
[614] | 1047 | SuperClassWriter::addAttribute("standard_name", StdString("cell_area"), &areaId); |
---|
[611] | 1048 | SuperClassWriter::addAttribute("units", StdString("m2"), &areaId); |
---|
| 1049 | } |
---|
| 1050 | |
---|
[498] | 1051 | SuperClassWriter::definition_end(); |
---|
[449] | 1052 | |
---|
[665] | 1053 | if (domain->hasLonLat) |
---|
[498] | 1054 | { |
---|
[1132] | 1055 | SuperClassWriter::writeData(writtenLat, latid, isCollective, 0); |
---|
| 1056 | SuperClassWriter::writeData(writtenLon, lonid, isCollective, 0); |
---|
[665] | 1057 | if (domain->hasBounds) |
---|
| 1058 | { |
---|
[1132] | 1059 | SuperClassWriter::writeData(writtenBndsLon, bounds_lonid, isCollective, 0); |
---|
| 1060 | SuperClassWriter::writeData(writtenBndsLat, bounds_latid, isCollective, 0); |
---|
[665] | 1061 | } |
---|
[498] | 1062 | } |
---|
[611] | 1063 | |
---|
| 1064 | if (domain->hasArea) |
---|
[1132] | 1065 | SuperClassWriter::writeData(writtenArea, areaId, isCollective, 0); |
---|
[611] | 1066 | |
---|
[498] | 1067 | SuperClassWriter::definition_start(); |
---|
| 1068 | break ; |
---|
| 1069 | } |
---|
[488] | 1070 | |
---|
[498] | 1071 | case (ONE_FILE) : |
---|
| 1072 | { |
---|
[1415] | 1073 | lonid = lonName+appendDomid; |
---|
| 1074 | latid = latName+appendDomid; |
---|
[1430] | 1075 | if (!domain->bounds_lon_name.isEmpty()) bounds_lonid = domain->bounds_lon_name; |
---|
| 1076 | else bounds_lonid = "bounds_"+lonName+appendDomid; |
---|
| 1077 | if (!domain->bounds_lat_name.isEmpty()) bounds_latid = domain->bounds_lat_name; |
---|
| 1078 | else bounds_latid = "bounds_"+latName+appendDomid; |
---|
[1391] | 1079 | |
---|
[498] | 1080 | dim0.push_back(dimXid); |
---|
[1132] | 1081 | SuperClassWriter::addDimension(dimXid, domain->ni_glo); |
---|
[665] | 1082 | if (domain->hasLonLat) |
---|
| 1083 | { |
---|
[1456] | 1084 | SuperClassWriter::addVariable(latid, typePrec, dim0, compressionLevel); |
---|
| 1085 | SuperClassWriter::addVariable(lonid, typePrec, dim0, compressionLevel); |
---|
[665] | 1086 | |
---|
| 1087 | this->writeAxisAttributes(lonid, "", "longitude", "Longitude", "degrees_east", domid); |
---|
| 1088 | if (domain->hasBounds) SuperClassWriter::addAttribute("bounds",bounds_lonid, &lonid); |
---|
| 1089 | this->writeAxisAttributes(latid, "", "latitude", "Latitude", "degrees_north", domid); |
---|
| 1090 | if (domain->hasBounds) SuperClassWriter::addAttribute("bounds",bounds_latid, &latid); |
---|
[1025] | 1091 | if (domain->hasBounds) SuperClassWriter::addDimension(dimVertId, nvertex); |
---|
[665] | 1092 | } |
---|
[498] | 1093 | dim0.clear(); |
---|
[449] | 1094 | |
---|
[498] | 1095 | if (domain->hasBounds) |
---|
| 1096 | { |
---|
| 1097 | dim0.push_back(dimXid); |
---|
| 1098 | dim0.push_back(dimVertId); |
---|
[1456] | 1099 | SuperClassWriter::addVariable(bounds_lonid, typePrec, dim0, compressionLevel); |
---|
| 1100 | SuperClassWriter::addVariable(bounds_latid, typePrec, dim0, compressionLevel); |
---|
[498] | 1101 | } |
---|
[488] | 1102 | |
---|
[611] | 1103 | if (domain->hasArea) |
---|
| 1104 | { |
---|
| 1105 | dim0.clear(); |
---|
| 1106 | dim0.push_back(dimXid); |
---|
[1456] | 1107 | SuperClassWriter::addVariable(areaId, typePrec, dim0, compressionLevel); |
---|
[614] | 1108 | SuperClassWriter::addAttribute("standard_name", StdString("cell_area"), &areaId); |
---|
[611] | 1109 | SuperClassWriter::addAttribute("units", StdString("m2"), &areaId); |
---|
| 1110 | } |
---|
| 1111 | |
---|
[498] | 1112 | SuperClassWriter::definition_end(); |
---|
[488] | 1113 | |
---|
[498] | 1114 | std::vector<StdSize> start(1), startBounds(2) ; |
---|
| 1115 | std::vector<StdSize> count(1), countBounds(2) ; |
---|
| 1116 | if (domain->isEmpty()) |
---|
| 1117 | { |
---|
| 1118 | start[0]=0 ; |
---|
| 1119 | count[0]=0 ; |
---|
| 1120 | startBounds[1]=0 ; |
---|
[1025] | 1121 | countBounds[1]=nvertex ; |
---|
[498] | 1122 | startBounds[0]=0 ; |
---|
| 1123 | countBounds[0]=0 ; |
---|
| 1124 | } |
---|
| 1125 | else |
---|
| 1126 | { |
---|
[1132] | 1127 | start[0]=domain->zoom_ibegin - domain->global_zoom_ibegin; |
---|
| 1128 | count[0]=domain->zoom_ni; |
---|
| 1129 | startBounds[0]=domain->zoom_ibegin-domain->global_zoom_ibegin; |
---|
[498] | 1130 | startBounds[1]=0 ; |
---|
[1132] | 1131 | countBounds[0]=domain->zoom_ni; |
---|
[1025] | 1132 | countBounds[1]=nvertex ; |
---|
[498] | 1133 | } |
---|
[665] | 1134 | |
---|
| 1135 | if (domain->hasLonLat) |
---|
[498] | 1136 | { |
---|
[1132] | 1137 | SuperClassWriter::writeData(writtenLat, latid, isCollective, 0,&start,&count); |
---|
| 1138 | SuperClassWriter::writeData(writtenLon, lonid, isCollective, 0,&start,&count); |
---|
[665] | 1139 | if (domain->hasBounds) |
---|
| 1140 | { |
---|
[1132] | 1141 | SuperClassWriter::writeData(writtenBndsLon, bounds_lonid, isCollective, 0,&startBounds,&countBounds); |
---|
| 1142 | SuperClassWriter::writeData(writtenBndsLat, bounds_latid, isCollective, 0,&startBounds,&countBounds); |
---|
[665] | 1143 | } |
---|
[498] | 1144 | } |
---|
[488] | 1145 | |
---|
[611] | 1146 | if (domain->hasArea) |
---|
[1132] | 1147 | SuperClassWriter::writeData(writtenArea, areaId, isCollective, 0, &start, &count); |
---|
[488] | 1148 | |
---|
[498] | 1149 | SuperClassWriter::definition_start(); |
---|
[488] | 1150 | |
---|
[498] | 1151 | break; |
---|
| 1152 | } |
---|
| 1153 | default : |
---|
| 1154 | ERROR("CNc4DataOutput::writeDomain(domain)", |
---|
| 1155 | << "[ type = " << SuperClass::type << "]" |
---|
| 1156 | << " not implemented yet !"); |
---|
| 1157 | } |
---|
[219] | 1158 | } |
---|
[498] | 1159 | catch (CNetCdfException& e) |
---|
| 1160 | { |
---|
| 1161 | StdString msg("On writing the domain : "); |
---|
| 1162 | msg.append(domid); msg.append("\n"); |
---|
| 1163 | msg.append("In the context : "); |
---|
| 1164 | msg.append(context->getId()); msg.append("\n"); |
---|
| 1165 | msg.append(e.what()); |
---|
| 1166 | ERROR("CNc4DataOutput::writeUnstructuredDomain(CDomain* domain)", << msg); |
---|
| 1167 | } |
---|
[219] | 1168 | domain->addRelFile(this->filename); |
---|
| 1169 | } |
---|
| 1170 | //-------------------------------------------------------------- |
---|
| 1171 | |
---|
[347] | 1172 | void CNc4DataOutput::writeAxis_(CAxis* axis) |
---|
[219] | 1173 | { |
---|
[1030] | 1174 | if (axis->IsWritten(this->filename)) return; |
---|
| 1175 | axis->checkAttributes(); |
---|
[488] | 1176 | |
---|
[1129] | 1177 | axis->computeWrittenIndex(); |
---|
[1249] | 1178 | axis->computeWrittenCompressedIndex(comm_file); |
---|
[1129] | 1179 | |
---|
[1509] | 1180 | int zoom_size = (MULTI_FILE == SuperClass::type) ? axis->zoom_n.getValue() |
---|
| 1181 | : axis->global_zoom_n.getValue(); |
---|
[1099] | 1182 | |
---|
[1235] | 1183 | int zoom_count = axis->zoom_n; |
---|
| 1184 | int zoom_begin = axis->zoom_begin; |
---|
| 1185 | // int zoom_begin = (MULTI_FILE == SuperClass::type) ? axis->global_zoom_begin |
---|
| 1186 | // : axis->zoom_begin; |
---|
| 1187 | |
---|
[1099] | 1188 | if ((0 == axis->zoom_n) && (MULTI_FILE == SuperClass::type)) return; |
---|
| 1189 | |
---|
[1030] | 1190 | std::vector<StdString> dims; |
---|
| 1191 | StdString axisid = axis->getAxisOutputName(); |
---|
[1435] | 1192 | StdString axisDim, axisBoundsId; |
---|
[1030] | 1193 | if (isWrittenAxis(axisid)) return ; |
---|
| 1194 | else setWrittenAxis(axisid); |
---|
[705] | 1195 | |
---|
[1158] | 1196 | nc_type typePrec ; |
---|
| 1197 | if (axis->prec.isEmpty()) typePrec = NC_FLOAT ; |
---|
[1235] | 1198 | else if (axis->prec==4) typePrec = NC_FLOAT ; |
---|
[1158] | 1199 | else if (axis->prec==8) typePrec = NC_DOUBLE ; |
---|
| 1200 | |
---|
| 1201 | if (!axis->label.isEmpty()) typePrec = NC_CHAR ; |
---|
| 1202 | string strId="str_len" ; |
---|
[1030] | 1203 | try |
---|
| 1204 | { |
---|
[1433] | 1205 | if (axis->dim_name.isEmpty()) axisDim = axisid; |
---|
| 1206 | else axisDim=axis->dim_name.getValue(); |
---|
| 1207 | SuperClassWriter::addDimension(axisDim, zoom_size); |
---|
| 1208 | dims.push_back(axisDim); |
---|
| 1209 | |
---|
[1439] | 1210 | if (!axis->label.isEmpty() && !SuperClassWriter::dimExist(strId)) SuperClassWriter::addDimension(strId, stringArrayLen); |
---|
[1433] | 1211 | |
---|
[1435] | 1212 | if (axis->hasValue || !axis->label.isEmpty()) |
---|
[816] | 1213 | { |
---|
[1158] | 1214 | if (!axis->label.isEmpty()) dims.push_back(strId); |
---|
[1430] | 1215 | |
---|
[1456] | 1216 | SuperClassWriter::addVariable(axisid, typePrec, dims, compressionLevel); |
---|
[219] | 1217 | |
---|
[1030] | 1218 | if (!axis->name.isEmpty()) |
---|
| 1219 | SuperClassWriter::addAttribute("name", axis->name.getValue(), &axisid); |
---|
[219] | 1220 | |
---|
[1030] | 1221 | if (!axis->standard_name.isEmpty()) |
---|
| 1222 | SuperClassWriter::addAttribute("standard_name", axis->standard_name.getValue(), &axisid); |
---|
[540] | 1223 | |
---|
[1030] | 1224 | if (!axis->long_name.isEmpty()) |
---|
| 1225 | SuperClassWriter::addAttribute("long_name", axis->long_name.getValue(), &axisid); |
---|
[219] | 1226 | |
---|
[1030] | 1227 | if (!axis->unit.isEmpty()) |
---|
| 1228 | SuperClassWriter::addAttribute("units", axis->unit.getValue(), &axisid); |
---|
[219] | 1229 | |
---|
[1430] | 1230 | if (!axis->axis_type.isEmpty()) |
---|
| 1231 | { |
---|
| 1232 | switch(axis->axis_type) |
---|
| 1233 | { |
---|
| 1234 | case CAxis::axis_type_attr::X : |
---|
| 1235 | SuperClassWriter::addAttribute("axis", string("X"), &axisid); |
---|
| 1236 | break; |
---|
| 1237 | case CAxis::axis_type_attr::Y : |
---|
| 1238 | SuperClassWriter::addAttribute("axis", string("Y"), &axisid); |
---|
| 1239 | break; |
---|
| 1240 | case CAxis::axis_type_attr::Z : |
---|
| 1241 | SuperClassWriter::addAttribute("axis", string("Z"), &axisid); |
---|
| 1242 | break; |
---|
| 1243 | case CAxis::axis_type_attr::T : |
---|
| 1244 | SuperClassWriter::addAttribute("axis", string("T"), &axisid); |
---|
| 1245 | break; |
---|
| 1246 | } |
---|
| 1247 | } |
---|
| 1248 | |
---|
[1030] | 1249 | if (!axis->positive.isEmpty()) |
---|
| 1250 | { |
---|
| 1251 | SuperClassWriter::addAttribute("positive", |
---|
| 1252 | (axis->positive == CAxis::positive_attr::up) ? string("up") : string("down"), |
---|
| 1253 | &axisid); |
---|
| 1254 | } |
---|
[399] | 1255 | |
---|
[1266] | 1256 | if (!axis->formula.isEmpty()) |
---|
| 1257 | SuperClassWriter::addAttribute("formula", axis->formula.getValue(), &axisid); |
---|
| 1258 | |
---|
| 1259 | if (!axis->formula_term.isEmpty()) |
---|
| 1260 | SuperClassWriter::addAttribute("formula_term", axis->formula_term.getValue(), &axisid); |
---|
| 1261 | |
---|
[1435] | 1262 | axisBoundsId = (axis->bounds_name.isEmpty()) ? axisid + "_bounds" : axis->bounds_name; |
---|
[1249] | 1263 | if (!axis->bounds.isEmpty() && axis->label.isEmpty()) |
---|
[1030] | 1264 | { |
---|
| 1265 | dims.push_back("axis_nbounds"); |
---|
[1456] | 1266 | SuperClassWriter::addVariable(axisBoundsId, typePrec, dims, compressionLevel); |
---|
[1030] | 1267 | SuperClassWriter::addAttribute("bounds", axisBoundsId, &axisid); |
---|
[1288] | 1268 | |
---|
| 1269 | if (!axis->standard_name.isEmpty()) |
---|
| 1270 | SuperClassWriter::addAttribute("standard_name", axis->standard_name.getValue(), &axisBoundsId); |
---|
| 1271 | |
---|
| 1272 | if (!axis->unit.isEmpty()) |
---|
| 1273 | SuperClassWriter::addAttribute("units", axis->unit.getValue(), &axisBoundsId); |
---|
| 1274 | |
---|
[1266] | 1275 | if (!axis->formula_bounds.isEmpty()) |
---|
[1288] | 1276 | SuperClassWriter::addAttribute("formula", axis->formula_bounds.getValue(), &axisBoundsId); |
---|
[1266] | 1277 | |
---|
| 1278 | if (!axis->formula_term_bounds.isEmpty()) |
---|
[1288] | 1279 | SuperClassWriter::addAttribute("formula_term", axis->formula_term_bounds.getValue(), &axisBoundsId); |
---|
[1030] | 1280 | } |
---|
[1435] | 1281 | } |
---|
[816] | 1282 | |
---|
[1435] | 1283 | SuperClassWriter::definition_end(); |
---|
| 1284 | |
---|
[1624] | 1285 | CArray<int, 1>& indexToWrite = axis->localIndexToWriteOnServer; |
---|
[1435] | 1286 | int nbWritten = indexToWrite.numElements(); |
---|
| 1287 | CArray<double,1> axis_value(indexToWrite.numElements()); |
---|
| 1288 | if (!axis->value.isEmpty()) |
---|
| 1289 | { |
---|
[1421] | 1290 | for (int i = 0; i < nbWritten; i++) |
---|
| 1291 | { |
---|
[1624] | 1292 | if (indexToWrite(i) < 0) |
---|
| 1293 | axis_value(i) = -1; // Some value in case of a hole |
---|
| 1294 | else |
---|
[1421] | 1295 | axis_value(i) = axis->value(indexToWrite(i)); |
---|
| 1296 | } |
---|
[1435] | 1297 | } |
---|
| 1298 | CArray<double,2> axis_bounds; |
---|
| 1299 | CArray<string,1> axis_label; |
---|
| 1300 | if (!axis->label.isEmpty()) |
---|
| 1301 | { |
---|
| 1302 | axis_label.resize(indexToWrite.numElements()); |
---|
| 1303 | for (int i = 0; i < nbWritten; i++) |
---|
[1235] | 1304 | { |
---|
[1624] | 1305 | if (indexToWrite(i) < 0) |
---|
| 1306 | axis_label(i) = boost::lexical_cast<string>(-1); // Some value in case of a hole |
---|
| 1307 | else |
---|
[1435] | 1308 | axis_label(i) = axis->label(indexToWrite(i)); |
---|
[1235] | 1309 | } |
---|
[1435] | 1310 | } |
---|
[1129] | 1311 | |
---|
[1435] | 1312 | switch (SuperClass::type) |
---|
| 1313 | { |
---|
| 1314 | case MULTI_FILE: |
---|
[1030] | 1315 | { |
---|
[1435] | 1316 | if (axis->label.isEmpty()) |
---|
[1437] | 1317 | { |
---|
| 1318 | if (!axis->value.isEmpty()) |
---|
| 1319 | SuperClassWriter::writeData(axis_value, axisid, isCollective, 0); |
---|
[633] | 1320 | |
---|
[1437] | 1321 | if (!axis->bounds.isEmpty()) |
---|
| 1322 | { |
---|
[1129] | 1323 | axis_bounds.resize(2, indexToWrite.numElements()); |
---|
| 1324 | for (int i = 0; i < nbWritten; ++i) |
---|
| 1325 | { |
---|
[1624] | 1326 | if (indexToWrite(i) < 0) |
---|
[1421] | 1327 | { |
---|
[1624] | 1328 | axis_bounds(0, i) = -1.; // Some value in case of a hole |
---|
| 1329 | axis_bounds(1, i) = -1.; |
---|
[1421] | 1330 | } |
---|
| 1331 | else |
---|
| 1332 | { |
---|
[1624] | 1333 | axis_bounds(0, i) = axis->bounds(0, int(indexToWrite(i))); |
---|
| 1334 | axis_bounds(1, i) = axis->bounds(1, int(indexToWrite(i))); |
---|
[1421] | 1335 | } |
---|
[1129] | 1336 | } |
---|
[1437] | 1337 | SuperClassWriter::writeData(axis_bounds, axisBoundsId, isCollective, 0); |
---|
| 1338 | } |
---|
[1435] | 1339 | } |
---|
[1437] | 1340 | else |
---|
[1435] | 1341 | SuperClassWriter::writeData(axis_label, axisid, isCollective, 0); |
---|
| 1342 | |
---|
| 1343 | SuperClassWriter::definition_start(); |
---|
| 1344 | break; |
---|
| 1345 | } |
---|
| 1346 | case ONE_FILE: |
---|
| 1347 | { |
---|
| 1348 | std::vector<StdSize> start(1), startBounds(2) ; |
---|
| 1349 | std::vector<StdSize> count(1), countBounds(2) ; |
---|
| 1350 | start[0] = startBounds[0] = zoom_begin - axis->global_zoom_begin; |
---|
| 1351 | count[0] = countBounds[0] = zoom_count; // zoom_size |
---|
| 1352 | startBounds[1] = 0; |
---|
| 1353 | countBounds[1] = 2; |
---|
| 1354 | |
---|
| 1355 | if (axis->label.isEmpty()) |
---|
[1437] | 1356 | { |
---|
| 1357 | if (!axis->value.isEmpty()) |
---|
| 1358 | SuperClassWriter::writeData(axis_value, axisid, isCollective, 0, &start, &count); |
---|
[1435] | 1359 | |
---|
[1437] | 1360 | if (!axis->bounds.isEmpty()) |
---|
[1235] | 1361 | { |
---|
[1437] | 1362 | axis_bounds.resize(2, indexToWrite.numElements()); |
---|
| 1363 | for (int i = 0; i < nbWritten; ++i) |
---|
[1435] | 1364 | { |
---|
[1624] | 1365 | if (indexToWrite(i) < 0) |
---|
[1437] | 1366 | { |
---|
[1624] | 1367 | axis_bounds(0, i) = -1.; |
---|
| 1368 | axis_bounds(1, i) = -1.; |
---|
[1437] | 1369 | } |
---|
| 1370 | else |
---|
| 1371 | { |
---|
[1624] | 1372 | axis_bounds(0, i) = axis->bounds(0, int(indexToWrite(i))); |
---|
| 1373 | axis_bounds(1, i) = axis->bounds(1, int(indexToWrite(i))); |
---|
[1437] | 1374 | } |
---|
[1435] | 1375 | } |
---|
[1437] | 1376 | SuperClassWriter::writeData(axis_bounds, axisBoundsId, isCollective, 0, &startBounds, &countBounds); |
---|
[1235] | 1377 | } |
---|
[1435] | 1378 | } |
---|
[1437] | 1379 | else |
---|
[1435] | 1380 | { |
---|
| 1381 | std::vector<StdSize> startLabel(2), countLabel(2); |
---|
| 1382 | startLabel[0] = start[0]; startLabel[1] = 0; |
---|
| 1383 | countLabel[0] = count[0]; countLabel[1] = stringArrayLen; |
---|
| 1384 | SuperClassWriter::writeData(axis_label, axisid, isCollective, 0, &startLabel, &countLabel); |
---|
| 1385 | } |
---|
[609] | 1386 | |
---|
[1435] | 1387 | SuperClassWriter::definition_start(); |
---|
| 1388 | |
---|
| 1389 | break; |
---|
[609] | 1390 | } |
---|
[1435] | 1391 | default : |
---|
| 1392 | ERROR("CNc4DataOutput::writeAxis_(CAxis* axis)", |
---|
| 1393 | << "[ type = " << SuperClass::type << "]" |
---|
| 1394 | << " not implemented yet !"); |
---|
[609] | 1395 | } |
---|
[1030] | 1396 | } |
---|
| 1397 | catch (CNetCdfException& e) |
---|
| 1398 | { |
---|
| 1399 | StdString msg("On writing the axis : "); |
---|
| 1400 | msg.append(axisid); msg.append("\n"); |
---|
| 1401 | msg.append("In the context : "); |
---|
| 1402 | CContext* context = CContext::getCurrent() ; |
---|
| 1403 | msg.append(context->getId()); msg.append("\n"); |
---|
| 1404 | msg.append(e.what()); |
---|
| 1405 | ERROR("CNc4DataOutput::writeAxis_(CAxis* axis)", << msg); |
---|
| 1406 | } |
---|
[1158] | 1407 | axis->addRelFile(this->filename); |
---|
[391] | 1408 | } |
---|
[488] | 1409 | |
---|
[887] | 1410 | void CNc4DataOutput::writeScalar_(CScalar* scalar) |
---|
| 1411 | { |
---|
| 1412 | if (scalar->IsWritten(this->filename)) return; |
---|
| 1413 | scalar->checkAttributes(); |
---|
| 1414 | int scalarSize = 1; |
---|
| 1415 | |
---|
| 1416 | StdString scalaId = scalar->getScalarOutputName(); |
---|
[1430] | 1417 | StdString boundsId; |
---|
[887] | 1418 | if (isWrittenAxis(scalaId)) return ; |
---|
| 1419 | else setWrittenAxis(scalaId); |
---|
| 1420 | |
---|
[1158] | 1421 | nc_type typePrec ; |
---|
| 1422 | if (scalar->prec.isEmpty()) typePrec = NC_FLOAT ; |
---|
| 1423 | else if (scalar->prec==4) typePrec = NC_FLOAT ; |
---|
| 1424 | else if (scalar->prec==8) typePrec = NC_DOUBLE ; |
---|
| 1425 | |
---|
[1435] | 1426 | if (!scalar->label.isEmpty()) typePrec = NC_CHAR ; |
---|
| 1427 | string strId="str_len" ; |
---|
| 1428 | |
---|
[887] | 1429 | try |
---|
| 1430 | { |
---|
[1439] | 1431 | if (!scalar->label.isEmpty() && !SuperClassWriter::dimExist(strId)) SuperClassWriter::addDimension(strId, stringArrayLen); |
---|
[1435] | 1432 | |
---|
| 1433 | if (!scalar->value.isEmpty() || !scalar->label.isEmpty()) |
---|
[887] | 1434 | { |
---|
[1430] | 1435 | std::vector<StdString> dims; |
---|
| 1436 | StdString scalarDim = scalaId; |
---|
| 1437 | |
---|
[1435] | 1438 | if (!scalar->label.isEmpty()) dims.push_back(strId); |
---|
| 1439 | |
---|
[1158] | 1440 | SuperClassWriter::addVariable(scalaId, typePrec, dims); |
---|
[887] | 1441 | |
---|
| 1442 | if (!scalar->name.isEmpty()) |
---|
| 1443 | SuperClassWriter::addAttribute("name", scalar->name.getValue(), &scalaId); |
---|
| 1444 | |
---|
| 1445 | if (!scalar->standard_name.isEmpty()) |
---|
| 1446 | SuperClassWriter::addAttribute("standard_name", scalar->standard_name.getValue(), &scalaId); |
---|
| 1447 | |
---|
| 1448 | if (!scalar->long_name.isEmpty()) |
---|
| 1449 | SuperClassWriter::addAttribute("long_name", scalar->long_name.getValue(), &scalaId); |
---|
| 1450 | |
---|
| 1451 | if (!scalar->unit.isEmpty()) |
---|
| 1452 | SuperClassWriter::addAttribute("units", scalar->unit.getValue(), &scalaId); |
---|
| 1453 | |
---|
[1430] | 1454 | if (!scalar->axis_type.isEmpty()) |
---|
| 1455 | { |
---|
| 1456 | switch(scalar->axis_type) |
---|
| 1457 | { |
---|
| 1458 | case CScalar::axis_type_attr::X : |
---|
| 1459 | SuperClassWriter::addAttribute("axis", string("X"), &scalaId); |
---|
| 1460 | break; |
---|
| 1461 | case CScalar::axis_type_attr::Y : |
---|
| 1462 | SuperClassWriter::addAttribute("axis", string("Y"), &scalaId); |
---|
| 1463 | break; |
---|
| 1464 | case CScalar::axis_type_attr::Z : |
---|
| 1465 | SuperClassWriter::addAttribute("axis", string("Z"), &scalaId); |
---|
| 1466 | break; |
---|
| 1467 | case CScalar::axis_type_attr::T : |
---|
| 1468 | SuperClassWriter::addAttribute("axis", string("T"), &scalaId); |
---|
| 1469 | break; |
---|
| 1470 | } |
---|
| 1471 | } |
---|
| 1472 | |
---|
[1435] | 1473 | if (!scalar->positive.isEmpty()) |
---|
[1430] | 1474 | { |
---|
[1435] | 1475 | SuperClassWriter::addAttribute("positive", |
---|
| 1476 | (scalar->positive == CScalar::positive_attr::up) ? string("up") : string("down"), |
---|
| 1477 | &scalaId); |
---|
| 1478 | } |
---|
| 1479 | |
---|
| 1480 | if (!scalar->bounds.isEmpty() && scalar->label.isEmpty()) |
---|
| 1481 | { |
---|
[1436] | 1482 | dims.clear(); |
---|
| 1483 | dims.push_back("axis_nbounds"); |
---|
[1435] | 1484 | boundsId = (scalar->bounds_name.isEmpty()) ? (scalaId + "_bounds") : scalar->bounds_name.getValue(); |
---|
[1430] | 1485 | SuperClassWriter::addVariable(boundsId, typePrec, dims); |
---|
[1436] | 1486 | SuperClassWriter::addAttribute("bounds", boundsId, &scalaId); |
---|
[1430] | 1487 | } |
---|
| 1488 | |
---|
[887] | 1489 | SuperClassWriter::definition_end(); |
---|
| 1490 | |
---|
| 1491 | switch (SuperClass::type) |
---|
| 1492 | { |
---|
| 1493 | case MULTI_FILE: |
---|
| 1494 | { |
---|
| 1495 | CArray<double,1> scalarValue(scalarSize); |
---|
[1435] | 1496 | CArray<string,1> scalarLabel(scalarSize); |
---|
[1436] | 1497 | CArray<double,1> scalarBounds(scalarSize*2); |
---|
[1435] | 1498 | |
---|
| 1499 | if (!scalar->value.isEmpty() && scalar->label.isEmpty()) |
---|
[1430] | 1500 | { |
---|
[1435] | 1501 | scalarValue(0) = scalar->value; |
---|
| 1502 | SuperClassWriter::writeData(scalarValue, scalaId, isCollective, 0); |
---|
| 1503 | } |
---|
| 1504 | |
---|
| 1505 | if (!scalar->bounds.isEmpty() && scalar->label.isEmpty()) |
---|
| 1506 | { |
---|
[1436] | 1507 | scalarBounds(0) = scalar->bounds(0); |
---|
| 1508 | scalarBounds(1) = scalar->bounds(1); |
---|
| 1509 | SuperClassWriter::writeData(scalarBounds, boundsId, isCollective, 0); |
---|
[1430] | 1510 | } |
---|
[1435] | 1511 | |
---|
| 1512 | if (!scalar->label.isEmpty()) |
---|
| 1513 | { |
---|
| 1514 | scalarLabel(0) = scalar->label; |
---|
| 1515 | SuperClassWriter::writeData(scalarLabel, scalaId, isCollective, 0); |
---|
| 1516 | } |
---|
| 1517 | |
---|
[887] | 1518 | SuperClassWriter::definition_start(); |
---|
| 1519 | |
---|
| 1520 | break; |
---|
| 1521 | } |
---|
| 1522 | case ONE_FILE: |
---|
| 1523 | { |
---|
| 1524 | CArray<double,1> scalarValue(scalarSize); |
---|
[1435] | 1525 | CArray<string,1> scalarLabel(scalarSize); |
---|
[1436] | 1526 | CArray<double,1> scalarBounds(scalarSize*2); |
---|
[887] | 1527 | |
---|
| 1528 | std::vector<StdSize> start(1); |
---|
| 1529 | std::vector<StdSize> count(1); |
---|
| 1530 | start[0] = 0; |
---|
| 1531 | count[0] = 1; |
---|
[1435] | 1532 | if (!scalar->value.isEmpty() && scalar->label.isEmpty()) |
---|
[1430] | 1533 | { |
---|
[1435] | 1534 | scalarValue(0) = scalar->value; |
---|
| 1535 | SuperClassWriter::writeData(scalarValue, scalaId, isCollective, 0, &start, &count); |
---|
| 1536 | } |
---|
| 1537 | if (!scalar->bounds.isEmpty() && scalar->label.isEmpty()) |
---|
| 1538 | { |
---|
[1436] | 1539 | scalarBounds(0) = scalar->bounds(0); |
---|
| 1540 | scalarBounds(1) = scalar->bounds(1); |
---|
| 1541 | count[0] = 2; |
---|
| 1542 | SuperClassWriter::writeData(scalarBounds, boundsId, isCollective, 0, &start, &count); |
---|
[1430] | 1543 | } |
---|
[1435] | 1544 | if (!scalar->label.isEmpty()) |
---|
| 1545 | { |
---|
| 1546 | scalarLabel(0) = scalar->label; |
---|
| 1547 | count[0] = stringArrayLen; |
---|
| 1548 | SuperClassWriter::writeData(scalarLabel, scalaId, isCollective, 0, &start, &count); |
---|
| 1549 | } |
---|
| 1550 | |
---|
[887] | 1551 | SuperClassWriter::definition_start(); |
---|
| 1552 | |
---|
| 1553 | break; |
---|
| 1554 | } |
---|
| 1555 | default : |
---|
| 1556 | ERROR("CNc4DataOutput::writeAxis_(CAxis* scalar)", |
---|
| 1557 | << "[ type = " << SuperClass::type << "]" |
---|
| 1558 | << " not implemented yet !"); |
---|
| 1559 | } |
---|
| 1560 | } |
---|
| 1561 | } |
---|
| 1562 | catch (CNetCdfException& e) |
---|
| 1563 | { |
---|
| 1564 | StdString msg("On writing the scalar : "); |
---|
| 1565 | msg.append(scalaId); msg.append("\n"); |
---|
| 1566 | msg.append("In the context : "); |
---|
| 1567 | CContext* context = CContext::getCurrent() ; |
---|
| 1568 | msg.append(context->getId()); msg.append("\n"); |
---|
| 1569 | msg.append(e.what()); |
---|
| 1570 | ERROR("CNc4DataOutput::writeScalar_(CScalar* scalar)", << msg); |
---|
| 1571 | } |
---|
| 1572 | scalar->addRelFile(this->filename); |
---|
| 1573 | } |
---|
| 1574 | |
---|
[676] | 1575 | //-------------------------------------------------------------- |
---|
| 1576 | |
---|
| 1577 | void CNc4DataOutput::writeGridCompressed_(CGrid* grid) |
---|
| 1578 | { |
---|
| 1579 | if (grid->isScalarGrid() || grid->isWrittenCompressed(this->filename)) return; |
---|
| 1580 | |
---|
| 1581 | try |
---|
| 1582 | { |
---|
[887] | 1583 | CArray<int,1> axisDomainOrder = grid->axis_domain_order; |
---|
[676] | 1584 | std::vector<StdString> domainList = grid->getDomainList(); |
---|
| 1585 | std::vector<StdString> axisList = grid->getAxisList(); |
---|
[887] | 1586 | std::vector<StdString> scalarList = grid->getScalarList(); |
---|
| 1587 | int numElement = axisDomainOrder.numElements(), idxDomain = 0, idxAxis = 0, idxScalar = 0; |
---|
[676] | 1588 | |
---|
| 1589 | std::vector<StdString> dims; |
---|
| 1590 | |
---|
| 1591 | if (grid->isCompressible()) |
---|
| 1592 | { |
---|
| 1593 | StdString varId = grid->getId() + "_points"; |
---|
| 1594 | |
---|
| 1595 | int nbIndexes = (SuperClass::type == MULTI_FILE) ? grid->getNumberWrittenIndexes() : grid->getTotalNumberWrittenIndexes(); |
---|
| 1596 | SuperClassWriter::addDimension(varId, nbIndexes); |
---|
| 1597 | |
---|
| 1598 | dims.push_back(varId); |
---|
| 1599 | SuperClassWriter::addVariable(varId, NC_INT, dims); |
---|
| 1600 | |
---|
| 1601 | StdOStringStream compress; |
---|
| 1602 | for (int i = numElement - 1; i >= 0; --i) |
---|
| 1603 | { |
---|
[887] | 1604 | if (2 == axisDomainOrder(i)) |
---|
[676] | 1605 | { |
---|
| 1606 | CDomain* domain = CDomain::get(domainList[domainList.size() - idxDomain - 1]); |
---|
[772] | 1607 | StdString domId = domain->getDomainOutputName(); |
---|
[676] | 1608 | StdString appendDomId = singleDomain ? "" : "_" + domId; |
---|
| 1609 | |
---|
| 1610 | switch (domain->type) |
---|
| 1611 | { |
---|
| 1612 | case CDomain::type_attr::curvilinear: |
---|
| 1613 | compress << "y" << appendDomId << " x" << appendDomId; |
---|
| 1614 | break; |
---|
| 1615 | case CDomain::type_attr::rectilinear: |
---|
| 1616 | compress << "lat" << appendDomId << " lon" << appendDomId; |
---|
| 1617 | break; |
---|
| 1618 | case CDomain::type_attr::unstructured: |
---|
[1430] | 1619 | StdString cellName = (!domain->dim_i_name.isEmpty()) ? cellName=domain->dim_i_name : "cell"; |
---|
| 1620 | compress << cellName << appendDomId; |
---|
| 1621 | // compress << "cell" << appendDomId; |
---|
[676] | 1622 | break; |
---|
| 1623 | } |
---|
| 1624 | ++idxDomain; |
---|
| 1625 | } |
---|
[887] | 1626 | else if (1 == axisDomainOrder(i)) |
---|
[676] | 1627 | { |
---|
| 1628 | CAxis* axis = CAxis::get(axisList[axisList.size() - idxAxis - 1]); |
---|
[772] | 1629 | compress << axis->getAxisOutputName(); |
---|
[676] | 1630 | ++idxAxis; |
---|
| 1631 | } |
---|
[887] | 1632 | else |
---|
| 1633 | { |
---|
| 1634 | CScalar* scalar = CScalar::get(scalarList[scalarList.size() - idxScalar - 1]); |
---|
| 1635 | compress << scalar->getScalarOutputName(); |
---|
| 1636 | ++idxScalar; |
---|
| 1637 | } |
---|
[676] | 1638 | |
---|
| 1639 | if (i != 0) compress << ' '; |
---|
| 1640 | } |
---|
[1144] | 1641 | SuperClassWriter::addAttribute("compress", compress.str(), &varId); |
---|
[676] | 1642 | |
---|
| 1643 | CArray<int, 1> indexes(grid->getNumberWrittenIndexes()); |
---|
[1143] | 1644 | indexes = grid->localIndexToWriteOnServer; |
---|
[676] | 1645 | |
---|
| 1646 | switch (SuperClass::type) |
---|
| 1647 | { |
---|
| 1648 | case (MULTI_FILE): |
---|
| 1649 | { |
---|
| 1650 | SuperClassWriter::writeData(indexes, varId, isCollective, 0); |
---|
| 1651 | break; |
---|
| 1652 | } |
---|
| 1653 | case (ONE_FILE): |
---|
| 1654 | { |
---|
| 1655 | if (grid->doGridHaveDataDistributed()) |
---|
| 1656 | grid->getDistributionServer()->computeGlobalIndex(indexes); |
---|
| 1657 | |
---|
| 1658 | std::vector<StdSize> start, count; |
---|
| 1659 | start.push_back(grid->getOffsetWrittenIndexes()); |
---|
| 1660 | count.push_back(grid->getNumberWrittenIndexes()); |
---|
| 1661 | |
---|
| 1662 | SuperClassWriter::writeData(indexes, varId, isCollective, 0, &start, &count); |
---|
| 1663 | break; |
---|
| 1664 | } |
---|
| 1665 | } |
---|
| 1666 | } |
---|
| 1667 | else |
---|
| 1668 | { |
---|
| 1669 | for (int i = 0; i < numElement; ++i) |
---|
| 1670 | { |
---|
| 1671 | StdString varId, compress; |
---|
| 1672 | CArray<int, 1> indexes; |
---|
| 1673 | bool isDistributed; |
---|
| 1674 | StdSize nbIndexes, totalNbIndexes, offset; |
---|
| 1675 | int firstGlobalIndex; |
---|
| 1676 | |
---|
[887] | 1677 | if (2 == axisDomainOrder(i)) |
---|
[676] | 1678 | { |
---|
| 1679 | CDomain* domain = CDomain::get(domainList[idxDomain]); |
---|
[774] | 1680 | StdString domId = domain->getDomainOutputName(); |
---|
| 1681 | |
---|
[676] | 1682 | if (!domain->isCompressible() |
---|
| 1683 | || domain->type == CDomain::type_attr::unstructured |
---|
[774] | 1684 | || domain->isWrittenCompressed(this->filename) |
---|
| 1685 | || isWrittenCompressedDomain(domId)) |
---|
[676] | 1686 | continue; |
---|
| 1687 | |
---|
| 1688 | StdString appendDomId = singleDomain ? "" : "_" + domId; |
---|
| 1689 | |
---|
| 1690 | varId = domId + "_points"; |
---|
| 1691 | switch (domain->type) |
---|
| 1692 | { |
---|
| 1693 | case CDomain::type_attr::curvilinear: |
---|
| 1694 | compress = "y" + appendDomId + " x" + appendDomId; |
---|
| 1695 | break; |
---|
| 1696 | case CDomain::type_attr::rectilinear: |
---|
| 1697 | compress = "lat" + appendDomId + " lon" + appendDomId; |
---|
| 1698 | break; |
---|
| 1699 | } |
---|
| 1700 | |
---|
[1249] | 1701 | // indexes.resize(domain->compressedIndexToWriteOnServer[comm_file].numElements()); |
---|
| 1702 | // indexes = domain->compressedIndexToWriteOnServer[com_file]; |
---|
| 1703 | indexes.resize(domain->getCompressedIndexToWriteOnServer(comm_file).numElements()); |
---|
| 1704 | indexes = domain->getCompressedIndexToWriteOnServer(comm_file); |
---|
[1143] | 1705 | |
---|
[676] | 1706 | isDistributed = domain->isDistributed(); |
---|
[1249] | 1707 | nbIndexes = domain->getNumberWrittenIndexes(comm_file); |
---|
| 1708 | totalNbIndexes = domain->getTotalNumberWrittenIndexes(comm_file); |
---|
| 1709 | offset = domain->getOffsetWrittenIndexes(comm_file); |
---|
[676] | 1710 | firstGlobalIndex = domain->ibegin + domain->jbegin * domain->ni_glo; |
---|
| 1711 | |
---|
| 1712 | domain->addRelFileCompressed(this->filename); |
---|
[774] | 1713 | setWrittenCompressedDomain(domId); |
---|
[676] | 1714 | ++idxDomain; |
---|
| 1715 | } |
---|
[887] | 1716 | else if (1 == axisDomainOrder(i)) |
---|
[676] | 1717 | { |
---|
| 1718 | CAxis* axis = CAxis::get(axisList[idxAxis]); |
---|
[774] | 1719 | StdString axisId = axis->getAxisOutputName(); |
---|
| 1720 | |
---|
| 1721 | if (!axis->isCompressible() |
---|
| 1722 | || axis->isWrittenCompressed(this->filename) |
---|
| 1723 | || isWrittenCompressedAxis(axisId)) |
---|
[676] | 1724 | continue; |
---|
| 1725 | |
---|
| 1726 | varId = axisId + "_points"; |
---|
| 1727 | compress = axisId; |
---|
| 1728 | |
---|
[1249] | 1729 | // indexes.resize(axis->compressedIndexToWriteOnServer.numElements()); |
---|
| 1730 | // indexes = axis->compressedIndexToWriteOnServer; |
---|
[1143] | 1731 | |
---|
[1249] | 1732 | indexes.resize(axis->getCompressedIndexToWriteOnServer(comm_file).numElements()); |
---|
| 1733 | indexes = axis->getCompressedIndexToWriteOnServer(comm_file); |
---|
| 1734 | |
---|
[676] | 1735 | isDistributed = axis->isDistributed(); |
---|
[1249] | 1736 | nbIndexes = axis->getNumberWrittenIndexes(comm_file); |
---|
| 1737 | totalNbIndexes = axis->getTotalNumberWrittenIndexes(comm_file); |
---|
| 1738 | offset = axis->getOffsetWrittenIndexes(comm_file); |
---|
[676] | 1739 | firstGlobalIndex = axis->begin; |
---|
| 1740 | |
---|
| 1741 | axis->addRelFileCompressed(this->filename); |
---|
[774] | 1742 | setWrittenCompressedAxis(axisId); |
---|
[676] | 1743 | ++idxAxis; |
---|
| 1744 | } |
---|
[887] | 1745 | else |
---|
| 1746 | { |
---|
| 1747 | } |
---|
[676] | 1748 | |
---|
| 1749 | if (!varId.empty()) |
---|
| 1750 | { |
---|
| 1751 | SuperClassWriter::addDimension(varId, (SuperClass::type == MULTI_FILE) ? nbIndexes : totalNbIndexes); |
---|
| 1752 | |
---|
| 1753 | dims.clear(); |
---|
| 1754 | dims.push_back(varId); |
---|
| 1755 | SuperClassWriter::addVariable(varId, NC_INT, dims); |
---|
| 1756 | |
---|
| 1757 | SuperClassWriter::addAttribute("compress", compress, &varId); |
---|
| 1758 | |
---|
| 1759 | switch (SuperClass::type) |
---|
| 1760 | { |
---|
| 1761 | case (MULTI_FILE): |
---|
| 1762 | { |
---|
| 1763 | indexes -= firstGlobalIndex; |
---|
| 1764 | SuperClassWriter::writeData(indexes, varId, isCollective, 0); |
---|
| 1765 | break; |
---|
| 1766 | } |
---|
| 1767 | case (ONE_FILE): |
---|
| 1768 | { |
---|
| 1769 | std::vector<StdSize> start, count; |
---|
| 1770 | start.push_back(offset); |
---|
| 1771 | count.push_back(nbIndexes); |
---|
| 1772 | |
---|
| 1773 | SuperClassWriter::writeData(indexes, varId, isCollective, 0, &start, &count); |
---|
| 1774 | break; |
---|
| 1775 | } |
---|
| 1776 | } |
---|
| 1777 | } |
---|
[1144] | 1778 | } |
---|
[676] | 1779 | } |
---|
| 1780 | |
---|
| 1781 | grid->addRelFileCompressed(this->filename); |
---|
| 1782 | } |
---|
| 1783 | catch (CNetCdfException& e) |
---|
| 1784 | { |
---|
| 1785 | StdString msg("On writing compressed grid : "); |
---|
| 1786 | msg.append(grid->getId()); msg.append("\n"); |
---|
| 1787 | msg.append("In the context : "); |
---|
| 1788 | CContext* context = CContext::getCurrent(); |
---|
| 1789 | msg.append(context->getId()); msg.append("\n"); |
---|
| 1790 | msg.append(e.what()); |
---|
| 1791 | ERROR("CNc4DataOutput::writeGridCompressed_(CGrid* grid)", << msg); |
---|
| 1792 | } |
---|
| 1793 | } |
---|
| 1794 | |
---|
| 1795 | //-------------------------------------------------------------- |
---|
| 1796 | |
---|
[391] | 1797 | void CNc4DataOutput::writeTimeDimension_(void) |
---|
| 1798 | { |
---|
[498] | 1799 | try |
---|
| 1800 | { |
---|
[802] | 1801 | SuperClassWriter::addDimension(getTimeCounterName()); |
---|
[498] | 1802 | } |
---|
| 1803 | catch (CNetCdfException& e) |
---|
| 1804 | { |
---|
[614] | 1805 | StdString msg("On writing time dimension : time_couter\n"); |
---|
[498] | 1806 | msg.append("In the context : "); |
---|
| 1807 | CContext* context = CContext::getCurrent() ; |
---|
| 1808 | msg.append(context->getId()); msg.append("\n"); |
---|
| 1809 | msg.append(e.what()); |
---|
| 1810 | ERROR("CNc4DataOutput::writeTimeDimension_(void)", << msg); |
---|
| 1811 | } |
---|
[391] | 1812 | } |
---|
[676] | 1813 | |
---|
[219] | 1814 | //-------------------------------------------------------------- |
---|
| 1815 | |
---|
[347] | 1816 | void CNc4DataOutput::writeField_(CField* field) |
---|
[219] | 1817 | { |
---|
[1158] | 1818 | CContext* context = CContext::getCurrent() ; |
---|
| 1819 | CContextServer* server=context->server ; |
---|
[300] | 1820 | |
---|
[1158] | 1821 | std::vector<StdString> dims, coodinates; |
---|
| 1822 | CGrid* grid = field->grid; |
---|
| 1823 | if (!grid->doGridHaveDataToWrite()) |
---|
[567] | 1824 | if (SuperClass::type==MULTI_FILE) return ; |
---|
[488] | 1825 | |
---|
[1158] | 1826 | CArray<int,1> axisDomainOrder = grid->axis_domain_order; |
---|
| 1827 | int numElement = axisDomainOrder.numElements(), idxDomain = 0, idxAxis = 0, idxScalar = 0; |
---|
| 1828 | std::vector<StdString> domainList = grid->getDomainList(); |
---|
| 1829 | std::vector<StdString> axisList = grid->getAxisList(); |
---|
| 1830 | std::vector<StdString> scalarList = grid->getScalarList(); |
---|
[219] | 1831 | |
---|
[1158] | 1832 | StdString timeid = getTimeCounterName(); |
---|
| 1833 | StdString dimXid,dimYid; |
---|
| 1834 | std::deque<StdString> dimIdList, dimCoordList; |
---|
| 1835 | bool hasArea = false; |
---|
| 1836 | StdString cellMeasures = "area:"; |
---|
| 1837 | bool compressedOutput = !field->indexed_output.isEmpty() && field->indexed_output; |
---|
[488] | 1838 | |
---|
[1158] | 1839 | for (int i = 0; i < numElement; ++i) |
---|
| 1840 | { |
---|
| 1841 | if (2 == axisDomainOrder(i)) |
---|
| 1842 | { |
---|
| 1843 | CDomain* domain = CDomain::get(domainList[idxDomain]); |
---|
| 1844 | StdString domId = domain->getDomainOutputName(); |
---|
| 1845 | StdString appendDomId = singleDomain ? "" : "_" + domId ; |
---|
[1391] | 1846 | StdString lonName,latName ; |
---|
[1430] | 1847 | StdString dimIname,dimJname ; |
---|
[676] | 1848 | |
---|
[1415] | 1849 | if (domain->lon_name.isEmpty()) |
---|
| 1850 | { |
---|
| 1851 | if (domain->type==CDomain::type_attr::curvilinear) lonName = "nav_lon"; |
---|
| 1852 | else lonName = "lon"; |
---|
| 1853 | } |
---|
[1391] | 1854 | else lonName = domain->lon_name; |
---|
| 1855 | |
---|
[1415] | 1856 | if (domain->lat_name.isEmpty()) |
---|
| 1857 | { |
---|
| 1858 | if (domain->type==CDomain::type_attr::curvilinear) latName = "nav_lat"; |
---|
| 1859 | else latName = "lat"; |
---|
| 1860 | } |
---|
[1391] | 1861 | else latName = domain->lat_name; |
---|
[1430] | 1862 | |
---|
| 1863 | if (domain->dim_i_name.isEmpty()) |
---|
| 1864 | { |
---|
| 1865 | if (domain->type==CDomain::type_attr::curvilinear) dimIname = "x"; |
---|
| 1866 | else if (domain->type==CDomain::type_attr::unstructured) dimIname = "cell"; |
---|
| 1867 | else dimIname = lonName; |
---|
| 1868 | } |
---|
| 1869 | else dimIname = domain->dim_i_name; |
---|
| 1870 | |
---|
| 1871 | if (domain->dim_j_name.isEmpty()) |
---|
| 1872 | { |
---|
| 1873 | if (domain->type==CDomain::type_attr::curvilinear) dimJname = "y"; |
---|
| 1874 | else dimJname = latName; |
---|
| 1875 | } |
---|
| 1876 | else dimJname = domain->dim_j_name; |
---|
[1391] | 1877 | |
---|
[1158] | 1878 | if (compressedOutput && domain->isCompressible() && domain->type != CDomain::type_attr::unstructured) |
---|
| 1879 | { |
---|
| 1880 | dimIdList.push_back(domId + "_points"); |
---|
| 1881 | field->setUseCompressedOutput(); |
---|
| 1882 | } |
---|
[676] | 1883 | |
---|
[1158] | 1884 | switch (domain->type) |
---|
[879] | 1885 | { |
---|
[1158] | 1886 | case CDomain::type_attr::curvilinear: |
---|
| 1887 | if (!compressedOutput || !domain->isCompressible()) |
---|
| 1888 | { |
---|
[1430] | 1889 | dimXid=dimIname+appendDomId; |
---|
| 1890 | dimYid=dimJname+appendDomId; |
---|
[1158] | 1891 | dimIdList.push_back(dimXid); |
---|
| 1892 | dimIdList.push_back(dimYid); |
---|
| 1893 | } |
---|
[1415] | 1894 | dimCoordList.push_back(lonName+appendDomId); |
---|
| 1895 | dimCoordList.push_back(latName+appendDomId); |
---|
[1158] | 1896 | break ; |
---|
| 1897 | case CDomain::type_attr::rectilinear: |
---|
| 1898 | if (!compressedOutput || !domain->isCompressible()) |
---|
| 1899 | { |
---|
[1430] | 1900 | dimXid = dimIname+appendDomId; |
---|
| 1901 | dimYid = dimJname+appendDomId; |
---|
[1158] | 1902 | dimIdList.push_back(dimXid); |
---|
| 1903 | dimIdList.push_back(dimYid); |
---|
| 1904 | } |
---|
[1430] | 1905 | if (lonName != dimIname) dimCoordList.push_back(lonName+appendDomId); |
---|
| 1906 | if (latName != dimJname) dimCoordList.push_back(latName+appendDomId); |
---|
| 1907 | |
---|
[1158] | 1908 | break ; |
---|
| 1909 | case CDomain::type_attr::unstructured: |
---|
| 1910 | { |
---|
| 1911 | if (SuperClassWriter::useCFConvention) |
---|
| 1912 | { |
---|
[1430] | 1913 | dimXid = dimIname + appendDomId; |
---|
[1158] | 1914 | dimIdList.push_back(dimXid); |
---|
[1415] | 1915 | dimCoordList.push_back(lonName+appendDomId); |
---|
| 1916 | dimCoordList.push_back(latName+appendDomId); |
---|
[1158] | 1917 | } |
---|
| 1918 | else |
---|
| 1919 | { |
---|
| 1920 | StdString domainName = domain->name; |
---|
| 1921 | if (domain->nvertex == 1) |
---|
| 1922 | { |
---|
| 1923 | dimXid = "n" + domainName + "_node"; |
---|
| 1924 | dimIdList.push_back(dimXid); |
---|
| 1925 | dimCoordList.push_back(StdString(domainName + "_node_x")); |
---|
| 1926 | dimCoordList.push_back(StdString(domainName + "_node_y")); |
---|
| 1927 | } |
---|
| 1928 | else if (domain->nvertex == 2) |
---|
| 1929 | { |
---|
| 1930 | dimXid = "n" + domainName + "_edge"; |
---|
| 1931 | dimIdList.push_back(dimXid); |
---|
| 1932 | dimCoordList.push_back(StdString(domainName + "_edge_x")); |
---|
| 1933 | dimCoordList.push_back(StdString(domainName + "_edge_y")); |
---|
| 1934 | } |
---|
| 1935 | else |
---|
| 1936 | { |
---|
| 1937 | dimXid = "n" + domainName + "_face"; |
---|
| 1938 | dimIdList.push_back(dimXid); |
---|
| 1939 | dimCoordList.push_back(StdString(domainName + "_face_x")); |
---|
| 1940 | dimCoordList.push_back(StdString(domainName + "_face_y")); |
---|
| 1941 | } |
---|
| 1942 | } // ugrid convention |
---|
| 1943 | } // case unstructured domain |
---|
[879] | 1944 | } |
---|
[1158] | 1945 | |
---|
| 1946 | if (domain->hasArea) |
---|
[879] | 1947 | { |
---|
[1158] | 1948 | hasArea = true; |
---|
| 1949 | cellMeasures += " area" + appendDomId; |
---|
[879] | 1950 | } |
---|
[1158] | 1951 | ++idxDomain; |
---|
| 1952 | } |
---|
| 1953 | else if (1 == axisDomainOrder(i)) |
---|
| 1954 | { |
---|
| 1955 | CAxis* axis = CAxis::get(axisList[idxAxis]); |
---|
| 1956 | StdString axisId = axis->getAxisOutputName(); |
---|
[1430] | 1957 | StdString axisDim; |
---|
[1158] | 1958 | |
---|
[1430] | 1959 | if (axis->dim_name.isEmpty()) axisDim = axisId; |
---|
| 1960 | else axisDim=axis->dim_name.getValue(); |
---|
| 1961 | |
---|
[1158] | 1962 | if (compressedOutput && axis->isCompressible()) |
---|
[879] | 1963 | { |
---|
[1430] | 1964 | dimIdList.push_back(axisDim + "_points"); |
---|
[1158] | 1965 | field->setUseCompressedOutput(); |
---|
[879] | 1966 | } |
---|
[1158] | 1967 | else |
---|
[1430] | 1968 | dimIdList.push_back(axisDim); |
---|
[878] | 1969 | |
---|
[1430] | 1970 | if (axisDim != axisId) dimCoordList.push_back(axisId); |
---|
[1158] | 1971 | ++idxAxis; |
---|
| 1972 | } |
---|
[1430] | 1973 | else |
---|
[1158] | 1974 | { |
---|
[1430] | 1975 | CScalar* scalar = CScalar::get(scalarList[idxScalar]); |
---|
| 1976 | StdString scalarId = scalar->getScalarOutputName(); |
---|
[1446] | 1977 | if (!scalar->value.isEmpty() || !scalar->label.isEmpty()) |
---|
| 1978 | dimCoordList.push_back(scalarId); |
---|
[1430] | 1979 | ++idxScalar; |
---|
[1158] | 1980 | } |
---|
| 1981 | } |
---|
[488] | 1982 | |
---|
[1158] | 1983 | StdString fieldid = field->getFieldOutputName(); |
---|
[219] | 1984 | |
---|
[1158] | 1985 | nc_type type ; |
---|
| 1986 | if (field->prec.isEmpty()) type = NC_FLOAT ; |
---|
| 1987 | else |
---|
| 1988 | { |
---|
| 1989 | if (field->prec==2) type = NC_SHORT ; |
---|
| 1990 | else if (field->prec==4) type = NC_FLOAT ; |
---|
| 1991 | else if (field->prec==8) type = NC_DOUBLE ; |
---|
| 1992 | } |
---|
[488] | 1993 | |
---|
[1158] | 1994 | bool wtime = !(!field->operation.isEmpty() && field->getOperationTimeType() == func::CFunctor::once); |
---|
[488] | 1995 | |
---|
[1158] | 1996 | if (wtime) |
---|
| 1997 | { |
---|
| 1998 | if (field->hasTimeInstant && hasTimeInstant) coodinates.push_back(string("time_instant")); |
---|
| 1999 | else if (field->hasTimeCentered && hasTimeCentered) coodinates.push_back(string("time_centered")); |
---|
| 2000 | dims.push_back(timeid); |
---|
| 2001 | } |
---|
[488] | 2002 | |
---|
[1158] | 2003 | if (compressedOutput && grid->isCompressible()) |
---|
| 2004 | { |
---|
| 2005 | dims.push_back(grid->getId() + "_points"); |
---|
| 2006 | field->setUseCompressedOutput(); |
---|
| 2007 | } |
---|
| 2008 | else |
---|
| 2009 | { |
---|
| 2010 | while (!dimIdList.empty()) |
---|
| 2011 | { |
---|
| 2012 | dims.push_back(dimIdList.back()); |
---|
| 2013 | dimIdList.pop_back(); |
---|
| 2014 | } |
---|
| 2015 | } |
---|
[219] | 2016 | |
---|
[1158] | 2017 | while (!dimCoordList.empty()) |
---|
| 2018 | { |
---|
| 2019 | coodinates.push_back(dimCoordList.back()); |
---|
| 2020 | dimCoordList.pop_back(); |
---|
| 2021 | } |
---|
[219] | 2022 | |
---|
[1158] | 2023 | try |
---|
| 2024 | { |
---|
[498] | 2025 | SuperClassWriter::addVariable(fieldid, type, dims); |
---|
[488] | 2026 | |
---|
[498] | 2027 | if (!field->standard_name.isEmpty()) |
---|
| 2028 | SuperClassWriter::addAttribute |
---|
| 2029 | ("standard_name", field->standard_name.getValue(), &fieldid); |
---|
[219] | 2030 | |
---|
[498] | 2031 | if (!field->long_name.isEmpty()) |
---|
| 2032 | SuperClassWriter::addAttribute |
---|
| 2033 | ("long_name", field->long_name.getValue(), &fieldid); |
---|
[219] | 2034 | |
---|
[498] | 2035 | if (!field->unit.isEmpty()) |
---|
| 2036 | SuperClassWriter::addAttribute |
---|
| 2037 | ("units", field->unit.getValue(), &fieldid); |
---|
[463] | 2038 | |
---|
[1158] | 2039 | // Ugrid field attributes "mesh" and "location" |
---|
| 2040 | if (!SuperClassWriter::useCFConvention) |
---|
| 2041 | { |
---|
| 2042 | if (!domainList.empty()) |
---|
| 2043 | { |
---|
| 2044 | CDomain* domain = CDomain::get(domainList[0]); // Suppose that we have only domain |
---|
| 2045 | StdString mesh = domain->name; |
---|
| 2046 | SuperClassWriter::addAttribute("mesh", mesh, &fieldid); |
---|
| 2047 | StdString location; |
---|
| 2048 | if (domain->nvertex == 1) |
---|
| 2049 | location = "node"; |
---|
| 2050 | else if (domain->nvertex == 2) |
---|
| 2051 | location = "edge"; |
---|
| 2052 | else if (domain->nvertex > 2) |
---|
| 2053 | location = "face"; |
---|
| 2054 | SuperClassWriter::addAttribute("location", location, &fieldid); |
---|
| 2055 | } |
---|
| 2056 | |
---|
| 2057 | } |
---|
| 2058 | |
---|
| 2059 | if (!field->valid_min.isEmpty()) |
---|
[498] | 2060 | SuperClassWriter::addAttribute |
---|
| 2061 | ("valid_min", field->valid_min.getValue(), &fieldid); |
---|
[463] | 2062 | |
---|
[498] | 2063 | if (!field->valid_max.isEmpty()) |
---|
| 2064 | SuperClassWriter::addAttribute |
---|
| 2065 | ("valid_max", field->valid_max.getValue(), &fieldid); |
---|
[464] | 2066 | |
---|
[498] | 2067 | if (!field->scale_factor.isEmpty()) |
---|
| 2068 | SuperClassWriter::addAttribute |
---|
| 2069 | ("scale_factor", field->scale_factor.getValue(), &fieldid); |
---|
[464] | 2070 | |
---|
[498] | 2071 | if (!field->add_offset.isEmpty()) |
---|
| 2072 | SuperClassWriter::addAttribute |
---|
| 2073 | ("add_offset", field->add_offset.getValue(), &fieldid); |
---|
[488] | 2074 | |
---|
[498] | 2075 | SuperClassWriter::addAttribute |
---|
| 2076 | ("online_operation", field->operation.getValue(), &fieldid); |
---|
[472] | 2077 | |
---|
[498] | 2078 | // write child variables as attributes |
---|
[488] | 2079 | |
---|
| 2080 | |
---|
[1021] | 2081 | bool alreadyAddCellMethod = false; |
---|
| 2082 | StdString cellMethodsPrefix(""), cellMethodsSuffix(""); |
---|
| 2083 | if (!field->cell_methods.isEmpty()) |
---|
| 2084 | { |
---|
[1158] | 2085 | StdString cellMethodString = field->cell_methods; |
---|
| 2086 | if (field->cell_methods_mode.isEmpty() || |
---|
[1021] | 2087 | (CField::cell_methods_mode_attr::overwrite == field->cell_methods_mode)) |
---|
[1158] | 2088 | { |
---|
| 2089 | SuperClassWriter::addAttribute("cell_methods", cellMethodString, &fieldid); |
---|
| 2090 | alreadyAddCellMethod = true; |
---|
| 2091 | } |
---|
| 2092 | else |
---|
| 2093 | { |
---|
| 2094 | switch (field->cell_methods_mode) |
---|
| 2095 | { |
---|
| 2096 | case (CField::cell_methods_mode_attr::prefix): |
---|
| 2097 | cellMethodsPrefix = cellMethodString; |
---|
| 2098 | cellMethodsPrefix += " "; |
---|
| 2099 | break; |
---|
| 2100 | case (CField::cell_methods_mode_attr::suffix): |
---|
| 2101 | cellMethodsSuffix = " "; |
---|
| 2102 | cellMethodsSuffix += cellMethodString; |
---|
| 2103 | break; |
---|
| 2104 | case (CField::cell_methods_mode_attr::none): |
---|
| 2105 | break; |
---|
| 2106 | default: |
---|
| 2107 | break; |
---|
| 2108 | } |
---|
| 2109 | } |
---|
[1021] | 2110 | } |
---|
[488] | 2111 | |
---|
[1021] | 2112 | |
---|
[498] | 2113 | if (wtime) |
---|
| 2114 | { |
---|
[614] | 2115 | CDuration freqOp = field->freq_op.getValue(); |
---|
| 2116 | freqOp.solveTimeStep(*context->calendar); |
---|
| 2117 | StdString freqOpStr = freqOp.toStringUDUnits(); |
---|
[612] | 2118 | SuperClassWriter::addAttribute("interval_operation", freqOpStr, &fieldid); |
---|
[437] | 2119 | |
---|
[614] | 2120 | CDuration freqOut = field->getRelFile()->output_freq.getValue(); |
---|
| 2121 | freqOut.solveTimeStep(*context->calendar); |
---|
| 2122 | SuperClassWriter::addAttribute("interval_write", freqOut.toStringUDUnits(), &fieldid); |
---|
[612] | 2123 | |
---|
[1021] | 2124 | StdString cellMethods(cellMethodsPrefix + "time: "); |
---|
[612] | 2125 | if (field->operation.getValue() == "instant") cellMethods += "point"; |
---|
| 2126 | else if (field->operation.getValue() == "average") cellMethods += "mean"; |
---|
| 2127 | else if (field->operation.getValue() == "accumulate") cellMethods += "sum"; |
---|
| 2128 | else cellMethods += field->operation; |
---|
[614] | 2129 | if (freqOp.resolve(*context->calendar) != freqOut.resolve(*context->calendar)) |
---|
| 2130 | cellMethods += " (interval: " + freqOpStr + ")"; |
---|
[1021] | 2131 | cellMethods += cellMethodsSuffix; |
---|
| 2132 | if (!alreadyAddCellMethod) |
---|
| 2133 | SuperClassWriter::addAttribute("cell_methods", cellMethods, &fieldid); |
---|
[498] | 2134 | } |
---|
[488] | 2135 | |
---|
[611] | 2136 | if (hasArea) |
---|
| 2137 | SuperClassWriter::addAttribute("cell_measures", cellMeasures, &fieldid); |
---|
| 2138 | |
---|
[498] | 2139 | if (!field->default_value.isEmpty()) |
---|
| 2140 | { |
---|
[1424] | 2141 | double default_value = field->default_value.getValue(); |
---|
| 2142 | if (type == NC_DOUBLE) |
---|
| 2143 | { |
---|
| 2144 | SuperClassWriter::setDefaultValue(fieldid, &default_value); |
---|
| 2145 | } |
---|
| 2146 | else if (type == NC_SHORT) |
---|
| 2147 | { |
---|
| 2148 | short sdefault_value = (short)default_value; |
---|
| 2149 | SuperClassWriter::setDefaultValue(fieldid, &sdefault_value); |
---|
| 2150 | } |
---|
| 2151 | else |
---|
| 2152 | { |
---|
| 2153 | float fdefault_value = (float)default_value; |
---|
| 2154 | SuperClassWriter::setDefaultValue(fieldid, &fdefault_value); |
---|
| 2155 | } |
---|
[498] | 2156 | } |
---|
| 2157 | else |
---|
[517] | 2158 | SuperClassWriter::setDefaultValue(fieldid, (double*)NULL); |
---|
[219] | 2159 | |
---|
[606] | 2160 | if (field->compression_level.isEmpty()) |
---|
| 2161 | field->compression_level = field->file->compression_level.isEmpty() ? 0 : field->file->compression_level; |
---|
| 2162 | SuperClassWriter::setCompressionLevel(fieldid, field->compression_level); |
---|
| 2163 | |
---|
[878] | 2164 | { // Ecriture des coordonnes |
---|
[488] | 2165 | |
---|
[498] | 2166 | StdString coordstr; //boost::algorithm::join(coodinates, " ") |
---|
| 2167 | std::vector<StdString>::iterator |
---|
| 2168 | itc = coodinates.begin(), endc = coodinates.end(); |
---|
[488] | 2169 | |
---|
[498] | 2170 | for (; itc!= endc; itc++) |
---|
| 2171 | { |
---|
| 2172 | StdString & coord = *itc; |
---|
| 2173 | if (itc+1 != endc) |
---|
| 2174 | coordstr.append(coord).append(" "); |
---|
| 2175 | else coordstr.append(coord); |
---|
| 2176 | } |
---|
[219] | 2177 | |
---|
[498] | 2178 | SuperClassWriter::addAttribute("coordinates", coordstr, &fieldid); |
---|
[219] | 2179 | |
---|
[498] | 2180 | } |
---|
[1222] | 2181 | |
---|
| 2182 | vector<CVariable*> listVars = field->getAllVariables() ; |
---|
| 2183 | for (vector<CVariable*>::iterator it = listVars.begin() ;it != listVars.end(); it++) writeAttribute_(*it, fieldid) ; |
---|
| 2184 | |
---|
[219] | 2185 | } |
---|
[498] | 2186 | catch (CNetCdfException& e) |
---|
| 2187 | { |
---|
| 2188 | StdString msg("On writing field : "); |
---|
| 2189 | msg.append(fieldid); msg.append("\n"); |
---|
| 2190 | msg.append("In the context : "); |
---|
| 2191 | msg.append(context->getId()); msg.append("\n"); |
---|
| 2192 | msg.append(e.what()); |
---|
| 2193 | ERROR("CNc4DataOutput::writeField_(CField* field)", << msg); |
---|
| 2194 | } |
---|
[879] | 2195 | } // writeField_() |
---|
[219] | 2196 | |
---|
| 2197 | //-------------------------------------------------------------- |
---|
| 2198 | |
---|
[347] | 2199 | void CNc4DataOutput::writeFile_ (CFile* file) |
---|
[219] | 2200 | { |
---|
[773] | 2201 | StdString filename = file->getFileOutputName(); |
---|
[219] | 2202 | StdString description = (!file->description.isEmpty()) |
---|
| 2203 | ? file->description.getValue() |
---|
[335] | 2204 | : StdString("Created by xios"); |
---|
[609] | 2205 | |
---|
| 2206 | singleDomain = (file->nbDomains == 1); |
---|
| 2207 | |
---|
[1158] | 2208 | StdString conv_str ; |
---|
| 2209 | if (file->convention_str.isEmpty()) |
---|
| 2210 | { |
---|
| 2211 | if (SuperClassWriter::useCFConvention) conv_str="CF-1.6" ; |
---|
| 2212 | else conv_str="UGRID" ; |
---|
| 2213 | } |
---|
| 2214 | else conv_str=file->convention_str ; |
---|
| 2215 | |
---|
[498] | 2216 | try |
---|
| 2217 | { |
---|
[1309] | 2218 | if (!appendMode) this->writeFileAttributes(filename, description, |
---|
| 2219 | conv_str, |
---|
| 2220 | StdString("An IPSL model"), |
---|
| 2221 | this->getTimeStamp()); |
---|
[609] | 2222 | |
---|
[701] | 2223 | if (!appendMode) |
---|
| 2224 | SuperClassWriter::addDimension("axis_nbounds", 2); |
---|
[498] | 2225 | } |
---|
| 2226 | catch (CNetCdfException& e) |
---|
| 2227 | { |
---|
| 2228 | StdString msg("On writing file : "); |
---|
| 2229 | msg.append(filename); msg.append("\n"); |
---|
| 2230 | msg.append("In the context : "); |
---|
| 2231 | CContext* context = CContext::getCurrent() ; |
---|
| 2232 | msg.append(context->getId()); msg.append("\n"); |
---|
| 2233 | msg.append(e.what()); |
---|
| 2234 | ERROR("CNc4DataOutput::writeFile_ (CFile* file)", << msg); |
---|
| 2235 | } |
---|
[219] | 2236 | } |
---|
[488] | 2237 | |
---|
[472] | 2238 | void CNc4DataOutput::writeAttribute_ (CVariable* var, const string& fieldId) |
---|
| 2239 | { |
---|
[773] | 2240 | StdString name = var->getVariableOutputName(); |
---|
[488] | 2241 | |
---|
[498] | 2242 | try |
---|
| 2243 | { |
---|
[527] | 2244 | if (var->type.getValue() == CVariable::type_attr::t_int || var->type.getValue() == CVariable::type_attr::t_int32) |
---|
| 2245 | addAttribute(name, var->getData<int>(), &fieldId); |
---|
| 2246 | else if (var->type.getValue() == CVariable::type_attr::t_int16) |
---|
| 2247 | addAttribute(name, var->getData<short int>(), &fieldId); |
---|
| 2248 | else if (var->type.getValue() == CVariable::type_attr::t_float) |
---|
| 2249 | addAttribute(name, var->getData<float>(), &fieldId); |
---|
| 2250 | else if (var->type.getValue() == CVariable::type_attr::t_double) |
---|
| 2251 | addAttribute(name, var->getData<double>(), &fieldId); |
---|
| 2252 | else if (var->type.getValue() == CVariable::type_attr::t_string) |
---|
| 2253 | addAttribute(name, var->getData<string>(), &fieldId); |
---|
| 2254 | else |
---|
| 2255 | ERROR("CNc4DataOutput::writeAttribute_ (CVariable* var, const string& fieldId)", |
---|
| 2256 | << "Unsupported variable of type " << var->type.getStringValue()); |
---|
[498] | 2257 | } |
---|
| 2258 | catch (CNetCdfException& e) |
---|
| 2259 | { |
---|
| 2260 | StdString msg("On writing attributes of variable with name : "); |
---|
| 2261 | msg.append(name); msg.append("in the field "); msg.append(fieldId); msg.append("\n"); |
---|
| 2262 | msg.append("In the context : "); |
---|
| 2263 | CContext* context = CContext::getCurrent() ; |
---|
| 2264 | msg.append(context->getId()); msg.append("\n"); |
---|
| 2265 | msg.append(e.what()); |
---|
| 2266 | ERROR("CNc4DataOutput::writeAttribute_ (CVariable* var, const string& fieldId)", << msg); |
---|
| 2267 | } |
---|
[472] | 2268 | } |
---|
[488] | 2269 | |
---|
[472] | 2270 | void CNc4DataOutput::writeAttribute_ (CVariable* var) |
---|
| 2271 | { |
---|
[773] | 2272 | StdString name = var->getVariableOutputName(); |
---|
| 2273 | |
---|
[498] | 2274 | try |
---|
| 2275 | { |
---|
[527] | 2276 | if (var->type.getValue() == CVariable::type_attr::t_int || var->type.getValue() == CVariable::type_attr::t_int32) |
---|
| 2277 | addAttribute(name, var->getData<int>()); |
---|
| 2278 | else if (var->type.getValue() == CVariable::type_attr::t_int16) |
---|
| 2279 | addAttribute(name, var->getData<short int>()); |
---|
| 2280 | else if (var->type.getValue() == CVariable::type_attr::t_float) |
---|
| 2281 | addAttribute(name, var->getData<float>()); |
---|
| 2282 | else if (var->type.getValue() == CVariable::type_attr::t_double) |
---|
| 2283 | addAttribute(name, var->getData<double>()); |
---|
| 2284 | else if (var->type.getValue() == CVariable::type_attr::t_string) |
---|
| 2285 | addAttribute(name, var->getData<string>()); |
---|
| 2286 | else |
---|
| 2287 | ERROR("CNc4DataOutput::writeAttribute_ (CVariable* var)", |
---|
| 2288 | << "Unsupported variable of type " << var->type.getStringValue()); |
---|
[498] | 2289 | } |
---|
| 2290 | catch (CNetCdfException& e) |
---|
| 2291 | { |
---|
| 2292 | StdString msg("On writing attributes of variable with name : "); |
---|
| 2293 | msg.append(name); msg.append("\n"); |
---|
| 2294 | msg.append("In the context : "); |
---|
| 2295 | CContext* context = CContext::getCurrent() ; |
---|
| 2296 | msg.append(context->getId()); msg.append("\n"); |
---|
| 2297 | msg.append(e.what()); |
---|
| 2298 | ERROR("CNc4DataOutput::writeAttribute_ (CVariable* var)", << msg); |
---|
| 2299 | } |
---|
[488] | 2300 | } |
---|
| 2301 | |
---|
[321] | 2302 | void CNc4DataOutput::syncFile_ (void) |
---|
| 2303 | { |
---|
[498] | 2304 | try |
---|
| 2305 | { |
---|
| 2306 | SuperClassWriter::sync() ; |
---|
| 2307 | } |
---|
| 2308 | catch (CNetCdfException& e) |
---|
| 2309 | { |
---|
| 2310 | StdString msg("On synchronizing the write among processes"); |
---|
| 2311 | msg.append("In the context : "); |
---|
| 2312 | CContext* context = CContext::getCurrent() ; |
---|
| 2313 | msg.append(context->getId()); msg.append("\n"); |
---|
| 2314 | msg.append(e.what()); |
---|
| 2315 | ERROR("CNc4DataOutput::syncFile_ (void)", << msg); |
---|
| 2316 | } |
---|
[321] | 2317 | } |
---|
[219] | 2318 | |
---|
[286] | 2319 | void CNc4DataOutput::closeFile_ (void) |
---|
| 2320 | { |
---|
[498] | 2321 | try |
---|
| 2322 | { |
---|
| 2323 | SuperClassWriter::close() ; |
---|
| 2324 | } |
---|
| 2325 | catch (CNetCdfException& e) |
---|
| 2326 | { |
---|
| 2327 | StdString msg("On closing file"); |
---|
| 2328 | msg.append("In the context : "); |
---|
| 2329 | CContext* context = CContext::getCurrent() ; |
---|
| 2330 | msg.append(context->getId()); msg.append("\n"); |
---|
| 2331 | msg.append(e.what()); |
---|
| 2332 | ERROR("CNc4DataOutput::syncFile_ (void)", << msg); |
---|
| 2333 | } |
---|
| 2334 | |
---|
[286] | 2335 | } |
---|
| 2336 | |
---|
[219] | 2337 | //--------------------------------------------------------------- |
---|
| 2338 | |
---|
| 2339 | StdString CNc4DataOutput::getTimeStamp(void) const |
---|
| 2340 | { |
---|
| 2341 | const int buffer_size = 100; |
---|
| 2342 | time_t rawtime; |
---|
| 2343 | struct tm * timeinfo = NULL; |
---|
| 2344 | char buffer [buffer_size]; |
---|
[1158] | 2345 | StdString formatStr; |
---|
| 2346 | if (file->time_stamp_format.isEmpty()) formatStr="%Y-%b-%d %H:%M:%S %Z" ; |
---|
| 2347 | else formatStr=file->time_stamp_format; |
---|
[219] | 2348 | |
---|
[1158] | 2349 | // time ( &rawtime ); |
---|
| 2350 | // timeinfo = localtime ( &rawtime ); |
---|
[219] | 2351 | time ( &rawtime ); |
---|
[1158] | 2352 | timeinfo = gmtime ( &rawtime ); |
---|
| 2353 | strftime (buffer, buffer_size, formatStr.c_str(), timeinfo); |
---|
[219] | 2354 | |
---|
| 2355 | return (StdString(buffer)); |
---|
| 2356 | } |
---|
[488] | 2357 | |
---|
[219] | 2358 | //--------------------------------------------------------------- |
---|
[488] | 2359 | |
---|
[347] | 2360 | void CNc4DataOutput::writeFieldData_ (CField* field) |
---|
[219] | 2361 | { |
---|
[707] | 2362 | CContext* context = CContext::getCurrent(); |
---|
| 2363 | CContextServer* server = context->server; |
---|
| 2364 | CGrid* grid = field->grid; |
---|
[300] | 2365 | |
---|
[1158] | 2366 | if (field->getNStep()<1) |
---|
| 2367 | { |
---|
| 2368 | return; |
---|
| 2369 | } |
---|
[952] | 2370 | |
---|
[707] | 2371 | if (!grid->doGridHaveDataToWrite()) |
---|
[1158] | 2372 | if (SuperClass::type == MULTI_FILE || !isCollective) |
---|
| 2373 | { |
---|
| 2374 | return; |
---|
| 2375 | } |
---|
[488] | 2376 | |
---|
[770] | 2377 | StdString fieldid = field->getFieldOutputName(); |
---|
[286] | 2378 | |
---|
[707] | 2379 | StdOStringStream oss; |
---|
| 2380 | string timeAxisId; |
---|
[1158] | 2381 | if (field->hasTimeInstant) timeAxisId = "time_instant"; |
---|
| 2382 | else if (field->hasTimeCentered) timeAxisId = "time_centered"; |
---|
[488] | 2383 | |
---|
[802] | 2384 | StdString timeBoundId = getTimeCounterName() + "_bounds"; |
---|
[449] | 2385 | |
---|
[707] | 2386 | StdString timeAxisBoundId; |
---|
[1158] | 2387 | if (field->hasTimeInstant) timeAxisBoundId = "time_instant_bounds"; |
---|
| 2388 | else if (field->hasTimeCentered) timeAxisBoundId = "time_centered_bounds"; |
---|
[488] | 2389 | |
---|
[707] | 2390 | if (!field->wasWritten()) |
---|
| 2391 | { |
---|
[1158] | 2392 | if (appendMode && field->file->record_offset.isEmpty() && |
---|
| 2393 | field->getOperationTimeType() != func::CFunctor::once) |
---|
[707] | 2394 | { |
---|
[1158] | 2395 | double factorUnit; |
---|
| 2396 | if (!field->file->time_units.isEmpty() && field->file->time_units==CFile::time_units_attr::days) |
---|
| 2397 | factorUnit=context->getCalendar()->getDayLengthInSeconds() ; |
---|
| 2398 | else factorUnit=1 ; |
---|
| 2399 | field->resetNStep(getRecordFromTime(field->last_Write_srv,factorUnit) + 1); |
---|
[707] | 2400 | } |
---|
[488] | 2401 | |
---|
[707] | 2402 | field->setWritten(); |
---|
| 2403 | } |
---|
[488] | 2404 | |
---|
| 2405 | |
---|
[707] | 2406 | CArray<double,1> time_data(1); |
---|
| 2407 | CArray<double,1> time_data_bound(2); |
---|
| 2408 | CArray<double,1> time_counter(1); |
---|
| 2409 | CArray<double,1> time_counter_bound(2); |
---|
| 2410 | |
---|
| 2411 | bool wtime = (field->getOperationTimeType() != func::CFunctor::once); |
---|
[1158] | 2412 | bool wtimeCounter =false ; |
---|
| 2413 | bool wtimeData =false ; |
---|
| 2414 | |
---|
[707] | 2415 | |
---|
[444] | 2416 | if (wtime) |
---|
| 2417 | { |
---|
[692] | 2418 | Time lastWrite = field->last_Write_srv; |
---|
| 2419 | Time lastLastWrite = field->lastlast_Write_srv; |
---|
| 2420 | |
---|
[1158] | 2421 | |
---|
| 2422 | if (field->hasTimeInstant) |
---|
| 2423 | { |
---|
| 2424 | time_data(0) = time_data_bound(1) = lastWrite; |
---|
[692] | 2425 | time_data_bound(0) = time_data_bound(1) = lastWrite; |
---|
[1158] | 2426 | if (timeCounterType==instant) |
---|
| 2427 | { |
---|
| 2428 | time_counter(0) = time_data(0); |
---|
| 2429 | time_counter_bound(0) = time_data_bound(0); |
---|
| 2430 | time_counter_bound(1) = time_data_bound(1); |
---|
| 2431 | wtimeCounter=true ; |
---|
| 2432 | } |
---|
| 2433 | if (hasTimeInstant) wtimeData=true ; |
---|
| 2434 | } |
---|
| 2435 | else if (field->hasTimeCentered) |
---|
[488] | 2436 | { |
---|
[1158] | 2437 | time_data(0) = (lastWrite + lastLastWrite) / 2; |
---|
[692] | 2438 | time_data_bound(0) = lastLastWrite; |
---|
| 2439 | time_data_bound(1) = lastWrite; |
---|
[1158] | 2440 | if (timeCounterType==centered) |
---|
| 2441 | { |
---|
| 2442 | time_counter(0) = time_data(0) ; |
---|
| 2443 | time_counter_bound(0) = time_data_bound(0) ; |
---|
| 2444 | time_counter_bound(1) = time_data_bound(1) ; |
---|
| 2445 | wtimeCounter=true ; |
---|
| 2446 | } |
---|
| 2447 | if (hasTimeCentered) wtimeData=true ; |
---|
[488] | 2448 | } |
---|
| 2449 | |
---|
[1158] | 2450 | if (timeCounterType==record) |
---|
| 2451 | { |
---|
[692] | 2452 | time_counter(0) = field->getNStep() - 1; |
---|
[1158] | 2453 | time_counter_bound(0) = time_counter_bound(1) = field->getNStep() - 1; |
---|
| 2454 | wtimeCounter=true ; |
---|
| 2455 | } |
---|
[692] | 2456 | |
---|
[1158] | 2457 | if (!field->file->time_units.isEmpty() && field->file->time_units==CFile::time_units_attr::days) |
---|
[692] | 2458 | { |
---|
[1158] | 2459 | double secByDay=context->getCalendar()->getDayLengthInSeconds() ; |
---|
| 2460 | time_data/=secByDay; |
---|
| 2461 | time_data_bound/=secByDay; |
---|
| 2462 | time_counter/=secByDay; |
---|
| 2463 | time_counter_bound/=secByDay; |
---|
[692] | 2464 | } |
---|
| 2465 | } |
---|
| 2466 | |
---|
[707] | 2467 | bool isRoot = (server->intraCommRank == 0); |
---|
[488] | 2468 | |
---|
[464] | 2469 | if (!field->scale_factor.isEmpty() || !field->add_offset.isEmpty()) |
---|
| 2470 | { |
---|
[707] | 2471 | double scaleFactor = 1.0; |
---|
| 2472 | double addOffset = 0.0; |
---|
| 2473 | if (!field->scale_factor.isEmpty()) scaleFactor = field->scale_factor; |
---|
| 2474 | if (!field->add_offset.isEmpty()) addOffset = field->add_offset; |
---|
| 2475 | field->scaleFactorAddOffset(scaleFactor, addOffset); |
---|
[464] | 2476 | } |
---|
[488] | 2477 | |
---|
[498] | 2478 | try |
---|
[219] | 2479 | { |
---|
[676] | 2480 | size_t writtenSize; |
---|
| 2481 | if (field->getUseCompressedOutput()) |
---|
| 2482 | writtenSize = grid->getNumberWrittenIndexes(); |
---|
| 2483 | else |
---|
| 2484 | writtenSize = grid->getWrittenDataSize(); |
---|
| 2485 | |
---|
| 2486 | CArray<double,1> fieldData(writtenSize); |
---|
[567] | 2487 | if (!field->default_value.isEmpty()) fieldData = field->default_value; |
---|
[676] | 2488 | |
---|
| 2489 | if (field->getUseCompressedOutput()) |
---|
| 2490 | field->outputCompressedField(fieldData); |
---|
| 2491 | else |
---|
| 2492 | field->outputField(fieldData); |
---|
| 2493 | |
---|
[707] | 2494 | if (!field->prec.isEmpty() && field->prec == 2) fieldData = round(fieldData); |
---|
[567] | 2495 | |
---|
| 2496 | switch (SuperClass::type) |
---|
[498] | 2497 | { |
---|
[567] | 2498 | case (MULTI_FILE) : |
---|
| 2499 | { |
---|
[1158] | 2500 | CTimer::get("Files : writing data").resume(); |
---|
[692] | 2501 | SuperClassWriter::writeData(fieldData, fieldid, isCollective, field->getNStep() - 1); |
---|
[1158] | 2502 | CTimer::get("Files : writing data").suspend(); |
---|
[567] | 2503 | if (wtime) |
---|
| 2504 | { |
---|
[1158] | 2505 | CTimer::get("Files : writing time axis").resume(); |
---|
| 2506 | if ( wtimeData) |
---|
[692] | 2507 | { |
---|
[1158] | 2508 | SuperClassWriter::writeTimeAxisData(time_data, timeAxisId, isCollective, field->getNStep() - 1, isRoot); |
---|
| 2509 | SuperClassWriter::writeTimeAxisDataBounds(time_data_bound, timeAxisBoundId, isCollective, field->getNStep() - 1, isRoot); |
---|
| 2510 | } |
---|
| 2511 | if (wtimeCounter) |
---|
| 2512 | { |
---|
| 2513 | SuperClassWriter::writeTimeAxisData(time_counter, getTimeCounterName(), isCollective, field->getNStep() - 1,isRoot); |
---|
| 2514 | if (timeCounterType!=record) SuperClassWriter::writeTimeAxisDataBounds(time_counter_bound, timeBoundId, isCollective, field->getNStep() - 1, isRoot); |
---|
[692] | 2515 | } |
---|
[1158] | 2516 | CTimer::get("Files : writing time axis").suspend(); |
---|
[567] | 2517 | } |
---|
[707] | 2518 | break; |
---|
[567] | 2519 | } |
---|
| 2520 | case (ONE_FILE) : |
---|
| 2521 | { |
---|
[676] | 2522 | const std::vector<int>& nZoomBeginGlobal = grid->getDistributionServer()->getZoomBeginGlobal(); |
---|
| 2523 | const std::vector<int>& nZoomBeginServer = grid->getDistributionServer()->getZoomBeginServer(); |
---|
| 2524 | const std::vector<int>& nZoomSizeServer = grid->getDistributionServer()->getZoomSizeServer(); |
---|
[464] | 2525 | |
---|
[676] | 2526 | std::vector<StdSize> start, count; |
---|
[464] | 2527 | |
---|
[676] | 2528 | if (field->getUseCompressedOutput()) |
---|
| 2529 | { |
---|
| 2530 | if (grid->isCompressible()) |
---|
| 2531 | { |
---|
| 2532 | start.push_back(grid->getOffsetWrittenIndexes()); |
---|
| 2533 | count.push_back(grid->getNumberWrittenIndexes()); |
---|
| 2534 | } |
---|
| 2535 | else |
---|
| 2536 | { |
---|
[887] | 2537 | CArray<int,1> axisDomainOrder = grid->axis_domain_order; |
---|
[676] | 2538 | std::vector<StdString> domainList = grid->getDomainList(); |
---|
| 2539 | std::vector<StdString> axisList = grid->getAxisList(); |
---|
| 2540 | int numElement = axisDomainOrder.numElements(); |
---|
| 2541 | int idxDomain = domainList.size() - 1, idxAxis = axisList.size() - 1; |
---|
| 2542 | int idx = nZoomBeginGlobal.size() - 1; |
---|
[464] | 2543 | |
---|
[676] | 2544 | start.reserve(nZoomBeginGlobal.size()); |
---|
| 2545 | count.reserve(nZoomBeginGlobal.size()); |
---|
| 2546 | |
---|
| 2547 | |
---|
| 2548 | for (int i = numElement - 1; i >= 0; --i) |
---|
| 2549 | { |
---|
[887] | 2550 | if (2 == axisDomainOrder(i)) |
---|
[676] | 2551 | { |
---|
| 2552 | CDomain* domain = CDomain::get(domainList[idxDomain]); |
---|
| 2553 | |
---|
| 2554 | if (domain->isCompressible()) |
---|
| 2555 | { |
---|
[1249] | 2556 | start.push_back(domain->getOffsetWrittenIndexes(comm_file)); |
---|
| 2557 | count.push_back(domain->getNumberWrittenIndexes(comm_file)); |
---|
[710] | 2558 | idx -= 2; |
---|
[676] | 2559 | } |
---|
| 2560 | else |
---|
| 2561 | { |
---|
[710] | 2562 | if ((domain->type) != CDomain::type_attr::unstructured) |
---|
| 2563 | { |
---|
| 2564 | start.push_back(nZoomBeginServer[idx] - nZoomBeginGlobal[idx]); |
---|
| 2565 | count.push_back(nZoomSizeServer[idx]); |
---|
| 2566 | } |
---|
| 2567 | --idx; |
---|
[676] | 2568 | start.push_back(nZoomBeginServer[idx] - nZoomBeginGlobal[idx]); |
---|
| 2569 | count.push_back(nZoomSizeServer[idx]); |
---|
[710] | 2570 | --idx; |
---|
[676] | 2571 | } |
---|
| 2572 | --idxDomain; |
---|
| 2573 | } |
---|
[887] | 2574 | else if (1 == axisDomainOrder(i)) |
---|
[676] | 2575 | { |
---|
| 2576 | CAxis* axis = CAxis::get(axisList[idxAxis]); |
---|
| 2577 | |
---|
| 2578 | if (axis->isCompressible()) |
---|
| 2579 | { |
---|
[1249] | 2580 | start.push_back(axis->getOffsetWrittenIndexes(comm_file)); |
---|
| 2581 | count.push_back(axis->getNumberWrittenIndexes(comm_file)); |
---|
[676] | 2582 | } |
---|
| 2583 | else |
---|
| 2584 | { |
---|
| 2585 | start.push_back(nZoomBeginServer[idx] - nZoomBeginGlobal[idx]); |
---|
| 2586 | count.push_back(nZoomSizeServer[idx]); |
---|
| 2587 | } |
---|
| 2588 | --idxAxis; |
---|
| 2589 | --idx; |
---|
| 2590 | } |
---|
| 2591 | } |
---|
[1158] | 2592 | } |
---|
[676] | 2593 | } |
---|
| 2594 | else |
---|
[498] | 2595 | { |
---|
[887] | 2596 | CArray<int,1> axisDomainOrder = grid->axis_domain_order; |
---|
[705] | 2597 | std::vector<StdString> domainList = grid->getDomainList(); |
---|
| 2598 | std::vector<StdString> axisList = grid->getAxisList(); |
---|
| 2599 | int numElement = axisDomainOrder.numElements(); |
---|
| 2600 | int idxDomain = domainList.size() - 1, idxAxis = axisList.size() - 1; |
---|
[1624] | 2601 | int idx = domainList.size() * 2 + axisList.size() - 1; |
---|
[705] | 2602 | |
---|
| 2603 | start.reserve(nZoomBeginGlobal.size()); |
---|
| 2604 | count.reserve(nZoomBeginGlobal.size()); |
---|
| 2605 | |
---|
| 2606 | for (int i = numElement - 1; i >= 0; --i) |
---|
| 2607 | { |
---|
[887] | 2608 | if (2 == axisDomainOrder(i)) |
---|
[705] | 2609 | { |
---|
| 2610 | CDomain* domain = CDomain::get(domainList[idxDomain]); |
---|
[710] | 2611 | if ((domain->type) != CDomain::type_attr::unstructured) |
---|
[705] | 2612 | { |
---|
[1099] | 2613 | start.push_back(domain->zoom_jbegin - domain->global_zoom_jbegin); |
---|
| 2614 | count.push_back(domain->zoom_nj); |
---|
[705] | 2615 | } |
---|
| 2616 | --idx ; |
---|
[1143] | 2617 | |
---|
[1099] | 2618 | start.push_back(domain->zoom_ibegin - domain->global_zoom_ibegin); |
---|
| 2619 | count.push_back(domain->zoom_ni); |
---|
[705] | 2620 | --idx ; |
---|
| 2621 | --idxDomain; |
---|
| 2622 | } |
---|
[887] | 2623 | else if (1 == axisDomainOrder(i)) |
---|
[705] | 2624 | { |
---|
[1143] | 2625 | CAxis* axis = CAxis::get(axisList[idxAxis]); |
---|
[1099] | 2626 | start.push_back(axis->zoom_begin - axis->global_zoom_begin); |
---|
| 2627 | count.push_back(axis->zoom_n); |
---|
[705] | 2628 | --idx; |
---|
[1025] | 2629 | --idxAxis; |
---|
[887] | 2630 | } |
---|
| 2631 | else |
---|
| 2632 | { |
---|
| 2633 | if (1 == axisDomainOrder.numElements()) |
---|
| 2634 | { |
---|
| 2635 | start.push_back(0); |
---|
| 2636 | count.push_back(1); |
---|
| 2637 | } |
---|
| 2638 | --idx; |
---|
| 2639 | } |
---|
[705] | 2640 | } |
---|
[498] | 2641 | } |
---|
[488] | 2642 | |
---|
[1158] | 2643 | |
---|
| 2644 | CTimer::get("Files : writing data").resume(); |
---|
[676] | 2645 | SuperClassWriter::writeData(fieldData, fieldid, isCollective, field->getNStep() - 1, &start, &count); |
---|
[1158] | 2646 | CTimer::get("Files : writing data").suspend(); |
---|
| 2647 | |
---|
| 2648 | if (wtime) |
---|
| 2649 | { |
---|
| 2650 | CTimer::get("Files : writing time axis").resume(); |
---|
| 2651 | if ( wtimeData) |
---|
[692] | 2652 | { |
---|
[1158] | 2653 | SuperClassWriter::writeTimeAxisData(time_data, timeAxisId, isCollective, field->getNStep() - 1, isRoot); |
---|
| 2654 | SuperClassWriter::writeTimeAxisDataBounds(time_data_bound, timeAxisBoundId, isCollective, field->getNStep() - 1, isRoot); |
---|
[692] | 2655 | } |
---|
[1158] | 2656 | if (wtimeCounter) |
---|
| 2657 | { |
---|
| 2658 | SuperClassWriter::writeTimeAxisData(time_counter, getTimeCounterName(), isCollective, field->getNStep() - 1,isRoot); |
---|
| 2659 | if (timeCounterType!=record) SuperClassWriter::writeTimeAxisDataBounds(time_counter_bound, timeBoundId, isCollective, field->getNStep() - 1, isRoot); |
---|
[586] | 2660 | |
---|
[1158] | 2661 | } |
---|
| 2662 | CTimer::get("Files : writing time axis").suspend(); |
---|
| 2663 | } |
---|
| 2664 | |
---|
[586] | 2665 | break; |
---|
[286] | 2666 | } |
---|
[567] | 2667 | } |
---|
[219] | 2668 | } |
---|
[498] | 2669 | catch (CNetCdfException& e) |
---|
| 2670 | { |
---|
| 2671 | StdString msg("On writing field data: "); |
---|
| 2672 | msg.append(fieldid); msg.append("\n"); |
---|
| 2673 | msg.append("In the context : "); |
---|
| 2674 | msg.append(context->getId()); msg.append("\n"); |
---|
| 2675 | msg.append(e.what()); |
---|
[1130] | 2676 | ERROR("CNc4DataOutput::writeFieldData_ (CField* field)", << msg); |
---|
[498] | 2677 | } |
---|
[219] | 2678 | } |
---|
| 2679 | |
---|
| 2680 | //--------------------------------------------------------------- |
---|
| 2681 | |
---|
| 2682 | void CNc4DataOutput::writeTimeAxis_ |
---|
[347] | 2683 | (CField* field, |
---|
[343] | 2684 | const boost::shared_ptr<CCalendar> cal) |
---|
[219] | 2685 | { |
---|
| 2686 | StdOStringStream oss; |
---|
[1158] | 2687 | bool createInstantAxis=false ; |
---|
| 2688 | bool createCenteredAxis=false ; |
---|
| 2689 | bool createTimeCounterAxis=false ; |
---|
| 2690 | |
---|
[645] | 2691 | if (field->getOperationTimeType() == func::CFunctor::once) return ; |
---|
[488] | 2692 | |
---|
| 2693 | |
---|
[1158] | 2694 | StdString axisId ; |
---|
| 2695 | StdString axisBoundId; |
---|
[802] | 2696 | StdString timeid(getTimeCounterName()); |
---|
[614] | 2697 | StdString timeBoundId("axis_nbounds"); |
---|
[488] | 2698 | |
---|
[1158] | 2699 | StdString strTimeUnits ; |
---|
| 2700 | if (!field->file->time_units.isEmpty() && field->file->time_units==CFile::time_units_attr::days) strTimeUnits="days since " ; |
---|
| 2701 | else strTimeUnits="seconds since " ; |
---|
| 2702 | |
---|
| 2703 | if (field->getOperationTimeType() == func::CFunctor::instant) field->hasTimeInstant = true; |
---|
| 2704 | if (field->getOperationTimeType() == func::CFunctor::centered) field->hasTimeCentered = true; |
---|
| 2705 | |
---|
| 2706 | |
---|
| 2707 | if (field->file->time_counter.isEmpty()) |
---|
[488] | 2708 | { |
---|
[1158] | 2709 | if (timeCounterType==none) createTimeCounterAxis=true ; |
---|
| 2710 | if (field->hasTimeCentered) |
---|
| 2711 | { |
---|
| 2712 | timeCounterType=centered ; |
---|
| 2713 | if (!hasTimeCentered) createCenteredAxis=true ; |
---|
| 2714 | } |
---|
| 2715 | if (field->hasTimeInstant) |
---|
| 2716 | { |
---|
| 2717 | if (timeCounterType==none) timeCounterType=instant ; |
---|
| 2718 | if (!hasTimeInstant) createInstantAxis=true ; |
---|
| 2719 | } |
---|
[488] | 2720 | } |
---|
[1158] | 2721 | else if (field->file->time_counter==CFile::time_counter_attr::instant) |
---|
| 2722 | { |
---|
| 2723 | if (field->hasTimeCentered) |
---|
| 2724 | { |
---|
| 2725 | if (!hasTimeCentered) createCenteredAxis=true ; |
---|
| 2726 | } |
---|
| 2727 | if (field->hasTimeInstant) |
---|
| 2728 | { |
---|
| 2729 | if (timeCounterType==none) createTimeCounterAxis=true ; |
---|
| 2730 | timeCounterType=instant ; |
---|
| 2731 | if (!hasTimeInstant) createInstantAxis=true ; |
---|
| 2732 | } |
---|
| 2733 | } |
---|
| 2734 | else if (field->file->time_counter==CFile::time_counter_attr::centered) |
---|
| 2735 | { |
---|
| 2736 | if (field->hasTimeCentered) |
---|
| 2737 | { |
---|
| 2738 | if (timeCounterType==none) createTimeCounterAxis=true ; |
---|
| 2739 | timeCounterType=centered ; |
---|
| 2740 | if (!hasTimeCentered) createCenteredAxis=true ; |
---|
| 2741 | } |
---|
| 2742 | if (field->hasTimeInstant) |
---|
| 2743 | { |
---|
| 2744 | if (!hasTimeInstant) createInstantAxis=true ; |
---|
| 2745 | } |
---|
| 2746 | } |
---|
| 2747 | else if (field->file->time_counter==CFile::time_counter_attr::instant_exclusive) |
---|
| 2748 | { |
---|
| 2749 | if (field->hasTimeCentered) |
---|
| 2750 | { |
---|
| 2751 | if (!hasTimeCentered) createCenteredAxis=true ; |
---|
| 2752 | } |
---|
| 2753 | if (field->hasTimeInstant) |
---|
| 2754 | { |
---|
| 2755 | if (timeCounterType==none) createTimeCounterAxis=true ; |
---|
| 2756 | timeCounterType=instant ; |
---|
| 2757 | } |
---|
| 2758 | } |
---|
| 2759 | else if (field->file->time_counter==CFile::time_counter_attr::centered_exclusive) |
---|
| 2760 | { |
---|
| 2761 | if (field->hasTimeCentered) |
---|
| 2762 | { |
---|
| 2763 | if (timeCounterType==none) createTimeCounterAxis=true ; |
---|
| 2764 | timeCounterType=centered ; |
---|
| 2765 | } |
---|
| 2766 | if (field->hasTimeInstant) |
---|
| 2767 | { |
---|
| 2768 | if (!hasTimeInstant) createInstantAxis=true ; |
---|
| 2769 | } |
---|
| 2770 | } |
---|
| 2771 | else if (field->file->time_counter==CFile::time_counter_attr::exclusive) |
---|
| 2772 | { |
---|
| 2773 | if (field->hasTimeCentered) |
---|
| 2774 | { |
---|
| 2775 | if (timeCounterType==none) createTimeCounterAxis=true ; |
---|
| 2776 | if (timeCounterType==instant) createInstantAxis=true ; |
---|
| 2777 | timeCounterType=centered ; |
---|
| 2778 | } |
---|
| 2779 | if (field->hasTimeInstant) |
---|
| 2780 | { |
---|
| 2781 | if (timeCounterType==none) |
---|
| 2782 | { |
---|
| 2783 | createTimeCounterAxis=true ; |
---|
| 2784 | timeCounterType=instant ; |
---|
| 2785 | } |
---|
| 2786 | if (timeCounterType==centered) |
---|
| 2787 | { |
---|
| 2788 | if (!hasTimeInstant) createInstantAxis=true ; |
---|
| 2789 | } |
---|
| 2790 | } |
---|
| 2791 | } |
---|
| 2792 | else if (field->file->time_counter==CFile::time_counter_attr::none) |
---|
| 2793 | { |
---|
| 2794 | if (field->hasTimeCentered) |
---|
| 2795 | { |
---|
| 2796 | if (!hasTimeCentered) createCenteredAxis=true ; |
---|
| 2797 | } |
---|
| 2798 | if (field->hasTimeInstant) |
---|
| 2799 | { |
---|
| 2800 | if (!hasTimeInstant) createInstantAxis=true ; |
---|
| 2801 | } |
---|
| 2802 | } |
---|
| 2803 | else if (field->file->time_counter==CFile::time_counter_attr::record) |
---|
| 2804 | { |
---|
| 2805 | if (timeCounterType==none) createTimeCounterAxis=true ; |
---|
| 2806 | timeCounterType=record ; |
---|
| 2807 | if (field->hasTimeCentered) |
---|
| 2808 | { |
---|
| 2809 | if (!hasTimeCentered) createCenteredAxis=true ; |
---|
| 2810 | } |
---|
| 2811 | if (field->hasTimeInstant) |
---|
| 2812 | { |
---|
| 2813 | if (!hasTimeInstant) createInstantAxis=true ; |
---|
| 2814 | } |
---|
| 2815 | } |
---|
| 2816 | |
---|
| 2817 | if (createInstantAxis) |
---|
| 2818 | { |
---|
| 2819 | axisId="time_instant" ; |
---|
| 2820 | axisBoundId="time_instant_bounds"; |
---|
| 2821 | hasTimeInstant=true ; |
---|
| 2822 | } |
---|
[488] | 2823 | |
---|
[1158] | 2824 | if (createCenteredAxis) |
---|
| 2825 | { |
---|
| 2826 | axisId="time_centered" ; |
---|
| 2827 | axisBoundId="time_centered_bounds"; |
---|
| 2828 | hasTimeCentered=true ; |
---|
| 2829 | } |
---|
| 2830 | |
---|
| 2831 | |
---|
[498] | 2832 | try |
---|
[219] | 2833 | { |
---|
[1158] | 2834 | std::vector<StdString> dims; |
---|
| 2835 | |
---|
| 2836 | if (createInstantAxis || createCenteredAxis) |
---|
| 2837 | { |
---|
| 2838 | // Adding time_instant or time_centered |
---|
| 2839 | dims.push_back(timeid); |
---|
| 2840 | if (!SuperClassWriter::varExist(axisId)) |
---|
| 2841 | { |
---|
| 2842 | SuperClassWriter::addVariable(axisId, NC_DOUBLE, dims); |
---|
[488] | 2843 | |
---|
[1158] | 2844 | CDate timeOrigin=cal->getTimeOrigin() ; |
---|
| 2845 | StdOStringStream oss2; |
---|
| 2846 | StdString strInitdate=oss2.str() ; |
---|
| 2847 | StdString strTimeOrigin=timeOrigin.toString() ; |
---|
| 2848 | this->writeTimeAxisAttributes(axisId, cal->getType(),strTimeUnits+strTimeOrigin, |
---|
| 2849 | strTimeOrigin, axisBoundId); |
---|
| 2850 | } |
---|
[219] | 2851 | |
---|
[1158] | 2852 | // Adding time_instant_bounds or time_centered_bounds variables |
---|
| 2853 | if (!SuperClassWriter::varExist(axisBoundId)) |
---|
| 2854 | { |
---|
| 2855 | dims.clear() ; |
---|
| 2856 | dims.push_back(timeid); |
---|
| 2857 | dims.push_back(timeBoundId); |
---|
| 2858 | SuperClassWriter::addVariable(axisBoundId, NC_DOUBLE, dims); |
---|
| 2859 | } |
---|
[498] | 2860 | } |
---|
[488] | 2861 | |
---|
[1158] | 2862 | if (createTimeCounterAxis) |
---|
[498] | 2863 | { |
---|
[692] | 2864 | // Adding time_counter |
---|
[1158] | 2865 | axisId = getTimeCounterName(); |
---|
[802] | 2866 | axisBoundId = getTimeCounterName() + "_bounds"; |
---|
[692] | 2867 | dims.clear(); |
---|
| 2868 | dims.push_back(timeid); |
---|
[1158] | 2869 | if (!SuperClassWriter::varExist(axisId)) |
---|
[692] | 2870 | { |
---|
[1158] | 2871 | SuperClassWriter::addVariable(axisId, NC_DOUBLE, dims); |
---|
| 2872 | SuperClassWriter::addAttribute("axis", string("T"), &axisId); |
---|
[488] | 2873 | |
---|
[1158] | 2874 | if (field->file->time_counter.isEmpty() || |
---|
| 2875 | (field->file->time_counter != CFile::time_counter_attr::record)) |
---|
[692] | 2876 | { |
---|
| 2877 | CDate timeOrigin = cal->getTimeOrigin(); |
---|
| 2878 | StdString strTimeOrigin = timeOrigin.toString(); |
---|
[498] | 2879 | |
---|
[1158] | 2880 | this->writeTimeAxisAttributes(axisId, cal->getType(), |
---|
| 2881 | strTimeUnits+strTimeOrigin, |
---|
[692] | 2882 | strTimeOrigin, axisBoundId); |
---|
| 2883 | } |
---|
| 2884 | } |
---|
| 2885 | |
---|
| 2886 | // Adding time_counter_bound dimension |
---|
[1158] | 2887 | if (field->file->time_counter.isEmpty() || (field->file->time_counter != CFile::time_counter_attr::record)) |
---|
[692] | 2888 | { |
---|
| 2889 | if (!SuperClassWriter::varExist(axisBoundId)) |
---|
| 2890 | { |
---|
| 2891 | dims.clear(); |
---|
| 2892 | dims.push_back(timeid); |
---|
| 2893 | dims.push_back(timeBoundId); |
---|
| 2894 | SuperClassWriter::addVariable(axisBoundId, NC_DOUBLE, dims); |
---|
| 2895 | } |
---|
| 2896 | } |
---|
[498] | 2897 | } |
---|
[488] | 2898 | } |
---|
[498] | 2899 | catch (CNetCdfException& e) |
---|
[488] | 2900 | { |
---|
[498] | 2901 | StdString msg("On writing time axis data: "); |
---|
| 2902 | msg.append("In the context : "); |
---|
| 2903 | CContext* context = CContext::getCurrent() ; |
---|
| 2904 | msg.append(context->getId()); msg.append("\n"); |
---|
| 2905 | msg.append(e.what()); |
---|
| 2906 | ERROR("CNc4DataOutput::writeTimeAxis_ (CField* field, \ |
---|
| 2907 | const boost::shared_ptr<CCalendar> cal)", << msg); |
---|
[488] | 2908 | } |
---|
[219] | 2909 | } |
---|
| 2910 | |
---|
| 2911 | //--------------------------------------------------------------- |
---|
[488] | 2912 | |
---|
[219] | 2913 | void CNc4DataOutput::writeTimeAxisAttributes(const StdString & axis_name, |
---|
| 2914 | const StdString & calendar, |
---|
| 2915 | const StdString & units, |
---|
| 2916 | const StdString & time_origin, |
---|
[488] | 2917 | const StdString & time_bounds, |
---|
[219] | 2918 | const StdString & standard_name, |
---|
[613] | 2919 | const StdString & long_name) |
---|
[219] | 2920 | { |
---|
[498] | 2921 | try |
---|
| 2922 | { |
---|
| 2923 | SuperClassWriter::addAttribute("standard_name", standard_name, &axis_name); |
---|
| 2924 | SuperClassWriter::addAttribute("long_name", long_name , &axis_name); |
---|
| 2925 | SuperClassWriter::addAttribute("calendar", calendar , &axis_name); |
---|
| 2926 | SuperClassWriter::addAttribute("units", units , &axis_name); |
---|
| 2927 | SuperClassWriter::addAttribute("time_origin", time_origin , &axis_name); |
---|
| 2928 | SuperClassWriter::addAttribute("bounds", time_bounds , &axis_name); |
---|
| 2929 | } |
---|
| 2930 | catch (CNetCdfException& e) |
---|
| 2931 | { |
---|
| 2932 | StdString msg("On writing time axis Attribute: "); |
---|
| 2933 | msg.append("In the context : "); |
---|
| 2934 | CContext* context = CContext::getCurrent() ; |
---|
| 2935 | msg.append(context->getId()); msg.append("\n"); |
---|
| 2936 | msg.append(e.what()); |
---|
| 2937 | ERROR("CNc4DataOutput::writeTimeAxisAttributes(const StdString & axis_name, \ |
---|
[613] | 2938 | const StdString & calendar,\ |
---|
| 2939 | const StdString & units, \ |
---|
| 2940 | const StdString & time_origin, \ |
---|
| 2941 | const StdString & time_bounds, \ |
---|
| 2942 | const StdString & standard_name, \ |
---|
| 2943 | const StdString & long_name)", << msg); |
---|
[498] | 2944 | } |
---|
[219] | 2945 | } |
---|
[488] | 2946 | |
---|
[219] | 2947 | //--------------------------------------------------------------- |
---|
| 2948 | |
---|
| 2949 | void CNc4DataOutput::writeAxisAttributes(const StdString & axis_name, |
---|
| 2950 | const StdString & axis, |
---|
| 2951 | const StdString & standard_name, |
---|
| 2952 | const StdString & long_name, |
---|
| 2953 | const StdString & units, |
---|
| 2954 | const StdString & nav_model) |
---|
| 2955 | { |
---|
[498] | 2956 | try |
---|
| 2957 | { |
---|
[613] | 2958 | if (!axis.empty()) |
---|
| 2959 | SuperClassWriter::addAttribute("axis" , axis , &axis_name); |
---|
| 2960 | |
---|
[498] | 2961 | SuperClassWriter::addAttribute("standard_name", standard_name, &axis_name); |
---|
| 2962 | SuperClassWriter::addAttribute("long_name" , long_name , &axis_name); |
---|
| 2963 | SuperClassWriter::addAttribute("units" , units , &axis_name); |
---|
[973] | 2964 | // SuperClassWriter::addAttribute("nav_model" , nav_model , &axis_name); |
---|
[498] | 2965 | } |
---|
| 2966 | catch (CNetCdfException& e) |
---|
| 2967 | { |
---|
| 2968 | StdString msg("On writing Axis Attribute: "); |
---|
| 2969 | msg.append("In the context : "); |
---|
| 2970 | CContext* context = CContext::getCurrent() ; |
---|
| 2971 | msg.append(context->getId()); msg.append("\n"); |
---|
| 2972 | msg.append(e.what()); |
---|
| 2973 | ERROR("CNc4DataOutput::writeAxisAttributes(const StdString & axis_name, \ |
---|
[613] | 2974 | const StdString & axis, \ |
---|
| 2975 | const StdString & standard_name, \ |
---|
| 2976 | const StdString & long_name, \ |
---|
| 2977 | const StdString & units, \ |
---|
| 2978 | const StdString & nav_model)", << msg); |
---|
[498] | 2979 | } |
---|
[219] | 2980 | } |
---|
| 2981 | |
---|
| 2982 | //--------------------------------------------------------------- |
---|
[488] | 2983 | |
---|
[219] | 2984 | void CNc4DataOutput::writeLocalAttributes |
---|
| 2985 | (int ibegin, int ni, int jbegin, int nj, StdString domid) |
---|
| 2986 | { |
---|
[498] | 2987 | try |
---|
| 2988 | { |
---|
[318] | 2989 | SuperClassWriter::addAttribute(StdString("ibegin").append(domid), ibegin); |
---|
| 2990 | SuperClassWriter::addAttribute(StdString("ni" ).append(domid), ni); |
---|
| 2991 | SuperClassWriter::addAttribute(StdString("jbegin").append(domid), jbegin); |
---|
| 2992 | SuperClassWriter::addAttribute(StdString("nj" ).append(domid), nj); |
---|
[498] | 2993 | } |
---|
| 2994 | catch (CNetCdfException& e) |
---|
| 2995 | { |
---|
| 2996 | StdString msg("On writing Local Attributes: "); |
---|
| 2997 | msg.append("In the context : "); |
---|
| 2998 | CContext* context = CContext::getCurrent() ; |
---|
| 2999 | msg.append(context->getId()); msg.append("\n"); |
---|
| 3000 | msg.append(e.what()); |
---|
| 3001 | ERROR("CNc4DataOutput::writeLocalAttributes \ |
---|
| 3002 | (int ibegin, int ni, int jbegin, int nj, StdString domid)", << msg); |
---|
| 3003 | } |
---|
| 3004 | |
---|
[219] | 3005 | } |
---|
| 3006 | |
---|
[628] | 3007 | void CNc4DataOutput::writeLocalAttributes_IOIPSL(const StdString& dimXid, const StdString& dimYid, |
---|
| 3008 | int ibegin, int ni, int jbegin, int nj, int ni_glo, int nj_glo, int rank, int size) |
---|
[391] | 3009 | { |
---|
| 3010 | CArray<int,1> array(2) ; |
---|
| 3011 | |
---|
[498] | 3012 | try |
---|
| 3013 | { |
---|
| 3014 | SuperClassWriter::addAttribute("DOMAIN_number_total",size ) ; |
---|
| 3015 | SuperClassWriter::addAttribute("DOMAIN_number", rank) ; |
---|
[629] | 3016 | array = SuperClassWriter::getDimension(dimXid) + 1, SuperClassWriter::getDimension(dimYid) + 1; |
---|
[498] | 3017 | SuperClassWriter::addAttribute("DOMAIN_dimensions_ids",array) ; |
---|
| 3018 | array=ni_glo,nj_glo ; |
---|
| 3019 | SuperClassWriter::addAttribute("DOMAIN_size_global", array) ; |
---|
| 3020 | array=ni,nj ; |
---|
| 3021 | SuperClassWriter::addAttribute("DOMAIN_size_local", array) ; |
---|
[819] | 3022 | array=ibegin+1,jbegin+1 ; |
---|
[498] | 3023 | SuperClassWriter::addAttribute("DOMAIN_position_first", array) ; |
---|
[819] | 3024 | array=ibegin+ni-1+1,jbegin+nj-1+1 ; |
---|
[498] | 3025 | SuperClassWriter::addAttribute("DOMAIN_position_last",array) ; |
---|
| 3026 | array=0,0 ; |
---|
| 3027 | SuperClassWriter::addAttribute("DOMAIN_halo_size_start", array) ; |
---|
| 3028 | SuperClassWriter::addAttribute("DOMAIN_halo_size_end", array); |
---|
| 3029 | SuperClassWriter::addAttribute("DOMAIN_type",string("box")) ; |
---|
| 3030 | /* |
---|
| 3031 | SuperClassWriter::addAttribute("DOMAIN_DIM_N001",string("x")) ; |
---|
| 3032 | SuperClassWriter::addAttribute("DOMAIN_DIM_N002",string("y")) ; |
---|
| 3033 | SuperClassWriter::addAttribute("DOMAIN_DIM_N003",string("axis_A")) ; |
---|
| 3034 | SuperClassWriter::addAttribute("DOMAIN_DIM_N004",string("time_counter")) ; |
---|
| 3035 | */ |
---|
| 3036 | } |
---|
| 3037 | catch (CNetCdfException& e) |
---|
| 3038 | { |
---|
[628] | 3039 | StdString msg("On writing Local Attributes IOIPSL \n"); |
---|
[498] | 3040 | msg.append("In the context : "); |
---|
| 3041 | CContext* context = CContext::getCurrent() ; |
---|
| 3042 | msg.append(context->getId()); msg.append("\n"); |
---|
| 3043 | msg.append(e.what()); |
---|
| 3044 | ERROR("CNc4DataOutput::writeLocalAttributes_IOIPSL \ |
---|
| 3045 | (int ibegin, int ni, int jbegin, int nj, int ni_glo, int nj_glo, int rank, int size)", << msg); |
---|
| 3046 | } |
---|
[391] | 3047 | } |
---|
[219] | 3048 | //--------------------------------------------------------------- |
---|
| 3049 | |
---|
| 3050 | void CNc4DataOutput:: writeFileAttributes(const StdString & name, |
---|
| 3051 | const StdString & description, |
---|
| 3052 | const StdString & conventions, |
---|
| 3053 | const StdString & production, |
---|
| 3054 | const StdString & timeStamp) |
---|
| 3055 | { |
---|
[498] | 3056 | try |
---|
| 3057 | { |
---|
| 3058 | SuperClassWriter::addAttribute("name" , name); |
---|
| 3059 | SuperClassWriter::addAttribute("description", description); |
---|
[613] | 3060 | SuperClassWriter::addAttribute("title" , description); |
---|
| 3061 | SuperClassWriter::addAttribute("Conventions", conventions); |
---|
[1158] | 3062 | // SuperClassWriter::addAttribute("production" , production); |
---|
| 3063 | |
---|
| 3064 | StdString timeStampStr ; |
---|
| 3065 | if (file->time_stamp_name.isEmpty()) timeStampStr="timeStamp" ; |
---|
| 3066 | else timeStampStr=file->time_stamp_name ; |
---|
| 3067 | SuperClassWriter::addAttribute(timeStampStr, timeStamp); |
---|
| 3068 | |
---|
| 3069 | StdString uuidName ; |
---|
| 3070 | if (file->uuid_name.isEmpty()) uuidName="uuid" ; |
---|
| 3071 | else uuidName=file->uuid_name ; |
---|
| 3072 | |
---|
| 3073 | if (file->uuid_format.isEmpty()) SuperClassWriter::addAttribute(uuidName, getUuidStr()); |
---|
| 3074 | else SuperClassWriter::addAttribute(uuidName, getUuidStr(file->uuid_format)); |
---|
| 3075 | |
---|
[498] | 3076 | } |
---|
| 3077 | catch (CNetCdfException& e) |
---|
| 3078 | { |
---|
| 3079 | StdString msg("On writing File Attributes \n "); |
---|
| 3080 | msg.append("In the context : "); |
---|
| 3081 | CContext* context = CContext::getCurrent() ; |
---|
| 3082 | msg.append(context->getId()); msg.append("\n"); |
---|
| 3083 | msg.append(e.what()); |
---|
| 3084 | ERROR("CNc4DataOutput:: writeFileAttributes(const StdString & name, \ |
---|
| 3085 | const StdString & description, \ |
---|
| 3086 | const StdString & conventions, \ |
---|
| 3087 | const StdString & production, \ |
---|
| 3088 | const StdString & timeStamp)", << msg); |
---|
| 3089 | } |
---|
[219] | 3090 | } |
---|
| 3091 | |
---|
| 3092 | //--------------------------------------------------------------- |
---|
| 3093 | |
---|
| 3094 | void CNc4DataOutput::writeMaskAttributes(const StdString & mask_name, |
---|
| 3095 | int data_dim, |
---|
| 3096 | int data_ni, |
---|
| 3097 | int data_nj, |
---|
| 3098 | int data_ibegin, |
---|
| 3099 | int data_jbegin) |
---|
| 3100 | { |
---|
[498] | 3101 | try |
---|
| 3102 | { |
---|
| 3103 | SuperClassWriter::addAttribute("data_dim" , data_dim , &mask_name); |
---|
| 3104 | SuperClassWriter::addAttribute("data_ni" , data_ni , &mask_name); |
---|
| 3105 | SuperClassWriter::addAttribute("data_nj" , data_nj , &mask_name); |
---|
| 3106 | SuperClassWriter::addAttribute("data_ibegin", data_ibegin, &mask_name); |
---|
| 3107 | SuperClassWriter::addAttribute("data_jbegin", data_jbegin, &mask_name); |
---|
| 3108 | } |
---|
| 3109 | catch (CNetCdfException& e) |
---|
| 3110 | { |
---|
| 3111 | StdString msg("On writing Mask Attributes \n "); |
---|
| 3112 | msg.append("In the context : "); |
---|
| 3113 | CContext* context = CContext::getCurrent() ; |
---|
| 3114 | msg.append(context->getId()); msg.append("\n"); |
---|
| 3115 | msg.append(e.what()); |
---|
| 3116 | ERROR("CNc4DataOutput::writeMaskAttributes(const StdString & mask_name, \ |
---|
| 3117 | int data_dim, \ |
---|
| 3118 | int data_ni, \ |
---|
| 3119 | int data_nj, \ |
---|
| 3120 | int data_ibegin, \ |
---|
| 3121 | int data_jbegin)", << msg); |
---|
| 3122 | } |
---|
[219] | 3123 | } |
---|
| 3124 | |
---|
| 3125 | ///-------------------------------------------------------------- |
---|
| 3126 | |
---|
[1158] | 3127 | StdSize CNc4DataOutput::getRecordFromTime(Time time, double factorUnit) |
---|
[707] | 3128 | { |
---|
| 3129 | std::map<Time, StdSize>::const_iterator it = timeToRecordCache.find(time); |
---|
| 3130 | if (it == timeToRecordCache.end()) |
---|
| 3131 | { |
---|
[802] | 3132 | StdString timeAxisBoundsId(getTimeCounterName() + "_bounds"); |
---|
[1158] | 3133 | if (!SuperClassWriter::varExist(timeAxisBoundsId)) timeAxisBoundsId = "time_centered_bounds"; |
---|
| 3134 | if (!SuperClassWriter::varExist(timeAxisBoundsId)) timeAxisBoundsId = "time_instant_bounds"; |
---|
[707] | 3135 | |
---|
| 3136 | CArray<double,2> timeAxisBounds; |
---|
[1158] | 3137 | std::vector<StdSize> dimSize(SuperClassWriter::getDimensions(timeAxisBoundsId)) ; |
---|
| 3138 | |
---|
[707] | 3139 | StdSize record = 0; |
---|
| 3140 | double dtime(time); |
---|
[1158] | 3141 | for (int n = dimSize[0] - 1; n >= 0; n--) |
---|
[707] | 3142 | { |
---|
[1158] | 3143 | SuperClassWriter::getTimeAxisBounds(timeAxisBounds, timeAxisBoundsId, isCollective, n); |
---|
| 3144 | timeAxisBounds*=factorUnit ; |
---|
| 3145 | if (timeAxisBounds(1, 0) < dtime) |
---|
[707] | 3146 | { |
---|
| 3147 | record = n + 1; |
---|
| 3148 | break; |
---|
| 3149 | } |
---|
| 3150 | } |
---|
| 3151 | it = timeToRecordCache.insert(std::make_pair(time, record)).first; |
---|
| 3152 | } |
---|
| 3153 | return it->second; |
---|
| 3154 | } |
---|
[774] | 3155 | |
---|
| 3156 | ///-------------------------------------------------------------- |
---|
| 3157 | |
---|
| 3158 | bool CNc4DataOutput::isWrittenDomain(const std::string& domainName) const |
---|
| 3159 | { |
---|
| 3160 | return (this->writtenDomains.find(domainName) != this->writtenDomains.end()); |
---|
| 3161 | } |
---|
| 3162 | |
---|
| 3163 | bool CNc4DataOutput::isWrittenCompressedDomain(const std::string& domainName) const |
---|
| 3164 | { |
---|
| 3165 | return (this->writtenCompressedDomains.find(domainName) != this->writtenCompressedDomains.end()); |
---|
| 3166 | } |
---|
| 3167 | |
---|
| 3168 | bool CNc4DataOutput::isWrittenAxis(const std::string& axisName) const |
---|
| 3169 | { |
---|
| 3170 | return (this->writtenAxis.find(axisName) != this->writtenAxis.end()); |
---|
| 3171 | } |
---|
| 3172 | |
---|
| 3173 | bool CNc4DataOutput::isWrittenCompressedAxis(const std::string& axisName) const |
---|
| 3174 | { |
---|
| 3175 | return (this->writtenCompressedAxis.find(axisName) != this->writtenCompressedAxis.end()); |
---|
| 3176 | } |
---|
| 3177 | |
---|
[887] | 3178 | bool CNc4DataOutput::isWrittenScalar(const std::string& scalarName) const |
---|
| 3179 | { |
---|
| 3180 | return (this->writtenScalar.find(scalarName) != this->writtenScalar.end()); |
---|
| 3181 | } |
---|
| 3182 | |
---|
[774] | 3183 | void CNc4DataOutput::setWrittenDomain(const std::string& domainName) |
---|
| 3184 | { |
---|
| 3185 | this->writtenDomains.insert(domainName); |
---|
| 3186 | } |
---|
| 3187 | |
---|
| 3188 | void CNc4DataOutput::setWrittenCompressedDomain(const std::string& domainName) |
---|
| 3189 | { |
---|
| 3190 | this->writtenCompressedDomains.insert(domainName); |
---|
| 3191 | } |
---|
| 3192 | |
---|
| 3193 | void CNc4DataOutput::setWrittenAxis(const std::string& axisName) |
---|
| 3194 | { |
---|
| 3195 | this->writtenAxis.insert(axisName); |
---|
| 3196 | } |
---|
| 3197 | |
---|
| 3198 | void CNc4DataOutput::setWrittenCompressedAxis(const std::string& axisName) |
---|
| 3199 | { |
---|
| 3200 | this->writtenCompressedAxis.insert(axisName); |
---|
| 3201 | } |
---|
[887] | 3202 | |
---|
| 3203 | void CNc4DataOutput::setWrittenScalar(const std::string& scalarName) |
---|
| 3204 | { |
---|
| 3205 | this->writtenScalar.insert(scalarName); |
---|
| 3206 | } |
---|
[335] | 3207 | } // namespace xios |
---|