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