Changeset 2019 for XIOS/dev/dev_trunk_graph/src/io
- Timestamp:
- 01/22/21 12:00:29 (3 years ago)
- Location:
- XIOS/dev/dev_trunk_graph/src/io
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/dev/dev_trunk_graph/src/io/nc4_data_input.cpp
r1612 r2019 43 43 CATCH 44 44 45 void CNc4DataInput::readFieldData_(CField* field )45 void CNc4DataInput::readFieldData_(CField* field, int record, CArray<double,1>& dataOut) 46 46 TRY 47 47 { 48 48 CContext* context = CContext::getCurrent(); 49 CContextServer* server = context->server; 50 51 CGrid* grid = field->grid; 52 53 if (!grid->doGridHaveDataToWrite()) 54 if (SuperClass::type==MULTI_FILE || !isCollective) return; 49 50 CGrid* grid = field->getGrid(); 51 52 if (!grid->doGridHaveDataToWrite()) if (SuperClass::type==MULTI_FILE || !isCollective) return; 55 53 56 54 StdString fieldId = field->getFieldOutputName(); 57 55 58 CArray<double,1> fieldData(grid->getWrittenDataSize());59 if (!field->default_value.isEmpty()) fieldData = field->default_value;60 61 56 switch (SuperClass::type) 62 57 { 63 58 case MULTI_FILE: 64 SuperClassWriter::getData( fieldData, fieldId, isCollective, (field->getNStep() - 1)%field->nstepMax);59 SuperClassWriter::getData(dataOut, fieldId, isCollective, record ); 65 60 break; 66 61 case ONE_FILE: … … 109 104 } 110 105 111 SuperClassWriter::getData( fieldData, fieldId, isCollective, (field->getNStep() - 1)%field->nstepMax, &start, &count);106 SuperClassWriter::getData(dataOut, fieldId, isCollective, record, &start, &count); 112 107 break; 113 108 } 114 109 } 115 116 field->inputField(fieldData);117 118 if (!field->scale_factor.isEmpty() || !field->add_offset.isEmpty())119 {120 double scaleFactor = 1.0, addOffset = 0.0;121 if (!field->scale_factor.isEmpty()) scaleFactor = field->scale_factor;122 if (!field->add_offset.isEmpty()) addOffset = field->add_offset;123 field->invertScaleFactorAddOffset(scaleFactor, addOffset);124 }125 110 } 126 111 CATCH … … 131 116 StdString fieldId = field->getFieldOutputName(); 132 117 133 CGrid* grid = field->g rid;118 CGrid* grid = field->getGrid(); 134 119 135 120 std::vector<CDomain*> domainP = grid->getDomains(); -
XIOS/dev/dev_trunk_graph/src/io/nc4_data_input.hpp
r1486 r2019 37 37 // Read methods 38 38 virtual StdSize getFieldNbRecords_(CField* field); 39 virtual void readFieldData_(CField* field );39 virtual void readFieldData_(CField* field, int record, CArray<double,1>& data); 40 40 virtual void readFieldAttributes_(CField* field, bool readAttributeValues); 41 41 virtual void closeFile_(void); -
XIOS/dev/dev_trunk_graph/src/io/nc4_data_output.cpp
r1653 r2019 57 57 { 58 58 StdString lonName,latName ; 59 60 domain->computeWrittenIndex();61 domain->computeWrittenCompressedIndex(comm_file);62 59 63 60 if (domain->type == CDomain::type_attr::unstructured) … … 71 68 72 69 CContext* context = CContext::getCurrent() ; 73 CContextServer* server=context->server ;74 70 75 71 if (domain->IsWritten(this->filename)) return; … … 146 142 string lonid,latid,bounds_lonid,bounds_latid ; 147 143 string areaId = "area" + appendDomid; 148 /*149 StdString lonid_loc = (server->intraCommSize > 1)150 ? StdString("lon").append(appendDomid).append("_local")151 : lonid;152 StdString latid_loc = (server->intraCommSize > 1)153 ? StdString("lat").append(appendDomid).append("_local")154 : latid;155 */156 157 CArray<int, 1>& indexToWrite = domain->localIndexToWriteOnServer;158 int nbWritten = indexToWrite.numElements();159 CArray<double,1> writtenLat, writtenLon;160 CArray<double,2> writtenBndsLat, writtenBndsLon;161 CArray<double,1> writtenArea;162 163 if (domain->hasLonLat)164 {165 writtenLat.resize(nbWritten);166 writtenLon.resize(nbWritten);167 for (int idx = 0; idx < nbWritten; ++idx)168 {169 if (indexToWrite(idx) < 0)170 {171 writtenLat(idx) = -1.; // hole172 writtenLon(idx) = -1.;173 }174 else175 {176 writtenLat(idx) = domain->latvalue(indexToWrite(idx));177 writtenLon(idx) = domain->lonvalue(indexToWrite(idx));178 }179 }180 181 if (domain->hasBounds)182 {183 int nvertex = domain->nvertex, idx;184 writtenBndsLat.resize(nvertex, nbWritten);185 writtenBndsLon.resize(nvertex, nbWritten);186 CArray<double,2>& boundslat = domain->bounds_latvalue;187 CArray<double,2>& boundslon = domain->bounds_lonvalue;188 for (idx = 0; idx < nbWritten; ++idx)189 for (int nv = 0; nv < nvertex; ++nv)190 {191 if (indexToWrite(idx) < 0)192 {193 writtenBndsLat(nv, idx) = -1.; // hole194 writtenBndsLon(nv, idx) = -1.;195 }196 else197 {198 writtenBndsLat(nv, idx) = boundslat(nv, int(indexToWrite(idx)));199 writtenBndsLon(nv, idx) = boundslon(nv, int(indexToWrite(idx)));200 }201 }202 }203 }204 205 if (domain->hasArea)206 {207 writtenArea.resize(nbWritten);208 for (int idx = 0; idx < nbWritten; ++idx)209 {210 if (indexToWrite(idx) < 0)211 writtenArea(idx) = -1.;212 else213 writtenArea(idx) = domain->areavalue(indexToWrite(idx));214 }215 }216 144 217 145 try … … 246 174 SuperClassWriter::addDimension(dimVertId, domain->nvertex); 247 175 248 if ( server->intraCommSize> 1)176 if (context->intraCommSize_ > 1) 249 177 { 250 178 this->writeLocalAttributes(domain->ibegin, … … 261 189 domain->nj, 262 190 domain->ni_glo,domain->nj_glo, 263 server->intraCommRank,server->intraCommSize);191 context->intraCommRank_,context->intraCommSize_); 264 192 } 265 193 … … 299 227 dim0.push_back(dimXid); 300 228 301 302 // supress mask if (server->intraCommSize > 1)303 // supress mask {304 // supress mask SuperClassWriter::addVariable(maskid, NC_INT, dim0);305 // supress mask306 // supress mask this->writeMaskAttributes(maskid,307 // supress mask domain->data_dim.getValue()/*,308 // supress mask domain->data_ni.getValue(),309 // supress mask domain->data_nj.getValue(),310 // supress mask domain->data_ibegin.getValue(),311 // supress mask domain->data_jbegin.getValue()*/);312 // supress mask }313 314 //SuperClassWriter::setDefaultValue(maskid, &dvm);315 316 229 if (domain->hasArea) 317 230 { … … 328 241 { 329 242 case CDomain::type_attr::curvilinear : 330 SuperClassWriter::writeData( writtenLat, latid, isCollective, 0);331 SuperClassWriter::writeData( writtenLon, lonid, isCollective, 0);243 SuperClassWriter::writeData(domain->latvalue, latid, isCollective, 0); 244 SuperClassWriter::writeData(domain->lonvalue, lonid, isCollective, 0); 332 245 break; 333 246 case CDomain::type_attr::rectilinear : 334 CArray<double,1> lat = writtenLat(Range(fromStart,toEnd,domain->ni)) ;247 CArray<double,1> lat = domain->latvalue(Range(fromStart,toEnd,domain->ni)) ; 335 248 SuperClassWriter::writeData(CArray<double,1>(lat.copy()), latid, isCollective, 0); 336 CArray<double,1> lon = writtenLon(Range(0,domain->ni-1)) ;249 CArray<double,1> lon = domain->lonvalue(Range(0,domain->ni-1)) ; 337 250 SuperClassWriter::writeData(CArray<double,1>(lon.copy()), lonid, isCollective, 0); 338 251 break; … … 341 254 if (domain->hasBounds) 342 255 { 343 SuperClassWriter::writeData( writtenBndsLon, bounds_lonid, isCollective, 0);344 SuperClassWriter::writeData( writtenBndsLat, bounds_latid, isCollective, 0);256 SuperClassWriter::writeData(domain->bounds_lonvalue, bounds_lonid, isCollective, 0); 257 SuperClassWriter::writeData(domain->bounds_latvalue, bounds_latid, isCollective, 0); 345 258 } 346 259 } … … 348 261 if (domain->hasArea) 349 262 { 350 SuperClassWriter::writeData( writtenArea, areaId, isCollective, 0);263 SuperClassWriter::writeData(domain->areavalue, areaId, isCollective, 0); 351 264 } 352 265 … … 426 339 std::vector<StdSize> start(2) ; 427 340 std::vector<StdSize> count(2) ; 428 // Comment out: it is not working for a hole 429 // if (domain->isEmpty()) 430 // { 431 // start[0]=0 ; start[1]=0 ; 432 // count[0]=0 ; count[1]=0 ; 433 // } 434 // else 435 { 436 start[1]=domain->ibegin; 437 start[0]=domain->jbegin; 438 count[1]=domain->ni ; count[0]=domain->nj ; 439 } 341 start[1]=domain->ibegin; 342 start[0]=domain->jbegin; 343 count[1]=domain->ni ; count[0]=domain->nj ; 440 344 441 345 if (domain->hasLonLat) 442 346 { 443 SuperClassWriter::writeData( writtenLat, latid, isCollective, 0,&start,&count);444 SuperClassWriter::writeData( writtenLon, lonid, isCollective, 0,&start,&count);347 SuperClassWriter::writeData(domain->latvalue, latid, isCollective, 0,&start,&count); 348 SuperClassWriter::writeData(domain->lonvalue, lonid, isCollective, 0,&start,&count); 445 349 } 446 350 break; … … 452 356 std::vector<StdSize> start(1) ; 453 357 std::vector<StdSize> count(1) ; 454 if (domain->isEmpty()) 455 { 456 start[0]=0 ; 457 count[0]=0 ; 458 SuperClassWriter::writeData(writtenLat, latid, isCollective, 0,&start,&count); 459 SuperClassWriter::writeData(writtenLon, lonid, isCollective, 0,&start,&count); 460 } 461 else 462 { 463 start[0]=domain->jbegin; 464 count[0]=domain->nj; 465 CArray<double,1> lat = writtenLat(Range(fromStart,toEnd,domain->ni)); 466 SuperClassWriter::writeData(CArray<double,1>(lat.copy()), latid, isCollective, 0,&start,&count); 467 468 start[0]=domain->ibegin; 469 count[0]=domain->ni; 470 CArray<double,1> lon = writtenLon(Range(0,domain->ni-1)); 471 SuperClassWriter::writeData(CArray<double,1>(lon.copy()), lonid, isCollective, 0,&start,&count); 472 } 358 359 start[0]=domain->jbegin; 360 count[0]=domain->nj; 361 CArray<double,1> lat = domain->latvalue(Range(fromStart,toEnd,domain->ni)); 362 SuperClassWriter::writeData(CArray<double,1>(lat.copy()), latid, isCollective, 0,&start,&count); 363 364 start[0]=domain->ibegin; 365 count[0]=domain->ni; 366 CArray<double,1> lon = domain->lonvalue(Range(0,domain->ni-1)); 367 SuperClassWriter::writeData(CArray<double,1>(lon.copy()), lonid, isCollective, 0,&start,&count); 473 368 } 474 369 break; … … 495 390 } 496 391 497 SuperClassWriter::writeData( writtenBndsLon, bounds_lonid, isCollective, 0, &start, &count);498 SuperClassWriter::writeData( writtenBndsLat, bounds_latid, isCollective, 0, &start, &count);392 SuperClassWriter::writeData(domain->bounds_lonvalue, bounds_lonid, isCollective, 0, &start, &count); // will probably not working for rectilinear 393 SuperClassWriter::writeData(domain->bounds_latvalue, bounds_latid, isCollective, 0, &start, &count); 499 394 } 500 395 … … 504 399 std::vector<StdSize> count(2); 505 400 506 if (domain->isEmpty()) 507 { 508 start[0] = 0; start[1] = 0; 509 count[0] = 0; count[1] = 0; 510 } 511 else 512 { 513 start[1] = domain->ibegin; 514 start[0] = domain->jbegin; 515 count[1] = domain->ni; 516 count[0] = domain->nj; 517 } 401 start[1] = domain->ibegin; 402 start[0] = domain->jbegin; 403 count[1] = domain->ni; 404 count[0] = domain->nj; 518 405 519 SuperClassWriter::writeData( writtenArea, areaId, isCollective, 0, &start, &count);406 SuperClassWriter::writeData(domain->areavalue, areaId, isCollective, 0, &start, &count); 520 407 } 521 408 … … 548 435 { 549 436 CContext* context = CContext::getCurrent() ; 550 CContextServer* server=context->server ;551 437 552 438 if (domain->IsWritten(this->filename)) return; … … 571 457 StdString domainName = domain->name; 572 458 domain->assignMesh(domainName, domain->nvertex); 573 domain->mesh->createMeshEpsilon( server->intraComm, domain->lonvalue, domain->latvalue, domain->bounds_lonvalue, domain->bounds_latvalue);459 domain->mesh->createMeshEpsilon(context->intraComm_, domain->lonvalue, domain->latvalue, domain->bounds_lonvalue, domain->bounds_latvalue); 574 460 575 461 StdString node_x = domainName + "_node_x"; … … 908 794 { 909 795 CContext* context = CContext::getCurrent() ; 910 CContextServer* server=context->server ;911 796 912 797 if (domain->IsWritten(this->filename)) return; … … 944 829 945 830 int nvertex = (domain->nvertex.isEmpty()) ? 0 : domain->nvertex; 946 947 CArray<int, 1>& indexToWrite = domain->localIndexToWriteOnServer;948 int nbWritten = indexToWrite.numElements();949 CArray<double,1> writtenLat, writtenLon;950 CArray<double,2> writtenBndsLat, writtenBndsLon;951 CArray<double,1> writtenArea;952 953 if (domain->hasLonLat)954 {955 writtenLat.resize(nbWritten);956 writtenLon.resize(nbWritten);957 for (int idx = 0; idx < nbWritten; ++idx)958 {959 if (indexToWrite(idx) < 0)960 {961 writtenLat(idx) = -1.;962 writtenLon(idx) = -1.;963 }964 else965 {966 writtenLat(idx) = domain->latvalue(indexToWrite(idx));967 writtenLon(idx) = domain->lonvalue(indexToWrite(idx));968 }969 }970 }971 972 if (domain->hasBounds)973 {974 int nvertex = domain->nvertex, idx;975 writtenBndsLat.resize(nvertex, nbWritten);976 writtenBndsLon.resize(nvertex, nbWritten);977 CArray<double,2>& boundslat = domain->bounds_latvalue;978 CArray<double,2>& boundslon = domain->bounds_lonvalue;979 for (idx = 0; idx < nbWritten; ++idx)980 {981 for (int nv = 0; nv < nvertex; ++nv)982 {983 if (indexToWrite(idx) < 0)984 {985 writtenBndsLat(nv, idx) = -1.;986 writtenBndsLon(nv, idx) = -1.;987 }988 else989 {990 writtenBndsLat(nv, idx) = boundslat(nv, int(indexToWrite(idx)));991 writtenBndsLon(nv, idx) = boundslon(nv, int(indexToWrite(idx)));992 }993 }994 }995 }996 997 if (domain->hasArea)998 {999 writtenArea.resize(nbWritten);1000 for (int idx = 0; idx < nbWritten; ++idx)1001 {1002 if (indexToWrite(idx) < 0)1003 writtenArea(idx) = -1.;1004 else1005 writtenArea(idx) = domain->areavalue(indexToWrite(idx));1006 }1007 }1008 831 1009 832 try … … 1055 878 if (domain->hasLonLat) 1056 879 { 1057 SuperClassWriter::writeData( writtenLat, latid, isCollective, 0);1058 SuperClassWriter::writeData( writtenLon, lonid, isCollective, 0);880 SuperClassWriter::writeData(domain->latvalue, latid, isCollective, 0); 881 SuperClassWriter::writeData(domain->lonvalue, lonid, isCollective, 0); 1059 882 if (domain->hasBounds) 1060 883 { 1061 SuperClassWriter::writeData( writtenBndsLon, bounds_lonid, isCollective, 0);1062 SuperClassWriter::writeData( writtenBndsLat, bounds_latid, isCollective, 0);884 SuperClassWriter::writeData(domain->bounds_lonvalue, bounds_lonid, isCollective, 0); 885 SuperClassWriter::writeData(domain->bounds_latvalue, bounds_latid, isCollective, 0); 1063 886 } 1064 887 } 1065 888 1066 889 if (domain->hasArea) 1067 SuperClassWriter::writeData( writtenArea, areaId, isCollective, 0);890 SuperClassWriter::writeData(domain->areavalue, areaId, isCollective, 0); 1068 891 1069 892 SuperClassWriter::definition_start(); … … 1137 960 if (domain->hasLonLat) 1138 961 { 1139 SuperClassWriter::writeData( writtenLat, latid, isCollective, 0,&start,&count);1140 SuperClassWriter::writeData( writtenLon, lonid, isCollective, 0,&start,&count);962 SuperClassWriter::writeData(domain->latvalue, latid, isCollective, 0,&start,&count); 963 SuperClassWriter::writeData(domain->lonvalue, lonid, isCollective, 0,&start,&count); 1141 964 if (domain->hasBounds) 1142 965 { 1143 SuperClassWriter::writeData( writtenBndsLon, bounds_lonid, isCollective, 0,&startBounds,&countBounds);1144 SuperClassWriter::writeData( writtenBndsLat, bounds_latid, isCollective, 0,&startBounds,&countBounds);966 SuperClassWriter::writeData(domain->bounds_lonvalue, bounds_lonid, isCollective, 0,&startBounds,&countBounds); 967 SuperClassWriter::writeData(domain->bounds_latvalue, bounds_latid, isCollective, 0,&startBounds,&countBounds); 1145 968 } 1146 969 } 1147 970 1148 971 if (domain->hasArea) 1149 SuperClassWriter::writeData( writtenArea, areaId, isCollective, 0, &start, &count);972 SuperClassWriter::writeData(domain->areavalue, areaId, isCollective, 0, &start, &count); 1150 973 1151 974 SuperClassWriter::definition_start(); … … 1177 1000 axis->checkAttributes(); 1178 1001 1179 axis->computeWrittenIndex();1180 axis->computeWrittenCompressedIndex(comm_file);1181 1182 1002 int size = (MULTI_FILE == SuperClass::type) ? axis->n.getValue() 1183 1003 : axis->n_glo.getValue(); … … 1279 1099 1280 1100 SuperClassWriter::definition_end(); 1281 1282 CArray<int, 1>& indexToWrite = axis->localIndexToWriteOnServer; 1283 int nbWritten = indexToWrite.numElements(); 1284 CArray<double,1> axis_value(indexToWrite.numElements()); 1285 if (!axis->value.isEmpty()) 1286 { 1287 for (int i = 0; i < nbWritten; i++) 1288 { 1289 if (indexToWrite(i) < 0) 1290 axis_value(i) = -1; // Some value in case of a hole 1291 else 1292 axis_value(i) = axis->value(indexToWrite(i)); 1293 } 1294 } 1295 CArray<double,2> axis_bounds; 1296 CArray<string,1> axis_label; 1297 if (!axis->label.isEmpty()) 1298 { 1299 axis_label.resize(indexToWrite.numElements()); 1300 for (int i = 0; i < nbWritten; i++) 1301 { 1302 if (indexToWrite(i) < 0) 1303 axis_label(i) = boost::lexical_cast<string>(-1); // Some value in case of a hole 1304 else 1305 axis_label(i) = axis->label(indexToWrite(i)); 1306 } 1307 } 1308 1101 1309 1102 switch (SuperClass::type) 1310 1103 { … … 1314 1107 { 1315 1108 if (!axis->value.isEmpty()) 1316 SuperClassWriter::writeData(axis _value, axisid, isCollective, 0);1109 SuperClassWriter::writeData(axis->value, axisid, isCollective, 0); 1317 1110 1318 1111 if (!axis->bounds.isEmpty()) 1319 { 1320 axis_bounds.resize(2, indexToWrite.numElements()); 1321 for (int i = 0; i < nbWritten; ++i) 1322 { 1323 if (indexToWrite(i) < 0) 1324 { 1325 axis_bounds(0, i) = -1.; // Some value in case of a hole 1326 axis_bounds(1, i) = -1.; 1327 } 1328 else 1329 { 1330 axis_bounds(0, i) = axis->bounds(0, int(indexToWrite(i))); 1331 axis_bounds(1, i) = axis->bounds(1, int(indexToWrite(i))); 1332 } 1333 } 1334 SuperClassWriter::writeData(axis_bounds, axisBoundsId, isCollective, 0); 1335 } 1112 SuperClassWriter::writeData(axis->bounds, axisBoundsId, isCollective, 0); 1336 1113 } 1337 1114 else 1338 SuperClassWriter::writeData(axis _label, axisid, isCollective, 0);1115 SuperClassWriter::writeData(axis->label, axisid, isCollective, 0); 1339 1116 1340 1117 SuperClassWriter::definition_start(); … … 1353 1130 { 1354 1131 if (!axis->value.isEmpty()) 1355 SuperClassWriter::writeData(axis _value, axisid, isCollective, 0, &start, &count);1132 SuperClassWriter::writeData(axis->value, axisid, isCollective, 0, &start, &count); 1356 1133 1357 1134 if (!axis->bounds.isEmpty()) 1358 { 1359 axis_bounds.resize(2, indexToWrite.numElements()); 1360 for (int i = 0; i < nbWritten; ++i) 1361 { 1362 if (indexToWrite(i) < 0) 1363 { 1364 axis_bounds(0, i) = -1.; 1365 axis_bounds(1, i) = -1.; 1366 } 1367 else 1368 { 1369 axis_bounds(0, i) = axis->bounds(0, int(indexToWrite(i))); 1370 axis_bounds(1, i) = axis->bounds(1, int(indexToWrite(i))); 1371 } 1372 } 1373 SuperClassWriter::writeData(axis_bounds, axisBoundsId, isCollective, 0, &startBounds, &countBounds); 1374 } 1135 SuperClassWriter::writeData(axis->bounds, axisBoundsId, isCollective, 0, &startBounds, &countBounds); 1375 1136 } 1376 1137 else … … 1379 1140 startLabel[0] = start[0]; startLabel[1] = 0; 1380 1141 countLabel[0] = count[0]; countLabel[1] = stringArrayLen; 1381 SuperClassWriter::writeData(axis _label, axisid, isCollective, 0, &startLabel, &countLabel);1142 SuperClassWriter::writeData(axis->label, axisid, isCollective, 0, &startLabel, &countLabel); 1382 1143 } 1383 1144 … … 1574 1335 void CNc4DataOutput::writeGridCompressed_(CGrid* grid) 1575 1336 { 1576 if (grid->isScalarGrid() || grid->isWrittenCompressed(this->filename)) return; 1577 1578 try 1579 { 1580 CArray<int,1> axisDomainOrder = grid->axis_domain_order; 1581 std::vector<StdString> domainList = grid->getDomainList(); 1582 std::vector<StdString> axisList = grid->getAxisList(); 1583 std::vector<StdString> scalarList = grid->getScalarList(); 1584 int numElement = axisDomainOrder.numElements(), idxDomain = 0, idxAxis = 0, idxScalar = 0; 1585 1586 std::vector<StdString> dims; 1587 1588 if (grid->isCompressible()) 1589 { 1590 StdString varId = grid->getId() + "_points"; 1591 1592 int nbIndexes = (SuperClass::type == MULTI_FILE) ? grid->getNumberWrittenIndexes() : grid->getTotalNumberWrittenIndexes(); 1593 SuperClassWriter::addDimension(varId, nbIndexes); 1594 1595 dims.push_back(varId); 1596 SuperClassWriter::addVariable(varId, NC_INT, dims); 1597 1598 StdOStringStream compress; 1599 for (int i = numElement - 1; i >= 0; --i) 1600 { 1601 if (2 == axisDomainOrder(i)) 1602 { 1603 CDomain* domain = CDomain::get(domainList[domainList.size() - idxDomain - 1]); 1604 StdString domId = domain->getDomainOutputName(); 1605 StdString appendDomId = singleDomain ? "" : "_" + domId; 1606 1607 switch (domain->type) 1608 { 1609 case CDomain::type_attr::curvilinear: 1610 compress << "y" << appendDomId << " x" << appendDomId; 1611 break; 1612 case CDomain::type_attr::rectilinear: 1613 compress << "lat" << appendDomId << " lon" << appendDomId; 1614 break; 1615 case CDomain::type_attr::unstructured: 1616 StdString cellName = (!domain->dim_i_name.isEmpty()) ? cellName=domain->dim_i_name : "cell"; 1617 compress << cellName << appendDomId; 1618 // compress << "cell" << appendDomId; 1619 break; 1620 } 1621 ++idxDomain; 1622 } 1623 else if (1 == axisDomainOrder(i)) 1624 { 1625 CAxis* axis = CAxis::get(axisList[axisList.size() - idxAxis - 1]); 1626 compress << axis->getAxisOutputName(); 1627 ++idxAxis; 1628 } 1629 else 1630 { 1631 CScalar* scalar = CScalar::get(scalarList[scalarList.size() - idxScalar - 1]); 1632 compress << scalar->getScalarOutputName(); 1633 ++idxScalar; 1634 } 1635 1636 if (i != 0) compress << ' '; 1637 } 1638 SuperClassWriter::addAttribute("compress", compress.str(), &varId); 1639 1640 CArray<int, 1> indexes(grid->getNumberWrittenIndexes()); 1641 indexes = grid->localIndexToWriteOnServer; 1642 1643 switch (SuperClass::type) 1644 { 1645 case (MULTI_FILE): 1646 { 1647 SuperClassWriter::writeData(indexes, varId, isCollective, 0); 1648 break; 1649 } 1650 case (ONE_FILE): 1651 { 1652 if (grid->doGridHaveDataDistributed()) 1653 grid->getDistributionServer()->computeGlobalIndex(indexes); 1654 1655 std::vector<StdSize> start, count; 1656 start.push_back(grid->getOffsetWrittenIndexes()); 1657 count.push_back(grid->getNumberWrittenIndexes()); 1658 1659 SuperClassWriter::writeData(indexes, varId, isCollective, 0, &start, &count); 1660 break; 1661 } 1662 } 1663 } 1664 else 1665 { 1666 for (int i = 0; i < numElement; ++i) 1667 { 1668 StdString varId, compress; 1669 CArray<int, 1> indexes; 1670 bool isDistributed; 1671 StdSize nbIndexes, totalNbIndexes, offset; 1672 int firstGlobalIndex; 1673 1674 if (2 == axisDomainOrder(i)) 1675 { 1676 CDomain* domain = CDomain::get(domainList[idxDomain]); 1677 StdString domId = domain->getDomainOutputName(); 1678 1679 if (!domain->isCompressible() 1680 || domain->type == CDomain::type_attr::unstructured 1681 || domain->isWrittenCompressed(this->filename) 1682 || isWrittenCompressedDomain(domId)) 1683 continue; 1684 1685 StdString appendDomId = singleDomain ? "" : "_" + domId; 1686 1687 varId = domId + "_points"; 1688 switch (domain->type) 1689 { 1690 case CDomain::type_attr::curvilinear: 1691 compress = "y" + appendDomId + " x" + appendDomId; 1692 break; 1693 case CDomain::type_attr::rectilinear: 1694 compress = "lat" + appendDomId + " lon" + appendDomId; 1695 break; 1696 } 1697 1698 // indexes.resize(domain->compressedIndexToWriteOnServer[comm_file].numElements()); 1699 // indexes = domain->compressedIndexToWriteOnServer[com_file]; 1700 indexes.resize(domain->getCompressedIndexToWriteOnServer(comm_file).numElements()); 1701 indexes = domain->getCompressedIndexToWriteOnServer(comm_file); 1702 1703 isDistributed = domain->isDistributed(); 1704 nbIndexes = domain->getNumberWrittenIndexes(comm_file); 1705 totalNbIndexes = domain->getTotalNumberWrittenIndexes(comm_file); 1706 offset = domain->getOffsetWrittenIndexes(comm_file); 1707 firstGlobalIndex = domain->ibegin + domain->jbegin * domain->ni_glo; 1708 1709 domain->addRelFileCompressed(this->filename); 1710 setWrittenCompressedDomain(domId); 1711 ++idxDomain; 1712 } 1713 else if (1 == axisDomainOrder(i)) 1714 { 1715 CAxis* axis = CAxis::get(axisList[idxAxis]); 1716 StdString axisId = axis->getAxisOutputName(); 1717 1718 if (!axis->isCompressible() 1719 || axis->isWrittenCompressed(this->filename) 1720 || isWrittenCompressedAxis(axisId)) 1721 continue; 1722 1723 varId = axisId + "_points"; 1724 compress = axisId; 1725 1726 // indexes.resize(axis->compressedIndexToWriteOnServer.numElements()); 1727 // indexes = axis->compressedIndexToWriteOnServer; 1728 1729 indexes.resize(axis->getCompressedIndexToWriteOnServer(comm_file).numElements()); 1730 indexes = axis->getCompressedIndexToWriteOnServer(comm_file); 1731 1732 isDistributed = axis->isDistributed(); 1733 nbIndexes = axis->getNumberWrittenIndexes(comm_file); 1734 totalNbIndexes = axis->getTotalNumberWrittenIndexes(comm_file); 1735 offset = axis->getOffsetWrittenIndexes(comm_file); 1736 firstGlobalIndex = axis->begin; 1737 1738 axis->addRelFileCompressed(this->filename); 1739 setWrittenCompressedAxis(axisId); 1740 ++idxAxis; 1741 } 1742 else 1743 { 1744 } 1745 1746 if (!varId.empty()) 1747 { 1748 SuperClassWriter::addDimension(varId, (SuperClass::type == MULTI_FILE) ? nbIndexes : totalNbIndexes); 1749 1750 dims.clear(); 1751 dims.push_back(varId); 1752 SuperClassWriter::addVariable(varId, NC_INT, dims); 1753 1754 SuperClassWriter::addAttribute("compress", compress, &varId); 1755 1756 switch (SuperClass::type) 1757 { 1758 case (MULTI_FILE): 1759 { 1760 indexes -= firstGlobalIndex; 1761 SuperClassWriter::writeData(indexes, varId, isCollective, 0); 1762 break; 1763 } 1764 case (ONE_FILE): 1765 { 1766 std::vector<StdSize> start, count; 1767 start.push_back(offset); 1768 count.push_back(nbIndexes); 1769 1770 SuperClassWriter::writeData(indexes, varId, isCollective, 0, &start, &count); 1771 break; 1772 } 1773 } 1774 } 1337 if (grid->isScalarGrid() || grid->isWrittenCompressed(this->filename)) return; 1338 1339 // NOTA : The cuurent algorithm to write compress elements of the grid 1340 // will work pretting well when on server side you dont't get 1341 // partial overlap on elements between differents participating process 1342 // So the element must be totally distributed or non distributed 1343 // If an element is partially overlaping betwwen process then the 1344 // total compressed part will apear artificially greater than expected 1345 // For the current implementation of writer which is decomposed only on 1346 // one element, it will work as expected, but for future, it must be 1347 // reconsidered again. 1348 try 1349 { 1350 CArray<int,1> axisDomainOrder = grid->axis_domain_order; 1351 std::vector<StdString> domainList = grid->getDomainList(); 1352 std::vector<StdString> axisList = grid->getAxisList(); 1353 std::vector<StdString> scalarList = grid->getScalarList(); 1354 int numElement = axisDomainOrder.numElements(), idxDomain = 0, idxAxis = 0, idxScalar = 0; 1355 int commRank ; 1356 MPI_Comm_rank(comm_file,&commRank) ; 1357 1358 std::vector<StdString> dims; 1359 1360 for (int i = 0; i < numElement; ++i) 1361 { 1362 StdString varId, compress; 1363 CArray<size_t, 1> indexes; 1364 bool isDistributed; 1365 size_t nbIndexes, totalNbIndexes, offset; 1366 size_t firstGlobalIndex; 1367 1368 if (2 == axisDomainOrder(i)) 1369 { 1370 CDomain* domain = CDomain::get(domainList[idxDomain]); 1371 StdString domId = domain->getDomainOutputName(); 1372 1373 if (!domain->isCompressible() 1374 || domain->type == CDomain::type_attr::unstructured 1375 || domain->isWrittenCompressed(this->filename) 1376 || isWrittenCompressedDomain(domId)) 1377 continue; 1378 1379 // unstructured grid seems not be taken into account why ? 1380 1381 string lonName,latName ; 1382 1383 if (domain->lon_name.isEmpty()) 1384 { 1385 if (domain->type==CDomain::type_attr::curvilinear) lonName = "nav_lon"; 1386 else lonName = "lon"; 1387 } 1388 else lonName = domain->lon_name; 1389 1390 if (domain->lat_name.isEmpty()) 1391 { 1392 if (domain->type==CDomain::type_attr::curvilinear) latName = "nav_lat"; 1393 else latName = "lat"; 1394 } 1395 else latName = domain->lat_name; 1396 1397 StdString appendDomId = singleDomain ? "" : "_" + domId; 1398 1399 varId = domId + "_points"; 1400 compress = latName + appendDomId + " " + lonName + appendDomId; 1401 1402 CLocalView* workflowView = domain->getLocalView(CElementView::WORKFLOW) ; 1403 workflowView->getGlobalIndexView(indexes) ; 1404 nbIndexes = workflowView->getSize() ; 1405 isDistributed = domain->isDistributed(); 1406 if (isDistributed) 1407 { 1408 MPI_Exscan(&nbIndexes, &offset, 1, MPI_SIZE_T, MPI_SUM, comm_file) ; 1409 if (commRank==0) offset=0 ; 1410 MPI_Allreduce(&nbIndexes,&totalNbIndexes,1 , MPI_SIZE_T, MPI_SUM, comm_file) ; 1411 } 1412 else 1413 { 1414 offset=0 ; 1415 totalNbIndexes = nbIndexes ; 1416 } 1417 1418 firstGlobalIndex = domain->ibegin + domain->jbegin * domain->ni_glo; 1419 1420 domain->addRelFileCompressed(this->filename); 1421 setWrittenCompressedDomain(domId); 1422 ++idxDomain; 1775 1423 } 1776 } 1777 1778 grid->addRelFileCompressed(this->filename); 1779 } 1780 catch (CNetCdfException& e) 1781 { 1782 StdString msg("On writing compressed grid : "); 1783 msg.append(grid->getId()); msg.append("\n"); 1784 msg.append("In the context : "); 1785 CContext* context = CContext::getCurrent(); 1786 msg.append(context->getId()); msg.append("\n"); 1787 msg.append(e.what()); 1788 ERROR("CNc4DataOutput::writeGridCompressed_(CGrid* grid)", << msg); 1789 } 1790 } 1424 else if (1 == axisDomainOrder(i)) 1425 { 1426 CAxis* axis = CAxis::get(axisList[idxAxis]); 1427 StdString axisId = axis->getAxisOutputName(); 1428 1429 if (!axis->isCompressible() 1430 || axis->isWrittenCompressed(this->filename) 1431 || isWrittenCompressedAxis(axisId)) 1432 continue; 1433 1434 varId = axisId + "_points"; 1435 compress = axisId; 1436 1437 CLocalView* workflowView = axis->getLocalView(CElementView::WORKFLOW) ; 1438 workflowView->getGlobalIndexView(indexes) ; 1439 nbIndexes = workflowView->getSize() ; 1440 isDistributed = axis->isDistributed(); 1441 if (isDistributed) 1442 { 1443 MPI_Exscan(&nbIndexes, &offset, 1, MPI_SIZE_T, MPI_SUM, comm_file) ; 1444 if (commRank==0) offset=0 ; 1445 MPI_Allreduce(&nbIndexes,&totalNbIndexes,1 , MPI_SIZE_T, MPI_SUM, comm_file) ; 1446 } 1447 else 1448 { 1449 offset=0 ; 1450 totalNbIndexes = nbIndexes ; 1451 } 1452 firstGlobalIndex = axis->begin; 1453 1454 axis->addRelFileCompressed(this->filename); 1455 setWrittenCompressedAxis(axisId); 1456 ++idxAxis; 1457 } 1458 else 1459 { 1460 //for scalar 1461 } 1462 1463 if (!varId.empty()) 1464 { 1465 SuperClassWriter::addDimension(varId, (SuperClass::type == MULTI_FILE) ? nbIndexes : totalNbIndexes); 1466 1467 dims.clear(); 1468 dims.push_back(varId); 1469 SuperClassWriter::addVariable(varId, NC_UINT64, dims); 1470 1471 SuperClassWriter::addAttribute("compress", compress, &varId); 1472 1473 switch (SuperClass::type) 1474 { 1475 case (MULTI_FILE): 1476 { 1477 indexes -= firstGlobalIndex; 1478 SuperClassWriter::writeData(indexes, varId, isCollective, 0); 1479 break; 1480 } 1481 case (ONE_FILE): 1482 { 1483 std::vector<StdSize> start, count; 1484 start.push_back(offset); 1485 count.push_back(nbIndexes); 1486 1487 SuperClassWriter::writeData(indexes, varId, isCollective, 0, &start, &count); 1488 break; 1489 } 1490 } 1491 } 1492 } 1493 1494 grid->addRelFileCompressed(this->filename); 1495 } 1496 catch (CNetCdfException& e) 1497 { 1498 StdString msg("On writing compressed grid : "); 1499 msg.append(grid->getId()); msg.append("\n"); 1500 msg.append("In the context : "); 1501 CContext* context = CContext::getCurrent(); 1502 msg.append(context->getId()); msg.append("\n"); 1503 msg.append(e.what()); 1504 ERROR("CNc4DataOutput::writeGridCompressed_(CGrid* grid)", << msg); 1505 } 1506 } 1791 1507 1792 1508 //-------------------------------------------------------------- … … 1814 1530 { 1815 1531 CContext* context = CContext::getCurrent() ; 1816 CContextServer* server=context->server ;1817 1532 1818 1533 std::vector<StdString> dims, coodinates; 1819 CGrid* grid = field->g rid;1534 CGrid* grid = field->getGrid(); 1820 1535 if (!grid->doGridHaveDataToWrite()) 1821 1536 if (SuperClass::type==MULTI_FILE) return ; … … 1998 1713 } 1999 1714 2000 if (compressedOutput && grid->isCompressible())1715 while (!dimIdList.empty()) 2001 1716 { 2002 dims.push_back(grid->getId() + "_points"); 2003 field->setUseCompressedOutput(); 2004 } 2005 else 2006 { 2007 while (!dimIdList.empty()) 2008 { 2009 dims.push_back(dimIdList.back()); 2010 dimIdList.pop_back(); 2011 } 1717 dims.push_back(dimIdList.back()); 1718 dimIdList.pop_back(); 2012 1719 } 2013 1720 … … 2156 1863 2157 1864 if (field->compression_level.isEmpty()) 2158 field->compression_level = field-> file->compression_level.isEmpty() ? 0 : field->file->compression_level;1865 field->compression_level = field->getRelFile()->compression_level.isEmpty() ? 0 : field->getRelFile()->compression_level; 2159 1866 SuperClassWriter::setCompressionLevel(fieldid, field->compression_level); 2160 1867 … … 2355 2062 //--------------------------------------------------------------- 2356 2063 2357 void CNc4DataOutput::writeFieldData_ (CField* field) 2064 int CNc4DataOutput::writeFieldData_ (CField* field, const CArray<double,1>& data, const CDate& lastWrite, 2065 const CDate& currentWrite, int nstep) 2358 2066 { 2359 2067 CContext* context = CContext::getCurrent(); 2360 CContextServer* server = context->server; 2361 CGrid* grid = field->grid; 2362 2363 if (field->getNStep()<1) 2068 CGrid* grid = field->getGrid(); 2069 2070 if (nstep<1) 2364 2071 { 2365 return ;2072 return nstep; 2366 2073 } 2367 2074 … … 2369 2076 if (SuperClass::type == MULTI_FILE || !isCollective) 2370 2077 { 2371 return ;2078 return nstep; 2372 2079 } 2373 2080 … … 2387 2094 if (!field->wasWritten()) 2388 2095 { 2389 if (appendMode && field-> file->record_offset.isEmpty() &&2096 if (appendMode && field->getRelFile()->record_offset.isEmpty() && 2390 2097 field->getOperationTimeType() != func::CFunctor::once) 2391 2098 { 2392 2099 double factorUnit; 2393 if (!field-> file->time_units.isEmpty() && field->file->time_units==CFile::time_units_attr::days)2100 if (!field->getRelFile()->time_units.isEmpty() && field->getRelFile()->time_units==CFile::time_units_attr::days) 2394 2101 factorUnit=context->getCalendar()->getDayLengthInSeconds() ; 2395 2102 else factorUnit=1 ; 2396 field->resetNStep(getRecordFromTime(field->last_Write_srv,factorUnit) + 1);2103 nstep = getRecordFromTime(currentWrite,factorUnit) + 1; 2397 2104 } 2398 2105 … … 2413 2120 if (wtime) 2414 2121 { 2415 Time lastWrite = field->last_Write_srv;2416 Time lastLastWrite = field->lastlast_Write_srv;2417 2418 2122 2419 2123 if (field->hasTimeInstant) 2420 2124 { 2421 time_data(0) = time_data_bound(1) = lastWrite;2422 time_data_bound(0) = time_data_bound(1) = lastWrite;2125 time_data(0) = time_data_bound(1) = (Time) lastWrite; 2126 time_data_bound(0) = time_data_bound(1) = (Time) currentWrite; 2423 2127 if (timeCounterType==instant) 2424 2128 { … … 2432 2136 else if (field->hasTimeCentered) 2433 2137 { 2434 time_data(0) = ( lastWrite + lastLastWrite) / 2;2435 time_data_bound(0) = lastLastWrite;2436 time_data_bound(1) = lastWrite;2138 time_data(0) = ((Time)currentWrite + (Time)lastWrite) / 2; 2139 time_data_bound(0) = (Time)lastWrite; 2140 time_data_bound(1) = (Time)currentWrite; 2437 2141 if (timeCounterType==centered) 2438 2142 { … … 2447 2151 if (timeCounterType==record) 2448 2152 { 2449 time_counter(0) = field->getNStep()- 1;2450 time_counter_bound(0) = time_counter_bound(1) = field->getNStep()- 1;2153 time_counter(0) = nstep - 1; 2154 time_counter_bound(0) = time_counter_bound(1) = nstep - 1; 2451 2155 wtimeCounter=true ; 2452 2156 } 2453 2157 2454 if (!field-> file->time_units.isEmpty() && field->file->time_units==CFile::time_units_attr::days)2158 if (!field->getRelFile()->time_units.isEmpty() && field->getRelFile()->time_units==CFile::time_units_attr::days) 2455 2159 { 2456 2160 double secByDay=context->getCalendar()->getDayLengthInSeconds() ; … … 2462 2166 } 2463 2167 2464 bool isRoot = (server->intraCommRank == 0); 2465 2466 if (!field->scale_factor.isEmpty() || !field->add_offset.isEmpty()) 2467 { 2468 double scaleFactor = 1.0; 2469 double addOffset = 0.0; 2470 if (!field->scale_factor.isEmpty()) scaleFactor = field->scale_factor; 2471 if (!field->add_offset.isEmpty()) addOffset = field->add_offset; 2472 field->scaleFactorAddOffset(scaleFactor, addOffset); 2473 } 2168 bool isRoot = (context->intraCommRank_ == 0); 2474 2169 2475 2170 try 2476 2171 { 2477 size_t writtenSize;2478 if (field->getUseCompressedOutput())2479 writtenSize = grid->getNumberWrittenIndexes();2480 else2481 writtenSize = grid->getWrittenDataSize();2482 2483 CArray<double,1> fieldData(writtenSize);2484 if (!field->default_value.isEmpty()) fieldData = field->default_value;2485 2486 if (field->getUseCompressedOutput())2487 field->outputCompressedField(fieldData);2488 else2489 field->outputField(fieldData);2490 2491 if (!field->prec.isEmpty() && field->prec == 2) fieldData = round(fieldData);2492 2493 2172 switch (SuperClass::type) 2494 2173 { … … 2496 2175 { 2497 2176 CTimer::get("Files : writing data").resume(); 2498 SuperClassWriter::writeData( fieldData, fieldid, isCollective, field->getNStep()- 1);2177 SuperClassWriter::writeData(data, fieldid, isCollective, nstep - 1); 2499 2178 CTimer::get("Files : writing data").suspend(); 2500 2179 if (wtime) … … 2503 2182 if ( wtimeData) 2504 2183 { 2505 SuperClassWriter::writeTimeAxisData(time_data, timeAxisId, isCollective, field->getNStep()- 1, isRoot);2506 SuperClassWriter::writeTimeAxisDataBounds(time_data_bound, timeAxisBoundId, isCollective, field->getNStep()- 1, isRoot);2184 SuperClassWriter::writeTimeAxisData(time_data, timeAxisId, isCollective, nstep - 1, isRoot); 2185 SuperClassWriter::writeTimeAxisDataBounds(time_data_bound, timeAxisBoundId, isCollective, nstep - 1, isRoot); 2507 2186 } 2508 2187 if (wtimeCounter) 2509 2188 { 2510 SuperClassWriter::writeTimeAxisData(time_counter, getTimeCounterName(), isCollective, field->getNStep()- 1,isRoot);2511 if (timeCounterType!=record) SuperClassWriter::writeTimeAxisDataBounds(time_counter_bound, timeBoundId, isCollective, field->getNStep()- 1, isRoot);2189 SuperClassWriter::writeTimeAxisData(time_counter, getTimeCounterName(), isCollective, nstep - 1,isRoot); 2190 if (timeCounterType!=record) SuperClassWriter::writeTimeAxisDataBounds(time_counter_bound, timeBoundId, isCollective, nstep - 1, isRoot); 2512 2191 } 2513 2192 CTimer::get("Files : writing time axis").suspend(); … … 2522 2201 if (field->getUseCompressedOutput()) 2523 2202 { 2524 if (grid->isCompressible()) 2203 CArray<int,1> axisDomainOrder = grid->axis_domain_order; 2204 std::vector<StdString> domainList = grid->getDomainList(); 2205 std::vector<StdString> axisList = grid->getAxisList(); 2206 int numElement = axisDomainOrder.numElements(); 2207 int idxDomain = domainList.size() - 1, idxAxis = axisList.size() - 1; 2208 int idx = domainList.size() * 2 + axisList.size() - 1; 2209 int commRank ; 2210 2211 MPI_Comm_rank(comm_file,&commRank) ; 2212 2213 start.reserve(idx+1); 2214 count.reserve(idx+1); 2215 2216 for (int i = numElement - 1; i >= 0; --i) 2525 2217 { 2526 start.push_back(grid->getOffsetWrittenIndexes()); 2527 count.push_back(grid->getNumberWrittenIndexes()); 2528 } 2529 else 2530 { 2531 CArray<int,1> axisDomainOrder = grid->axis_domain_order; 2532 std::vector<StdString> domainList = grid->getDomainList(); 2533 std::vector<StdString> axisList = grid->getAxisList(); 2534 int numElement = axisDomainOrder.numElements(); 2535 int idxDomain = domainList.size() - 1, idxAxis = axisList.size() - 1; 2536 int idx = domainList.size() * 2 + axisList.size() - 1; 2537 2538 start.reserve(idx+1); 2539 count.reserve(idx+1); 2540 2541 for (int i = numElement - 1; i >= 0; --i) 2218 if (2 == axisDomainOrder(i)) 2542 2219 { 2543 if (2 == axisDomainOrder(i)) 2220 CDomain* domain = CDomain::get(domainList[idxDomain]); 2221 2222 if (domain->isCompressible()) 2544 2223 { 2545 CDomain* domain = CDomain::get(domainList[idxDomain]);2546 2547 if (domain->is Compressible())2224 size_t offset ; 2225 size_t nbIndexes = domain->getLocalView(CElementView::WORKFLOW)->getSize() ; 2226 if (domain->isDistributed()) 2548 2227 { 2549 start.push_back(domain->getOffsetWrittenIndexes(comm_file)); 2550 count.push_back(domain->getNumberWrittenIndexes(comm_file)); 2551 idx -= 2; 2228 MPI_Exscan(&nbIndexes, &offset, 1, MPI_SIZE_T, MPI_SUM, comm_file) ; 2229 if (commRank==0) offset=0 ; 2552 2230 } 2553 else 2231 else offset=0 ; 2232 2233 start.push_back(offset); 2234 count.push_back(nbIndexes); 2235 idx -= 2; 2236 } 2237 else 2238 { 2239 if ((domain->type) != CDomain::type_attr::unstructured) 2554 2240 { 2555 if ((domain->type) != CDomain::type_attr::unstructured) 2556 { 2557 start.push_back(domain->jbegin); 2558 count.push_back(domain->nj); 2559 } 2560 --idx; 2561 start.push_back(domain->ibegin); 2562 count.push_back(domain->ni); 2563 --idx; 2241 start.push_back(domain->jbegin); 2242 count.push_back(domain->nj); 2564 2243 } 2565 --idxDomain; 2566 } 2567 else if (1 == axisDomainOrder(i)) 2568 { 2569 CAxis* axis = CAxis::get(axisList[idxAxis]); 2570 2571 if (axis->isCompressible()) 2572 { 2573 start.push_back(axis->getOffsetWrittenIndexes(comm_file)); 2574 count.push_back(axis->getNumberWrittenIndexes(comm_file)); 2575 } 2576 else 2577 { 2578 start.push_back(axis->begin); 2579 count.push_back(axis->n); 2580 } 2581 --idxAxis; 2244 --idx; 2245 start.push_back(domain->ibegin); 2246 count.push_back(domain->ni); 2582 2247 --idx; 2583 2248 } 2249 --idxDomain; 2250 } 2251 else if (1 == axisDomainOrder(i)) 2252 { 2253 CAxis* axis = CAxis::get(axisList[idxAxis]); 2254 2255 if (axis->isCompressible()) 2256 { 2257 size_t offset ; 2258 size_t nbIndexes = axis->getLocalView(CElementView::WORKFLOW)->getSize() ; 2259 if (axis->isDistributed()) 2260 { 2261 MPI_Exscan(&nbIndexes, &offset, 1, MPI_SIZE_T, MPI_SUM, comm_file) ; 2262 if (commRank==0) offset=0 ; 2263 } 2264 else offset=0 ; 2265 2266 start.push_back(offset); 2267 count.push_back(nbIndexes); 2268 } 2269 else 2270 { 2271 start.push_back(axis->begin); 2272 count.push_back(axis->n); 2273 } 2274 --idxAxis; 2275 --idx; 2584 2276 } 2585 2277 } … … 2636 2328 2637 2329 CTimer::get("Files : writing data").resume(); 2638 SuperClassWriter::writeData( fieldData, fieldid, isCollective, field->getNStep()- 1, &start, &count);2330 SuperClassWriter::writeData(data, fieldid, isCollective, nstep - 1, &start, &count); 2639 2331 CTimer::get("Files : writing data").suspend(); 2640 2332 … … 2644 2336 if ( wtimeData) 2645 2337 { 2646 SuperClassWriter::writeTimeAxisData(time_data, timeAxisId, isCollective, field->getNStep()- 1, isRoot);2647 SuperClassWriter::writeTimeAxisDataBounds(time_data_bound, timeAxisBoundId, isCollective, field->getNStep()- 1, isRoot);2338 SuperClassWriter::writeTimeAxisData(time_data, timeAxisId, isCollective, nstep - 1, isRoot); 2339 SuperClassWriter::writeTimeAxisDataBounds(time_data_bound, timeAxisBoundId, isCollective, nstep - 1, isRoot); 2648 2340 } 2649 2341 if (wtimeCounter) 2650 2342 { 2651 SuperClassWriter::writeTimeAxisData(time_counter, getTimeCounterName(), isCollective, field->getNStep()- 1,isRoot);2652 if (timeCounterType!=record) SuperClassWriter::writeTimeAxisDataBounds(time_counter_bound, timeBoundId, isCollective, field->getNStep()- 1, isRoot);2343 SuperClassWriter::writeTimeAxisData(time_counter, getTimeCounterName(), isCollective, nstep - 1,isRoot); 2344 if (timeCounterType!=record) SuperClassWriter::writeTimeAxisDataBounds(time_counter_bound, timeBoundId, isCollective, nstep - 1, isRoot); 2653 2345 2654 2346 } … … 2659 2351 } 2660 2352 } 2353 return nstep ; 2661 2354 } 2662 2355 catch (CNetCdfException& e) … … 2691 2384 2692 2385 StdString strTimeUnits ; 2693 if (!field-> file->time_units.isEmpty() && field->file->time_units==CFile::time_units_attr::days) strTimeUnits="days since " ;2386 if (!field->getRelFile()->time_units.isEmpty() && field->getRelFile()->time_units==CFile::time_units_attr::days) strTimeUnits="days since " ; 2694 2387 else strTimeUnits="seconds since " ; 2695 2388 … … 2698 2391 2699 2392 2700 if (field-> file->time_counter.isEmpty())2393 if (field->getRelFile()->time_counter.isEmpty()) 2701 2394 { 2702 2395 if (timeCounterType==none) createTimeCounterAxis=true ; … … 2712 2405 } 2713 2406 } 2714 else if (field-> file->time_counter==CFile::time_counter_attr::instant)2407 else if (field->getRelFile()->time_counter==CFile::time_counter_attr::instant) 2715 2408 { 2716 2409 if (field->hasTimeCentered) … … 2725 2418 } 2726 2419 } 2727 else if (field-> file->time_counter==CFile::time_counter_attr::centered)2420 else if (field->getRelFile()->time_counter==CFile::time_counter_attr::centered) 2728 2421 { 2729 2422 if (field->hasTimeCentered) … … 2738 2431 } 2739 2432 } 2740 else if (field-> file->time_counter==CFile::time_counter_attr::instant_exclusive)2433 else if (field->getRelFile()->time_counter==CFile::time_counter_attr::instant_exclusive) 2741 2434 { 2742 2435 if (field->hasTimeCentered) … … 2750 2443 } 2751 2444 } 2752 else if (field-> file->time_counter==CFile::time_counter_attr::centered_exclusive)2445 else if (field->getRelFile()->time_counter==CFile::time_counter_attr::centered_exclusive) 2753 2446 { 2754 2447 if (field->hasTimeCentered) … … 2762 2455 } 2763 2456 } 2764 else if (field-> file->time_counter==CFile::time_counter_attr::exclusive)2457 else if (field->getRelFile()->time_counter==CFile::time_counter_attr::exclusive) 2765 2458 { 2766 2459 if (field->hasTimeCentered) … … 2783 2476 } 2784 2477 } 2785 else if (field-> file->time_counter==CFile::time_counter_attr::none)2478 else if (field->getRelFile()->time_counter==CFile::time_counter_attr::none) 2786 2479 { 2787 2480 if (field->hasTimeCentered) … … 2794 2487 } 2795 2488 } 2796 else if (field-> file->time_counter==CFile::time_counter_attr::record)2489 else if (field->getRelFile()->time_counter==CFile::time_counter_attr::record) 2797 2490 { 2798 2491 if (timeCounterType==none) createTimeCounterAxis=true ; … … 2865 2558 SuperClassWriter::addAttribute("axis", string("T"), &axisId); 2866 2559 2867 if (field-> file->time_counter.isEmpty() ||2868 (field-> file->time_counter != CFile::time_counter_attr::record))2560 if (field->getRelFile()->time_counter.isEmpty() || 2561 (field->getRelFile()->time_counter != CFile::time_counter_attr::record)) 2869 2562 { 2870 2563 CDate timeOrigin = cal->getTimeOrigin(); … … 2878 2571 2879 2572 // Adding time_counter_bound dimension 2880 if (field-> file->time_counter.isEmpty() || (field->file->time_counter != CFile::time_counter_attr::record))2573 if (field->getRelFile()->time_counter.isEmpty() || (field->getRelFile()->time_counter != CFile::time_counter_attr::record)) 2881 2574 { 2882 2575 if (!SuperClassWriter::varExist(axisBoundId)) -
XIOS/dev/dev_trunk_graph/src/io/nc4_data_output.hpp
r1542 r2019 56 56 virtual void writeAttribute_(CVariable* var); 57 57 virtual void writeAttribute_(CVariable* var, const string& fieldId); 58 virtual void writeFieldData_(CField* field);58 virtual int writeFieldData_(CField* field, const CArray<double,1>& data, const CDate& lastWrite, const CDate& currentWrite, int nstep); 59 59 virtual void writeFile_ (CFile* file); 60 60 virtual void closeFile_ (void); -
XIOS/dev/dev_trunk_graph/src/io/netCdfInterface.cpp
r1454 r2019 894 894 895 895 template<> 896 int CNetCdfInterface::ncGetAttType(int ncid, int varid, const char* attrName, size_t* data) 897 { 898 return nc_get_att_ulonglong(ncid, varid, attrName, (unsigned long long*)data); 899 } 900 901 template<> 896 902 int CNetCdfInterface::ncGetAttType(int ncid, int varid, const char* attrName, short* data) 897 903 { … … 936 942 template<> 937 943 int CNetCdfInterface::ncPutAttType(int ncid, int varid, const char* attrName, 944 StdSize numVal, const size_t* data) 945 { 946 return nc_put_att_ulonglong(ncid, varid, attrName, NC_UINT64, numVal, (unsigned long long*) data); 947 } 948 949 template<> 950 int CNetCdfInterface::ncPutAttType(int ncid, int varid, const char* attrName, 938 951 StdSize numVal, const short* data) 939 952 { … … 968 981 969 982 template<> 983 int CNetCdfInterface::ncGetVaraType(int ncid, int varid, const StdSize* start, const StdSize* count, size_t* data) 984 { 985 return nc_get_vara_ulonglong(ncid, varid, start, count, (unsigned long long*) data); 986 } 987 988 template<> 970 989 int CNetCdfInterface::ncGetVaraType(int ncid, int varid, const StdSize* start, const StdSize* count, char* data) 971 990 { … … 990 1009 { 991 1010 return nc_put_vara_int(ncid, varid, start, count, data); 1011 } 1012 1013 template<> 1014 int CNetCdfInterface::ncPutVaraType(int ncid, int varid, const StdSize* start, const StdSize* count, const size_t* data) 1015 { 1016 return nc_put_vara_ulonglong(ncid, varid, start, count, (unsigned long long*)data); 992 1017 } 993 1018 -
XIOS/dev/dev_trunk_graph/src/io/netCdfInterface_decl.cpp
r1158 r2019 20 20 macroAtt(float) 21 21 macroAtt(int) 22 macroAtt(size_t) 22 23 macroAtt(long) 23 24 macroAtt(short) … … 33 34 macroPutVar(float) 34 35 macroPutVar(int) 36 macroPutVar(size_t) 35 37 macroPutVar(char) 36 38 … … 41 43 macroType(float, NC_FLOAT) 42 44 macroType(int, NC_INT) 45 macroType(size_t, NC_UINT64) 43 46 macroType(long, NC_LONG) 44 47 macroType(short, NC_SHORT) -
XIOS/dev/dev_trunk_graph/src/io/onetcdf4.cpp
r1456 r2019 538 538 539 539 template <> 540 541 540 void CONetCDF4::writeData_(int grpid, int varid, 542 541 const std::vector<StdSize>& sstart, 543 542 const std::vector<StdSize>& scount, const int* data) 543 { 544 CNetCdfInterface::putVaraType(grpid, varid, &sstart[0], &scount[0], data); 545 } 546 //--------------------------------------------------------------- 547 548 template <> 549 void CONetCDF4::writeData_(int grpid, int varid, 550 const std::vector<StdSize>& sstart, 551 const std::vector<StdSize>& scount, const size_t* data) 544 552 { 545 553 CNetCdfInterface::putVaraType(grpid, varid, &sstart[0], &scount[0], data); -
XIOS/dev/dev_trunk_graph/src/io/onetcdf4_decl.cpp
r1392 r2019 11 11 macro(int, 1) 12 12 macro(int, 2) 13 macro(size_t, 1) 14 macro(size_t, 2) 13 15 macro(double, 1) 14 16 macro(double, 2) -
XIOS/dev/dev_trunk_graph/src/io/onetcdf4_impl.hpp
r1686 r2019 76 76 memset (PtrArrayStr,' ',stringArrayLen*data.numElements()); 77 77 size_t offset=0 ; 78 78 79 79 // pb with iterator with blitz++ string array with recent compiler 80 80 /* … … 90 90 data(i).copy(PtrArrayStr+offset,data(i).size()) ; 91 91 PtrArrayStr[offset+data(i).size()]='\0' ; 92 } 92 } 93 93 CTimer::get("CONetCDF4::writeData writeData_").resume(); 94 94 this->writeData_(grpid, varid, sstart, scount, PtrArrayStr);
Note: See TracChangeset
for help on using the changeset viewer.