Changeset 1704 for XIOS/trunk/src/node
- Timestamp:
- 09/11/19 10:22:09 (5 years ago)
- Location:
- XIOS/trunk/src/node
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/src/node/field.cpp
r1639 r1704 24 24 #include "spatial_transform_filter.hpp" 25 25 #include "file_server_writer_filter.hpp" 26 #include "workflow_graph.hpp" 26 27 27 28 namespace xios{ … … 45 46 , mustAutoTrigger(false) 46 47 , isEOF(false), nstepMaxRead(false) 47 { setVirtualVariableGroup(CVariableGroup::create(getId() + "_virtual_variable_group")); } 48 { setVirtualVariableGroup(CVariableGroup::create(getId() + "_virtual_variable_group")); 49 field_graph_start = -2; 50 field_graph_end = -2; 51 } 48 52 49 53 CField::CField(const StdString& id) … … 63 67 , mustAutoTrigger(false) 64 68 , isEOF(false), nstepMaxRead(false) 65 { setVirtualVariableGroup(CVariableGroup::create(getId() + "_virtual_variable_group")); } 69 { setVirtualVariableGroup(CVariableGroup::create(getId() + "_virtual_variable_group")); 70 field_graph_start = -2; 71 field_graph_end = -2; 72 } 73 66 74 67 75 CField::~CField(void) … … 1106 1114 * read by the client or/and written to a file 1107 1115 */ 1108 void CField::buildFilterGraph(CGarbageCollector& gc, bool enableOutput )1116 void CField::buildFilterGraph(CGarbageCollector& gc, bool enableOutput, Time start_graph, Time end_graph) 1109 1117 TRY 1110 1118 { 1111 if (!isReferenceSolvedAndTransformed) solveAllEnabledFieldsAndTransform();1112 if (!isGridChecked) checkGridOfEnabledFields();1119 if (!isReferenceSolvedAndTransformed) solveAllEnabledFieldsAndTransform(); 1120 if (!isGridChecked) checkGridOfEnabledFields(); 1113 1121 1114 1122 const bool detectMissingValues = (!detect_missing_value.isEmpty() && !default_value.isEmpty() && detect_missing_value == true); 1123 1124 const bool buildWorkflowGraph = (!build_workflow_graph.isEmpty() && build_workflow_graph == true); 1125 1126 1115 1127 const double defaultValue = detectMissingValues ? default_value : (!default_value.isEmpty() ? default_value : 0.0); 1116 1128 1117 1129 CContext* context = CContext::getCurrent(); 1130 1131 Time filter_start; 1132 if(!build_workflow_graph_start.isEmpty() && buildWorkflowGraph) filter_start = context->calendar->getInitDate()+build_workflow_graph_start; 1133 else if(build_workflow_graph_start.isEmpty() && buildWorkflowGraph) filter_start = 0; 1134 else filter_start = -1; 1135 1136 Time filter_end; 1137 if(!build_workflow_graph_end.isEmpty() && buildWorkflowGraph) filter_end = context->calendar->getInitDate()+build_workflow_graph_end; 1138 else if(build_workflow_graph_end.isEmpty() && buildWorkflowGraph) filter_end = 9223372036854775807; 1139 else filter_end = -1; 1140 1141 if(this->field_graph_start==-2) this->field_graph_start = filter_start; 1142 if(this->field_graph_end==-2) this->field_graph_end = filter_end; // init 1143 1144 // if(CXios::isClient) std::cout<<"****************** buildFilterGraph : field_id = "<<this->getId()<<" BEFORE: this->field_graph_start = "<<this->field_graph_start<<" this->field_graph_end = "<<this->field_graph_end<<std::endl; 1145 1146 if(start_graph == -1) 1147 { 1148 //nothing 1149 // if(CXios::isClient) std::cout<<"buildFilterGraph field_id = "<<this->getId()<<" case1: this->field_graph_start = "<<this->field_graph_start<<std::endl; 1150 } 1151 else //if(start_graph != -1) 1152 { 1153 if(this->field_graph_start == -1) this->field_graph_start = start_graph; 1154 else this->field_graph_start = min(this->field_graph_start, start_graph); 1155 1156 // if(CXios::isClient) std::cout<<"buildFilterGraph field_id = "<<this->getId()<<" case2: this->field_graph_start = "<<this->field_graph_start<<std::endl; 1157 } 1158 1159 1160 if(end_graph == -1) 1161 { 1162 //nothing 1163 // if(CXios::isClient) std::cout<<"buildFilterGraph field_id = "<<this->getId()<<" case1: this->field_graph_end = "<<this->field_graph_end<<std::endl; 1164 } 1165 else 1166 { 1167 if(this->field_graph_end == -1) this->field_graph_end = end_graph; 1168 else this->field_graph_end = max(this->field_graph_end, end_graph); 1169 1170 // if(CXios::isClient) std::cout<<"buildFilterGraph field_id = "<<this->getId()<<" case2: this->field_graph_end = "<<this->field_graph_end<<std::endl; 1171 } 1172 1173 1174 filter_start = this->field_graph_start; 1175 filter_end = this->field_graph_end; 1176 1177 1178 // if(CXios::isClient) std::cout<<"****************** buildFilterGraph : field_id = "<<this->getId()<<" AFTER: this->field_graph_start = "<<this->field_graph_start<<" this->field_graph_end = "<<this->field_graph_end<<std::endl; 1179 1180 1181 1182 1183 1118 1184 bool hasWriterServer = context->hasServer && !context->hasClient; 1119 1185 bool hasIntermediateServer = context->hasServer && context->hasClient; … … 1159 1225 { 1160 1226 boost::scoped_ptr<IFilterExprNode> expr(parseExpr(getExpression() + '\0')); 1161 std::shared_ptr<COutputPin> filter = expr->reduce(gc, *this );1227 std::shared_ptr<COutputPin> filter = expr->reduce(gc, *this, filter_start, filter_end); 1162 1228 1163 1229 // Check if a spatial transformation is needed … … 1168 1234 if (grid && grid != gridRef && grid->hasTransform()) 1169 1235 { 1170 std::pair<std::shared_ptr<CFilter>, std::shared_ptr<CFilter> > filters = CSpatialTransformFilter::buildFilterGraph(gc, gridRef, grid, detectMissingValues, defaultValue);1236 std::pair<std::shared_ptr<CFilter>, std::shared_ptr<CFilter> > filters = CSpatialTransformFilter::buildFilterGraph(gc, gridRef, grid, detectMissingValues, defaultValue); 1171 1237 1172 1238 filter->connectOutput(filters.first, 0); … … 1176 1242 1177 1243 instantDataFilter = filter; 1244 instantDataFilter->field = this; 1245 filter->tag = buildWorkflowGraph; 1246 1247 filter->start_graph = filter_start; 1248 filter->end_graph = filter_end; 1249 1250 for(int i=0; i<filter->parent_filters.size(); i++) 1251 { 1252 filter->tag = filter->tag || filter->parent_filters[i]->tag; 1253 } 1178 1254 } 1179 1255 // Check if we have a reference on another field 1180 1256 else if (!field_ref.isEmpty()) 1181 instantDataFilter = getFieldReference(gc); 1257 { 1258 instantDataFilter = getFieldReference(gc, filter_start, filter_end); 1259 instantDataFilter->tag = buildWorkflowGraph; 1260 instantDataFilter->start_graph = filter_start; 1261 instantDataFilter->end_graph = filter_end; 1262 } 1182 1263 // Check if the data is to be read from a file 1183 1264 else if (file && !file->mode.isEmpty() && file->mode == CFile::mode_attr::read) … … 1186 1267 instantDataFilter = serverSourceFilter = std::shared_ptr<CSourceFilter>(new CSourceFilter(gc, grid, true, false, freq_offset, true, 1187 1268 detectMissingValues, defaultValue)); 1269 instantDataFilter->tag = buildWorkflowGraph; 1270 instantDataFilter->start_graph = filter_start; 1271 instantDataFilter->end_graph = filter_end; 1272 instantDataFilter->field = this; 1273 1188 1274 } 1189 1275 else // The data might be passed from the model … … 1191 1277 if (check_if_active.isEmpty()) check_if_active = false; 1192 1278 instantDataFilter = clientSourceFilter = std::shared_ptr<CSourceFilter>(new CSourceFilter(gc, grid, false, true, NoneDu, false, 1193 detectMissingValues, defaultValue)); 1279 detectMissingValues, defaultValue)); 1280 instantDataFilter->tag = buildWorkflowGraph; 1281 instantDataFilter->start_graph = filter_start; 1282 instantDataFilter->end_graph = filter_end; 1283 instantDataFilter->field = this; 1284 // if(CXios::isClient) std::cout<<"***********************buildFilterGraph init source filter : field_id = "<<this->getId()<<" sourcefilter->start_graph = "<<clientSourceFilter->start_graph<<" sourcefilter->end_graph = "<<clientSourceFilter->end_graph<<std::endl; 1194 1285 } 1195 1286 } … … 1203 1294 detectMissingValues, defaultValue)); 1204 1295 instantDataFilter->connectOutput(storeFilter, 0); 1296 1297 storeFilter->tag = (instantDataFilter->tag || buildWorkflowGraph); 1298 instantDataFilter->start_graph = filter_start; 1299 instantDataFilter->end_graph = filter_end; 1300 1301 instantDataFilter->setParentFiltersTag(); 1302 storeFilter->start_graph = filter_start; 1303 storeFilter->end_graph = filter_end; 1304 storeFilter->field = this; 1305 storeFilter->distance = instantDataFilter->distance+1; 1205 1306 } 1206 1307 … … 1209 1310 fileWriterFilter = std::shared_ptr<CFileWriterFilter>(new CFileWriterFilter(gc, this)); 1210 1311 getTemporalDataFilter(gc, file->output_freq)->connectOutput(fileWriterFilter, 0); 1312 1313 fileWriterFilter->tag = (getTemporalDataFilter(gc, file->output_freq)->tag || buildWorkflowGraph); 1314 getTemporalDataFilter(gc, file->output_freq)->start_graph = filter_start; 1315 getTemporalDataFilter(gc, file->output_freq)->end_graph = filter_end; 1316 getTemporalDataFilter(gc, file->output_freq)->tag = buildWorkflowGraph; 1317 getTemporalDataFilter(gc, file->output_freq)->setParentFiltersTag(); 1318 fileWriterFilter->start_graph = filter_start; 1319 fileWriterFilter->end_graph = filter_end; 1320 fileWriterFilter->distance = getTemporalDataFilter(gc, file->output_freq)->distance+1; 1321 1322 // std::cout<<"CFileWriterFilter filter start = "<<filter_start<<" end = "<<filter_end<<" field = "<<this->getId()<<std::endl; 1323 1211 1324 } 1212 1325 } … … 1222 1335 * \return the output pin corresponding to the field reference 1223 1336 */ 1224 std::shared_ptr<COutputPin> CField::getFieldReference(CGarbageCollector& gc )1337 std::shared_ptr<COutputPin> CField::getFieldReference(CGarbageCollector& gc, Time start_graph, Time end_graph) 1225 1338 TRY 1226 1339 { … … 1230 1343 1231 1344 CField* fieldRef = CField::get(field_ref); 1232 fieldRef->buildFilterGraph(gc, false); 1345 fieldRef->buildFilterGraph(gc, false, start_graph, end_graph); 1346 const bool buildWorkflowGraph = (!build_workflow_graph.isEmpty() && build_workflow_graph == true); 1347 1348 CContext* context = CContext::getCurrent(); 1349 1350 Time filter_start; 1351 if(!build_workflow_graph_start.isEmpty() && buildWorkflowGraph) filter_start = context->calendar->getInitDate()+build_workflow_graph_start; 1352 else if(build_workflow_graph_start.isEmpty() && buildWorkflowGraph) filter_start = 0; 1353 else filter_start = -1; 1354 1355 Time filter_end; 1356 if(!build_workflow_graph_end.isEmpty() && buildWorkflowGraph) filter_end = context->calendar->getInitDate()+build_workflow_graph_end; 1357 else if(build_workflow_graph_end.isEmpty() && buildWorkflowGraph) filter_end = 9223372036854775807; 1358 else filter_end = -1; 1359 1360 if(this->field_graph_start==-2) this->field_graph_start = filter_start; 1361 if(this->field_graph_end==-2) this->field_graph_end = filter_end; // init 1362 1363 // if(CXios::isClient) std::cout<<"getFieldReference field_id = "<<this->getId()<<" BEFORE: this->field_graph_start = "<<this->field_graph_start<<" this->field_graph_end = "<<this->field_graph_end<<std::endl; 1364 1365 if(start_graph == -1) 1366 { 1367 //nothing 1368 // if(CXios::isClient) std::cout<<"getFieldReference field_id = "<<this->getId()<<" case1: this->field_graph_start = "<<this->field_graph_start<<std::endl; 1369 } 1370 else //if(start_graph != -1) 1371 { 1372 if(this->field_graph_start == -1) this->field_graph_start = start_graph; 1373 else this->field_graph_start = min(this->field_graph_start, start_graph); 1374 1375 // if(CXios::isClient) std::cout<<"getFieldReference field_id = "<<this->getId()<<" case2: this->field_graph_start = "<<this->field_graph_start<<std::endl; 1376 } 1377 1378 if(end_graph == -1) 1379 { 1380 //nothing 1381 // if(CXios::isClient) std::cout<<"getFieldReference field_id = "<<this->getId()<<" case1: this->field_graph_end = "<<this->field_graph_end<<std::endl; 1382 } 1383 else 1384 { 1385 if(this->field_graph_end == -1) this->field_graph_end = end_graph; 1386 else this->field_graph_end = max(this->field_graph_end, end_graph); 1387 1388 // if(CXios::isClient) std::cout<<"getFieldReference field_id = "<<this->getId()<<" case2: this->field_graph_end = "<<this->field_graph_end<<std::endl; 1389 } 1390 1391 filter_start = this->field_graph_start; 1392 filter_end = this->field_graph_end; 1393 1394 // if(CXios::isClient) std::cout<<"getFieldReference field_id = "<<this->getId()<<" AFTER: this->field_graph_start = "<<this->field_graph_start<<" this->field_graph_end = "<<this->field_graph_end<<std::endl; 1395 1233 1396 1234 1397 std::pair<std::shared_ptr<CFilter>, std::shared_ptr<CFilter> > filters; … … 1239 1402 double defaultValue = hasMissingValue ? default_value : (!default_value.isEmpty() ? default_value : 0.0); 1240 1403 filters = CSpatialTransformFilter::buildFilterGraph(gc, fieldRef->grid, grid, hasMissingValue, defaultValue); 1404 1405 fieldRef->getInstantDataFilter()->connectOutput(filters.first, 0); 1406 1407 1408 1409 filters.second->parent_filters.resize(1); 1410 filters.second->parent_filters[0]= fieldRef->getInstantDataFilter(); 1411 1412 filters.second->tag = (buildWorkflowGraph || filters.second->parent_filters[0]->tag); 1413 1414 filters.second->start_graph = filter_start; 1415 filters.second->end_graph = filter_end; 1416 filters.second->field = this; 1417 1241 1418 } 1242 1419 else 1420 { 1243 1421 filters.first = filters.second = std::shared_ptr<CFilter>(new CPassThroughFilter(gc)); 1244 1422 1245 fieldRef->getInstantDataFilter()->connectOutput(filters.first, 0); 1423 fieldRef->getInstantDataFilter()->connectOutput(filters.first, 0); 1424 1425 1426 filters.second->parent_filters.resize(1); 1427 filters.second->parent_filters[0]= fieldRef->getInstantDataFilter(); 1428 1429 filters.second->tag = (buildWorkflowGraph || filters.second->parent_filters[0]->tag); 1430 1431 filters.second->start_graph = filter_start; 1432 filters.second->end_graph = filter_end; 1433 filters.second->field = this; 1434 1435 } 1246 1436 1247 1437 return filters.second; … … 1258 1448 * \return the output pin corresponding to a self reference 1259 1449 */ 1260 std::shared_ptr<COutputPin> CField::getSelfReference(CGarbageCollector& gc) 1261 TRY 1262 { 1450 std::shared_ptr<COutputPin> CField::getSelfReference(CGarbageCollector& gc, Time start_graph, Time end_graph) 1451 TRY 1452 { 1453 if(CXios::isClient) std::cout<<"getSelfReference field_id = "<<this->getId()<<" start_graph = "<<start_graph<<" end_graph = "<<end_graph<<std::endl; 1454 1263 1455 if (instantDataFilter || !hasExpression()) 1264 1456 ERROR("COutputPin* CField::getSelfReference(CGarbageCollector& gc)", 1265 1457 "Impossible to add a self reference to a field which has already been parsed or which does not have an expression."); 1458 1459 bool buildWorkflowGraph = (!build_workflow_graph.isEmpty() && build_workflow_graph == true); 1266 1460 1267 1461 if (!selfReferenceFilter) … … 1300 1494 } 1301 1495 1496 selfReferenceFilter->tag = buildWorkflowGraph; 1497 selfReferenceFilter->field = this; 1302 1498 return selfReferenceFilter; 1303 1499 } … … 1317 1513 { 1318 1514 std::map<CDuration, std::shared_ptr<COutputPin> >::iterator it = temporalDataFilters.find(outFreq); 1515 const bool buildWorkflowGraph = (!build_workflow_graph.isEmpty() && build_workflow_graph == true); 1516 1517 CContext* context = CContext::getCurrent(); 1518 1319 1519 1320 1520 if (it == temporalDataFilters.end()) … … 1332 1532 1333 1533 instantDataFilter->connectOutput(temporalFilter, 0); 1534 // temporalFilter->tag = buildWorkflowGraph; 1535 1536 temporalFilter->parent_filters.resize(1); 1537 temporalFilter->parent_filters[0] = instantDataFilter; 1538 1539 1540 if(temporalFilter->parent_filters[0]->tag) temporalFilter->tag=true; 1541 1542 // temporalFilter->start_graph = filter_start; 1543 // temporalFilter->end_graph = filter_end; 1544 temporalFilter->field = this; 1334 1545 1335 1546 it = temporalDataFilters.insert(std::make_pair(outFreq, temporalFilter)).first; … … 1367 1578 1368 1579 const bool detectMissingValues = (!detect_missing_value.isEmpty() && detect_missing_value == true); 1580 bool buildWorkflowGraph = (!build_workflow_graph.isEmpty() && build_workflow_graph == true); 1369 1581 std::shared_ptr<CTemporalFilter> temporalFilter(new CTemporalFilter(gc, operation, 1370 1371 1582 CContext::getCurrent()->getCalendar()->getInitDate(), 1583 freq_op, freq_offset, outFreq, detectMissingValues)); 1372 1584 1373 1585 selfReferenceFilter->connectOutput(temporalFilter, 0); 1586 temporalFilter->tag = buildWorkflowGraph; 1587 temporalFilter->field = this; 1588 1374 1589 return temporalFilter ; 1375 1590 } -
XIOS/trunk/src/node/field.hpp
r1637 r1704 7 7 #include "functor.hpp" 8 8 #include "functor_type.hpp" 9 #include "filter.hpp" 9 10 #include "duration.hpp" 10 11 #include "date.hpp" … … 139 140 void checkTimeAttributes(CDuration* freqOp=NULL); 140 141 141 void buildFilterGraph(CGarbageCollector& gc, bool enableOutput );142 void buildFilterGraph(CGarbageCollector& gc, bool enableOutput, Time start_graph=-1, Time end_graph=-1); 142 143 size_t getGlobalWrittenSize(void) ; 143 144 144 145 145 std::shared_ptr<COutputPin> getFieldReference(CGarbageCollector& gc );146 std::shared_ptr<COutputPin> getSelfReference(CGarbageCollector& gc );146 std::shared_ptr<COutputPin> getFieldReference(CGarbageCollector& gc, Time start_graph=-1, Time end_graph=-1); 147 std::shared_ptr<COutputPin> getSelfReference(CGarbageCollector& gc, Time start_graph=-1, Time end_graph=-1); 147 148 std::shared_ptr<COutputPin> getTemporalDataFilter(CGarbageCollector& gc, CDuration outFreq); 148 149 std::shared_ptr<COutputPin> getSelfTemporalDataFilter(CGarbageCollector& gc, CDuration outFreq); … … 243 244 bool hasTimeCentered; 244 245 246 Time field_graph_start; 247 Time field_graph_end; 248 245 249 246 250 DECLARE_REF_FUNC(Field,field)
Note: See TracChangeset
for help on using the changeset viewer.