Changeset 1096 for XIOS/trunk/src
- Timestamp:
- 04/14/17 11:18:27 (7 years ago)
- Location:
- XIOS/trunk/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/src/config/file_attribute.conf
r1048 r1096 17 17 DECLARE_ATTRIBUTE(bool, append) 18 18 DECLARE_ENUM2(mode, read, write) 19 DECLARE_ENUM 4(time_counter, centered, instant, record, none)19 DECLARE_ENUM7(time_counter, centered, instant, record, exclusive, centered_exclusive, instant_exclusive, none) 20 20 DECLARE_ATTRIBUTE(StdString, time_counter_name) 21 21 DECLARE_ENUM2(time_units, seconds, days) -
XIOS/trunk/src/data_output.cpp
r887 r1096 84 84 //---------------------------------------------------------------- 85 85 86 void CDataOutput::writeField (CField* field)86 void CDataOutput::writeFieldTimeAxis(CField* field) 87 87 { 88 88 CContext* context = CContext::getCurrent() ; 89 89 boost::shared_ptr<CCalendar> calendar = context->getCalendar(); 90 90 91 this->writeTimeAxis_(field, calendar); 92 } 93 94 void CDataOutput::writeField(CField* field) 95 { 91 96 this->writeField_(field); 92 this->writeTimeAxis_(field, calendar);93 97 } 94 98 -
XIOS/trunk/src/data_output.hpp
r887 r1096 25 25 void closeFile (void); 26 26 void writeField (CField* field); 27 void writeFieldTimeAxis(CField* field) ; 27 28 void writeFieldGrid(CField* field); 28 29 void writeTimeDimension(void); -
XIOS/trunk/src/io/nc4_data_output.cpp
r1061 r1096 21 21 , SuperClassWriter(filename, exist) 22 22 , filename(filename) 23 , file(file) 23 , file(file),hasTimeInstant(false),hasTimeCentered(false), timeCounterType(none) 24 24 { 25 25 SuperClass::type = MULTI_FILE; … … 34 34 , filename(filename) 35 35 , isCollective(isCollective) 36 , file(file) 36 , file(file),hasTimeInstant(false),hasTimeCentered(false), timeCounterType(none) 37 37 { 38 38 SuperClass::type = (multifile) ? MULTI_FILE : ONE_FILE; … … 1617 1617 } 1618 1618 1619 /*1620 StdString lonid_loc = (server->intraCommSize > 1)1621 ? StdString("lon").append(appendDomid).append("_local")1622 : lonid;1623 StdString latid_loc = (server->intraCommSize > 1)1624 ? StdString("lat").append(appendDomid).append("_local")1625 : latid;1626 */1627 1619 StdString fieldid = field->getFieldOutputName(); 1628 1620 … … 1640 1632 if (wtime) 1641 1633 { 1642 1643 //StdOStringStream oss; 1644 // oss << "time_" << field->operation.getValue() 1645 // << "_" << field->getRelFile()->output_freq.getValue(); 1646 //oss 1647 if (field->getOperationTimeType() == func::CFunctor::instant) coodinates.push_back(string("time_instant")); 1648 else if (field->getOperationTimeType() == func::CFunctor::centered) coodinates.push_back(string("time_centered")); 1634 if (field->hasTimeInstant && hasTimeInstant) coodinates.push_back(string("time_instant")); 1635 else if (field->hasTimeCentered && hasTimeCentered) coodinates.push_back(string("time_centered")); 1649 1636 dims.push_back(timeid); 1650 1637 } … … 2011 1998 StdOStringStream oss; 2012 1999 string timeAxisId; 2013 if (field-> getOperationTimeType() == func::CFunctor::instant) timeAxisId = "time_instant";2014 else if (field-> getOperationTimeType() == func::CFunctor::centered) timeAxisId = "time_centered";2000 if (field->hasTimeInstant) timeAxisId = "time_instant"; 2001 else if (field->hasTimeCentered) timeAxisId = "time_centered"; 2015 2002 2016 2003 StdString timeBoundId = getTimeCounterName() + "_bounds"; 2017 2004 2018 2005 StdString timeAxisBoundId; 2019 if (field-> getOperationTimeType() == func::CFunctor::instant) timeAxisBoundId = "time_instant_bounds";2020 else if (field-> getOperationTimeType() == func::CFunctor::centered) timeAxisBoundId = "time_centered_bounds";2006 if (field->hasTimeInstant) timeAxisBoundId = "time_instant_bounds"; 2007 else if (field->hasTimeCentered) timeAxisBoundId = "time_centered_bounds"; 2021 2008 2022 2009 if (!field->wasWritten()) … … 2042 2029 2043 2030 bool wtime = (field->getOperationTimeType() != func::CFunctor::once); 2031 bool wtimeCounter =false ; 2032 bool wtimeData =false ; 2033 2044 2034 2045 2035 if (wtime) 2046 2036 { 2047 2048 if (field->getOperationTimeType() == func::CFunctor::instant) field->hasTimeInstant = true;2049 if (field->getOperationTimeType() == func::CFunctor::centered) field->hasTimeCentered = true;2050 2037 2051 2038 Time lastWrite = field->last_Write_srv; 2052 2039 Time lastLastWrite = field->lastlast_Write_srv; 2053 2040 2054 if (field->getOperationTimeType() == func::CFunctor::instant) 2055 time_data(0) = lastWrite; 2056 else if (field->getOperationTimeType() == func::CFunctor::centered) 2041 2042 if (field->hasTimeInstant) 2043 { 2044 time_data(0) = time_data_bound(1) = lastWrite; 2045 time_data_bound(0) = time_data_bound(1) = lastWrite; 2046 if (timeCounterType==instant) 2047 { 2048 time_counter(0) = time_data(0); 2049 time_counter_bound(0) = time_data_bound(0); 2050 time_counter_bound(1) = time_data_bound(1); 2051 wtimeCounter=true ; 2052 } 2053 if (hasTimeInstant) wtimeData=true ; 2054 } 2055 else if (field->hasTimeCentered) 2056 { 2057 2057 time_data(0) = (lastWrite + lastLastWrite) / 2; 2058 2059 if (field->getOperationTimeType() == func::CFunctor::instant)2060 time_data_bound(0) = time_data_bound(1) = lastWrite;2061 else if (field->getOperationTimeType() == func::CFunctor::centered)2062 {2063 2058 time_data_bound(0) = lastLastWrite; 2064 2059 time_data_bound(1) = lastWrite; 2060 if (timeCounterType==centered) 2061 { 2062 time_counter(0) = time_data(0) ; 2063 time_counter_bound(0) = time_data_bound(0) ; 2064 time_counter_bound(1) = time_data_bound(1) ; 2065 wtimeCounter=true ; 2066 } 2067 if (hasTimeCentered) wtimeData=true ; 2065 2068 } 2066 2067 if (field->file->time_counter.isEmpty()) 2068 if (field->hasTimeInstant && !field->hasTimeCentered) 2069 time_counter(0) = lastWrite; 2070 else 2071 time_counter(0) = (lastWrite + lastLastWrite) / 2; 2072 2073 else if (field->file->time_counter == CFile::time_counter_attr::instant) 2074 time_counter(0) = lastWrite; 2075 else if (field->file->time_counter == CFile::time_counter_attr::centered) 2076 time_counter(0) = (lastWrite + lastLastWrite) / 2; 2077 else if (field->file->time_counter == CFile::time_counter_attr::record) 2069 2070 if (timeCounterType==record) 2071 { 2078 2072 time_counter(0) = field->getNStep() - 1; 2079 2080 2081 if (field->file->time_counter.isEmpty()) 2082 if (field->hasTimeInstant && !field->hasTimeCentered) 2083 time_counter_bound(0) = time_counter_bound(1) = lastWrite; 2084 else 2085 { 2086 time_counter_bound(0) = lastLastWrite; 2087 time_counter_bound(1) = lastWrite; 2088 } 2089 else if (field->file->time_counter == CFile::time_counter_attr::instant) 2090 time_counter_bound(0) = time_counter_bound(1) = lastWrite; 2091 else if (field->file->time_counter == CFile::time_counter_attr::centered) 2092 { 2093 time_counter_bound(0) = lastLastWrite; 2094 time_counter_bound(1) = lastWrite; 2073 time_counter_bound(0) = time_counter_bound(1) = field->getNStep() - 1; 2074 wtimeCounter=true ; 2095 2075 } 2096 else if (field->file->time_counter == CFile::time_counter_attr::record)2097 time_counter_bound(0) = time_counter_bound(1) = field->getNStep() - 1;2098 2099 2100 2076 2101 2077 if (!field->file->time_units.isEmpty() && field->file->time_units==CFile::time_units_attr::days) … … 2145 2121 if (wtime) 2146 2122 { 2147 SuperClassWriter::writeData(time_data, timeAxisId, isCollective, field->getNStep() - 1); 2148 SuperClassWriter::writeData(time_data_bound, timeAxisBoundId, isCollective, field->getNStep() - 1); 2149 if (field->file->time_counter.isEmpty() || 2150 (field->file->time_counter != CFile::time_counter_attr::none)) 2123 if ( wtimeData) 2124 { 2125 SuperClassWriter::writeData(time_data, timeAxisId, isCollective, field->getNStep() - 1); 2126 SuperClassWriter::writeData(time_data_bound, timeAxisBoundId, isCollective, field->getNStep() - 1); 2127 } 2128 if (wtimeCounter) 2151 2129 { 2152 2130 SuperClassWriter::writeData(time_counter, getTimeCounterName(), isCollective, field->getNStep() - 1); 2153 if (field->file->time_counter.isEmpty() || 2154 (field->file->time_counter != CFile::time_counter_attr::record)) 2155 SuperClassWriter::writeData(time_counter_bound, timeBoundId, isCollective, field->getNStep() - 1); 2131 if (timeCounterType!=record) SuperClassWriter::writeData(time_counter_bound, timeBoundId, isCollective, field->getNStep() - 1); 2156 2132 } 2157 2133 } … … 2281 2257 2282 2258 SuperClassWriter::writeData(fieldData, fieldid, isCollective, field->getNStep() - 1, &start, &count); 2283 if (wtime) 2284 { 2285 SuperClassWriter::writeTimeAxisData(time_data, timeAxisId, isCollective, field->getNStep() - 1, isRoot); 2286 SuperClassWriter::writeTimeAxisData(time_data_bound, timeAxisBoundId, isCollective, field->getNStep() - 1, isRoot); 2287 if (field->file->time_counter.isEmpty() || 2288 (field->file->time_counter != CFile::time_counter_attr::none)) 2259 if (wtime) 2260 { 2261 if ( wtimeData) 2289 2262 { 2290 SuperClassWriter::writeTimeAxisData(time_counter, getTimeCounterName(), isCollective, field->getNStep() - 1, isRoot); 2291 if (field->file->time_counter.isEmpty() || 2292 (field->file->time_counter != CFile::time_counter_attr::record)) 2293 SuperClassWriter::writeTimeAxisData(time_counter_bound, timeBoundId, isCollective, field->getNStep() - 1, isRoot); 2263 SuperClassWriter::writeData(time_data, timeAxisId, isCollective, field->getNStep() - 1); 2264 SuperClassWriter::writeData(time_data_bound, timeAxisBoundId, isCollective, field->getNStep() - 1); 2294 2265 } 2295 } 2266 if (wtimeCounter) 2267 { 2268 SuperClassWriter::writeData(time_counter, getTimeCounterName(), isCollective, field->getNStep() - 1); 2269 if (timeCounterType!=record) SuperClassWriter::writeData(time_counter_bound, timeBoundId, isCollective, field->getNStep() - 1); 2270 } 2271 } 2296 2272 2297 2273 break; … … 2317 2293 { 2318 2294 StdOStringStream oss; 2319 2295 bool createInstantAxis=false ; 2296 bool createCenteredAxis=false ; 2297 bool createTimeCounterAxis=false ; 2298 2320 2299 if (field->getOperationTimeType() == func::CFunctor::once) return ; 2321 2300 2322 // oss << "time_" << field->operation.getValue() 2323 // << "_" << field->getRelFile()->output_freq.getValue(); 2324 2325 // StdString axisid = oss.str(); 2326 // if (field->getOperationTimeType() == func::CFunctor::centered) axisid="time_centered" ; 2327 // else if (field->getOperationTimeType() == func::CFunctor::instant) axisid="time_instant" ; 2328 2329 StdString axisid("time_centered") ; 2330 StdString axisBoundId("time_centered_bounds"); 2301 2302 StdString axisId ; 2303 StdString axisBoundId; 2331 2304 StdString timeid(getTimeCounterName()); 2332 2305 StdString timeBoundId("axis_nbounds"); … … 2336 2309 else strTimeUnits="seconds since " ; 2337 2310 2338 if (field->getOperationTimeType() == func::CFunctor::instant) 2339 { 2340 axisid = "time_instant"; 2341 axisBoundId = "time_instant_bounds"; 2342 field->hasTimeInstant = true; 2343 } 2344 2345 if (field->getOperationTimeType() == func::CFunctor::centered) 2346 { 2347 field->hasTimeCentered = true; 2348 } 2349 2311 if (field->getOperationTimeType() == func::CFunctor::instant) field->hasTimeInstant = true; 2312 if (field->getOperationTimeType() == func::CFunctor::centered) field->hasTimeCentered = true; 2313 2314 2315 if (field->file->time_counter.isEmpty()) 2316 { 2317 if (timeCounterType==none) createTimeCounterAxis=true ; 2318 if (field->hasTimeCentered) 2319 { 2320 timeCounterType=centered ; 2321 if (!hasTimeCentered) createCenteredAxis=true ; 2322 } 2323 if (field->hasTimeInstant) 2324 { 2325 if (timeCounterType==none) timeCounterType=instant ; 2326 if (!hasTimeInstant) createInstantAxis=true ; 2327 } 2328 } 2329 else if (field->file->time_counter==CFile::time_counter_attr::instant) 2330 { 2331 if (field->hasTimeCentered) 2332 { 2333 if (!hasTimeCentered) createCenteredAxis=true ; 2334 } 2335 if (field->hasTimeInstant) 2336 { 2337 if (timeCounterType==none) createTimeCounterAxis=true ; 2338 timeCounterType=instant ; 2339 if (!hasTimeInstant) createInstantAxis=true ; 2340 } 2341 } 2342 else if (field->file->time_counter==CFile::time_counter_attr::centered) 2343 { 2344 if (field->hasTimeCentered) 2345 { 2346 if (timeCounterType==none) createTimeCounterAxis=true ; 2347 timeCounterType=centered ; 2348 if (!hasTimeCentered) createCenteredAxis=true ; 2349 } 2350 if (field->hasTimeInstant) 2351 { 2352 if (!hasTimeInstant) createInstantAxis=true ; 2353 } 2354 } 2355 else if (field->file->time_counter==CFile::time_counter_attr::instant_exclusive) 2356 { 2357 if (field->hasTimeCentered) 2358 { 2359 if (!hasTimeCentered) createCenteredAxis=true ; 2360 } 2361 if (field->hasTimeInstant) 2362 { 2363 if (timeCounterType==none) createTimeCounterAxis=true ; 2364 timeCounterType=instant ; 2365 } 2366 } 2367 else if (field->file->time_counter==CFile::time_counter_attr::centered_exclusive) 2368 { 2369 if (field->hasTimeCentered) 2370 { 2371 if (timeCounterType==none) createTimeCounterAxis=true ; 2372 timeCounterType=centered ; 2373 } 2374 if (field->hasTimeInstant) 2375 { 2376 if (!hasTimeInstant) createInstantAxis=true ; 2377 } 2378 } 2379 else if (field->file->time_counter==CFile::time_counter_attr::exclusive) 2380 { 2381 if (field->hasTimeCentered) 2382 { 2383 if (timeCounterType==none) createTimeCounterAxis=true ; 2384 if (timeCounterType==instant) createInstantAxis=true ; 2385 timeCounterType=centered ; 2386 } 2387 if (field->hasTimeInstant) 2388 { 2389 if (timeCounterType==none) 2390 { 2391 createTimeCounterAxis=true ; 2392 timeCounterType=instant ; 2393 } 2394 if (timeCounterType==centered) 2395 { 2396 if (!hasTimeInstant) createInstantAxis=true ; 2397 } 2398 } 2399 } 2400 else if (field->file->time_counter==CFile::time_counter_attr::none) 2401 { 2402 if (field->hasTimeCentered) 2403 { 2404 if (!hasTimeCentered) createCenteredAxis=true ; 2405 } 2406 if (field->hasTimeInstant) 2407 { 2408 if (!hasTimeInstant) createInstantAxis=true ; 2409 } 2410 } 2411 else if (field->file->time_counter==CFile::time_counter_attr::record) 2412 { 2413 if (timeCounterType==none) createTimeCounterAxis=true ; 2414 timeCounterType=record ; 2415 if (field->hasTimeCentered) 2416 { 2417 if (!hasTimeCentered) createCenteredAxis=true ; 2418 } 2419 if (field->hasTimeInstant) 2420 { 2421 if (!hasTimeInstant) createInstantAxis=true ; 2422 } 2423 } 2424 2425 if (createInstantAxis) 2426 { 2427 axisId="time_instant" ; 2428 axisBoundId="time_instant_bounds"; 2429 hasTimeInstant=true ; 2430 } 2431 2432 if (createCenteredAxis) 2433 { 2434 axisId="time_centered" ; 2435 axisBoundId="time_centered_bounds"; 2436 hasTimeCentered=true ; 2437 } 2438 2439 2350 2440 try 2351 2441 { 2352 // Adding time_instant or time_centered 2353 std::vector<StdString> dims; 2354 dims.push_back(timeid); 2355 if (!SuperClassWriter::varExist(axisid)) 2356 { 2357 SuperClassWriter::addVariable(axisid, NC_DOUBLE, dims); 2358 2359 CDate timeOrigin=cal->getTimeOrigin() ; 2360 StdOStringStream oss2; 2361 // oss2<<initDate.getYear()<<"-"<<initDate.getMonth()<<"-"<<initDate.getDay()<<" " 2362 // <<initDate.getHour()<<"-"<<initDate.getMinute()<<"-"<<initDate.getSecond() ; 2363 StdString strInitdate=oss2.str() ; 2364 StdString strTimeOrigin=timeOrigin.toString() ; 2365 this->writeTimeAxisAttributes 2366 (axisid, cal->getType(),strTimeUnits+strTimeOrigin, 2367 strTimeOrigin, axisBoundId); 2442 std::vector<StdString> dims; 2443 2444 if (createInstantAxis || createCenteredAxis) 2445 { 2446 // Adding time_instant or time_centered 2447 dims.push_back(timeid); 2448 if (!SuperClassWriter::varExist(axisId)) 2449 { 2450 SuperClassWriter::addVariable(axisId, NC_DOUBLE, dims); 2451 2452 CDate timeOrigin=cal->getTimeOrigin() ; 2453 StdOStringStream oss2; 2454 StdString strInitdate=oss2.str() ; 2455 StdString strTimeOrigin=timeOrigin.toString() ; 2456 this->writeTimeAxisAttributes(axisId, cal->getType(),strTimeUnits+strTimeOrigin, 2457 strTimeOrigin, axisBoundId); 2458 } 2459 2460 // Adding time_instant_bounds or time_centered_bounds variables 2461 if (!SuperClassWriter::varExist(axisBoundId)) 2462 { 2463 dims.clear() ; 2464 dims.push_back(timeid); 2465 dims.push_back(timeBoundId); 2466 SuperClassWriter::addVariable(axisBoundId, NC_DOUBLE, dims); 2467 } 2368 2468 } 2369 2469 2370 // Adding time_instant_bounds or time_centered_bounds variables 2371 if (!SuperClassWriter::varExist(axisBoundId)) 2372 { 2373 dims.clear() ; 2374 dims.push_back(timeid); 2375 dims.push_back(timeBoundId); 2376 SuperClassWriter::addVariable(axisBoundId, NC_DOUBLE, dims); 2377 } 2378 2379 if (field->file->time_counter.isEmpty() || 2380 (field->file->time_counter != CFile::time_counter_attr::none)) 2470 if (createTimeCounterAxis) 2381 2471 { 2382 2472 // Adding time_counter 2383 axis id = getTimeCounterName();2473 axisId = getTimeCounterName(); 2384 2474 axisBoundId = getTimeCounterName() + "_bounds"; 2385 2475 dims.clear(); 2386 2476 dims.push_back(timeid); 2387 if (!SuperClassWriter::varExist(axis id))2477 if (!SuperClassWriter::varExist(axisId)) 2388 2478 { 2389 SuperClassWriter::addVariable(axis id, NC_DOUBLE, dims);2390 SuperClassWriter::addAttribute("axis", string("T"), &axis id);2479 SuperClassWriter::addVariable(axisId, NC_DOUBLE, dims); 2480 SuperClassWriter::addAttribute("axis", string("T"), &axisId); 2391 2481 2392 2482 if (field->file->time_counter.isEmpty() || … … 2396 2486 StdString strTimeOrigin = timeOrigin.toString(); 2397 2487 2398 this->writeTimeAxisAttributes(axis id, cal->getType(),2488 this->writeTimeAxisAttributes(axisId, cal->getType(), 2399 2489 strTimeUnits+strTimeOrigin, 2400 2490 strTimeOrigin, axisBoundId); … … 2403 2493 2404 2494 // Adding time_counter_bound dimension 2405 if (field->file->time_counter.isEmpty() || 2406 (field->file->time_counter != CFile::time_counter_attr::record)) 2495 if (field->file->time_counter.isEmpty() || (field->file->time_counter != CFile::time_counter_attr::record)) 2407 2496 { 2408 2497 if (!SuperClassWriter::varExist(axisBoundId)) -
XIOS/trunk/src/io/nc4_data_output.hpp
r1046 r1096 123 123 std::set<std::string> writtenAxis, writtenCompressedAxis; 124 124 std::set<std::string> writtenScalar; 125 126 enum { none, centered, instant, record} timeCounterType ; 127 bool hasTimeInstant ; 128 bool hasTimeCentered ; 125 129 }; // class CNc4DataOutput 126 130 -
XIOS/trunk/src/node/file.cpp
r1092 r1096 484 484 { 485 485 CField* field = *it; 486 this->data_out->writeFieldTimeAxis(field); 487 } 488 489 for (it = this->enabledFields.begin(); it != end; it++) 490 { 491 CField* field = *it; 486 492 this->data_out->writeField(field); 487 493 }
Note: See TracChangeset
for help on using the changeset viewer.