Changeset 707 for XIOS/trunk/src/io/nc4_data_output.cpp
- Timestamp:
- 09/24/15 15:55:17 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/src/io/nc4_data_output.cpp
r706 r707 1393 1393 void CNc4DataOutput::writeFieldData_ (CField* field) 1394 1394 { 1395 CContext* context = CContext::getCurrent() ; 1396 // if (field->getRelFile()->isSyncTime()) SuperClassWriter::sync() ; 1397 CContextServer* server=context->server ; 1398 1399 CGrid* grid = field->grid ; 1400 1401 if (!grid->doGridHaveDataToWrite()) 1402 if (SuperClass::type==MULTI_FILE || !isCollective) return ; 1403 1404 StdString fieldid = (!field->name.isEmpty()) 1405 ? field->name.getValue() 1406 : field->getBaseFieldReference()->getId(); 1407 1408 StdOStringStream oss; 1409 string timeAxisId ; 1410 if (field->getOperationTimeType() == func::CFunctor::instant) timeAxisId="time_instant" ; 1411 else if (field->getOperationTimeType() == func::CFunctor::centered) timeAxisId="time_centered" ; 1412 1413 StdString timeBoundId("time_counter_bounds"); 1414 1415 StdString timeAxisBoundId; 1416 if (field->getOperationTimeType() == func::CFunctor::instant) timeAxisBoundId="time_instant_bounds" ; 1417 else if (field->getOperationTimeType() == func::CFunctor::centered) timeAxisBoundId="time_centered_bounds" ; 1418 1419 CArray<double,1> time_data(1) ; 1420 CArray<double,1> time_data_bound(2); 1421 CArray<double,1> time_counter(1) ; 1422 CArray<double,1> time_counter_bound(2); 1423 1424 bool wtime = !(!field->operation.isEmpty() && (field->getOperationTimeType() == func::CFunctor::once)); 1395 CContext* context = CContext::getCurrent(); 1396 CContextServer* server = context->server; 1397 CGrid* grid = field->grid; 1398 1399 if (!grid->doGridHaveDataToWrite()) 1400 if (SuperClass::type == MULTI_FILE || !isCollective) return; 1401 1402 StdString fieldid = !field->name.isEmpty() 1403 ? field->name.getValue() 1404 : field->getBaseFieldReference()->getId(); 1405 1406 StdOStringStream oss; 1407 string timeAxisId; 1408 if (field->getOperationTimeType() == func::CFunctor::instant) timeAxisId = "time_instant"; 1409 else if (field->getOperationTimeType() == func::CFunctor::centered) timeAxisId = "time_centered"; 1410 1411 StdString timeBoundId("time_counter_bounds"); 1412 1413 StdString timeAxisBoundId; 1414 if (field->getOperationTimeType() == func::CFunctor::instant) timeAxisBoundId = "time_instant_bounds"; 1415 else if (field->getOperationTimeType() == func::CFunctor::centered) timeAxisBoundId = "time_centered_bounds"; 1416 1417 if (!field->wasWritten()) 1418 { 1419 if (appendMode) 1420 { 1421 field->resetNStep(getRecordFromTime(field->last_Write_srv) + 1); 1422 } 1423 1424 field->setWritten(); 1425 } 1426 1427 1428 CArray<double,1> time_data(1); 1429 CArray<double,1> time_data_bound(2); 1430 CArray<double,1> time_counter(1); 1431 CArray<double,1> time_counter_bound(2); 1432 1433 bool wtime = (field->getOperationTimeType() != func::CFunctor::once); 1425 1434 1426 1435 if (wtime) … … 1461 1470 } 1462 1471 1463 bool isRoot ; 1464 if (server->intraCommRank==0) isRoot=true ; 1465 else isRoot=false ; 1472 bool isRoot = (server->intraCommRank == 0); 1466 1473 1467 1474 if (!field->scale_factor.isEmpty() || !field->add_offset.isEmpty()) 1468 1475 { 1469 double scaleFactor =1.;1470 double addOffset =0.;1471 if (!field->scale_factor.isEmpty()) scaleFactor =field->scale_factor;1472 if (!field->add_offset.isEmpty()) addOffset =field->add_offset;1473 field->scaleFactorAddOffset(scaleFactor, addOffset);1476 double scaleFactor = 1.0; 1477 double addOffset = 0.0; 1478 if (!field->scale_factor.isEmpty()) scaleFactor = field->scale_factor; 1479 if (!field->add_offset.isEmpty()) addOffset = field->add_offset; 1480 field->scaleFactorAddOffset(scaleFactor, addOffset); 1474 1481 } 1475 1482 … … 1490 1497 field->outputField(fieldData); 1491 1498 1492 if (!field->prec.isEmpty() && field->prec ==2) fieldData=round(fieldData);1499 if (!field->prec.isEmpty() && field->prec == 2) fieldData = round(fieldData); 1493 1500 1494 1501 switch (SuperClass::type) … … 1508 1515 } 1509 1516 } 1510 break 1517 break; 1511 1518 } 1512 1519 case (ONE_FILE) : … … 1971 1978 ///-------------------------------------------------------------- 1972 1979 1980 StdSize CNc4DataOutput::getRecordFromTime(Time time) 1981 { 1982 std::map<Time, StdSize>::const_iterator it = timeToRecordCache.find(time); 1983 if (it == timeToRecordCache.end()) 1984 { 1985 StdString timeAxisBoundsId("time_counter_bounds"); 1986 if (!SuperClassWriter::varExist(timeAxisBoundsId)) 1987 timeAxisBoundsId = "time_instant_bounds"; 1988 1989 CArray<double,2> timeAxisBounds; 1990 SuperClassWriter::getTimeAxisBounds(timeAxisBounds, timeAxisBoundsId, isCollective); 1991 1992 StdSize record = 0; 1993 double dtime(time); 1994 for (int n = timeAxisBounds.extent(1) - 1; n >= 0; n--) 1995 { 1996 if (timeAxisBounds(1, n) < dtime) 1997 { 1998 record = n + 1; 1999 break; 2000 } 2001 } 2002 it = timeToRecordCache.insert(std::make_pair(time, record)).first; 2003 } 2004 return it->second; 2005 } 1973 2006 } // namespace xios
Note: See TracChangeset
for help on using the changeset viewer.