Changeset 1877


Ignore:
Timestamp:
05/13/20 16:46:00 (4 years ago)
Author:
yushan
Message:

trunk : each context has its own graph file

Location:
XIOS/trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/inputs/COMPLETE/context_atmosphere.xml

    r1876 r1877  
    1010  <file_definition type="one_file" par_access="collective" output_freq="6h" sync_freq="6h" output_level="10" enabled=".TRUE."> 
    1111    <file id="output_atmosphere" name="output_atmosphere"> 
    12       <field field_ref="field_A_atm" /> 
     12      <field field_ref="field_A_atm" build_workflow_graph="true"/> 
    1313    </file> 
    1414    <file id="output_atmosphere_zoom" name="output_atmosphere_zoom"> 
    15       <field field_ref="field_A_atm_zoom" name="field_A_atm_zoom" /> 
     15      <field field_ref="field_A_atm_zoom" name="field_A_atm_zoom" build_workflow_graph="true"/> 
    1616    </file> 
    1717  </file_definition> 
  • XIOS/trunk/inputs/COMPLETE/context_surface.xml

    r1876 r1877  
    2222      <field field_ref="field_A_srf_K" build_workflow_graph="false" /> 
    2323      <field field_ref="field_A_srf_K_2" name="field_A_srf_K_2" /> <!-- Should be identical to field_A_srf_K --> 
    24       <field field_ref="field_A_srf_K" name="field_A_srf_K_3" build_workflow_graph="true"> field_A_srf_K</field> <!-- Should be identical to field_A_srf_K --> 
     24      <field field_ref="field_A_srf_K" name="field_A_srf_K_3" build_workflow_graph="true"/> <!-- Should be identical to field_A_srf_K --> 
    2525      <field field_ref="field_A_srf_K_2" name="field_A_srf_K_max_mean" long_name="Maximum of hourly average over 6h" operation="maximum" freq_op="1h"> @field_A_srf_K </field> 
    2626      <field field_ref="field_A_srf" name="field_A_srf_min" operation="minimum" /> 
  • XIOS/trunk/inputs/iodef.xml

    r1876 r1877  
    2020   <file_definition type="one_file" par_access="collective" output_freq="1h" output_level="10" > 
    2121       
    22      <file id="test_output" output_freq="4h" enabled=".TRUE." > 
    23        <field field_ref="field_A"                        name ="field_A" build_workflow_graph=".FALSE." enabled=".FALSE."/> 
    24        <field field_ref="test_field_B"                   name ="field_B" build_workflow_graph=".FALSE." enabled=".TRUE."/> 
     22     <file id="test_output" name = "output" output_freq="4h" enabled=".TRUE." > 
     23       <field field_ref="field_A"                        name ="field_A" build_workflow_graph=".TRUE." enabled=".TRUE."/> 
     24       <field field_ref="test_field_B"                   name ="field_B" build_workflow_graph=".TRUE." enabled=".TRUE."/> 
    2525       <field id="test_field_C" field_ref="test_field_B" name ="field_C" build_workflow_graph=".TRUE."  enabled=".TRUE."  > 10*test_field_B </field> 
    26        <field id="test_field_D" field_ref="test_field_B" name ="field_D" build_workflow_graph=".TRUE."  enabled=".FALSE." > 100*field_A </field> 
    27        <field id="test_field_E" field_ref="test_field_B" name ="field_E" build_workflow_graph=".TRUE."  enabled=".FALSE." > field_A+10*test_field_B-field_C </field> 
     26       <field id="test_field_D" field_ref="test_field_B" name ="field_D" build_workflow_graph=".TRUE."  enabled=".TRUE." > 100*field_A </field> 
     27       <field id="test_field_E" field_ref="test_field_B" name ="field_E" build_workflow_graph=".TRUE."  enabled=".TRUE." > field_A+10*test_field_B-field_C </field> 
    2828     </file> 
    2929 
  • XIOS/trunk/src/filter/file_writer_filter.cpp

    r1704 r1877  
    3030      namestring.erase(0, 6); 
    3131      namestring.erase(namestring.length()-1, 1); 
    32  
    33       CWorkflowGraph::addNode(this->filterID, namestring + "\\n("+this->field->file->getId()+".nc)", 6, 0, 1, data[0]); 
     32       
     33      CWorkflowGraph::addNode(this->filterID, namestring + "\\n(file ID : "+this->field->file->getId()+")", 6, 0, 1, data[0]); 
    3434 
    3535      (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].attributes = this->field->record4graphXiosAttributes(); 
  • XIOS/trunk/src/filter/source_filter.cpp

    r1876 r1877  
    4141      packet->distance = 1; 
    4242       
    43      
    4443      CWorkflowGraph::allocNodeEdge(); 
    45  
     44       
    4645      CWorkflowGraph::addNode(this->filterID, "Source Filter ", 1, 1, 0, packet); 
    4746      (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].attributes = this->field->record4graphXiosAttributes(); 
  • XIOS/trunk/src/graphviz.cpp

    r1704 r1877  
    5555 
    5656      boost::write_graphviz(file, g, 
    57           boost::make_label_writer(&nodes[0]), 
    58           boost::make_label_writer(get(edge_name, g)), 
    59           boost::make_graph_attributes_writer(graph_attr, vertex_attr, edge_attr)); 
     57      boost::make_label_writer(&nodes[0]), 
     58      boost::make_label_writer(get(edge_name, g)), 
     59      boost::make_graph_attributes_writer(graph_attr, vertex_attr, edge_attr)); 
    6060          
    6161    } 
     
    7272    { 
    7373      CWorkflowGraph::buildStaticWorkflow_with_info(); 
     74      int nbGraphContext = CWorkflowGraph::mapContext_ptr->size(); 
    7475 
    7576      StdString color_table[7] = {"black", "red", "blue", "green", "purple", "yellow", "gray"}; 
    7677     
    77       std::ofstream fs_json; 
    78       fs_json.open ("graph_data.json", std::fstream::out); 
     78      std::ofstream fs_json[nbGraphContext]; 
     79       
     80      for (std::unordered_map<StdString, int>::const_iterator it = CWorkflowGraph::mapContext_ptr->begin(); it != CWorkflowGraph::mapContext_ptr->end(); ++it)  
     81      { 
     82        fs_json[it->second].open ("graph_data_"+it->first+".json", std::fstream::out); 
     83        fs_json[it->second] << "{\"nodes\":["<<std::endl<<"      "; 
     84      } 
    7985 
    80       fs_json << "{\"nodes\":["<<std::endl<<"      "; 
    81       static bool firstnode=true; 
    82       static bool firstedge=true; 
    83      
     86      static bool firstnodes[5]; 
     87      static bool firstedges[5]; 
     88 
     89      for(int i=0; i<nbGraphContext; i++) 
     90      { 
     91        firstnodes[i]=true; 
     92        firstedges[i]=true; 
     93      } 
     94 
    8495      for (auto it=CWorkflowGraph::mapFilters_ptr_with_info->begin(); it != CWorkflowGraph::mapFilters_ptr_with_info->end(); it++) 
    8596      { 
    86         if(firstnode)  
     97        int index = (*CWorkflowGraph::mapContext_ptr)[it->second.node_context_id]; 
     98        if(firstnodes[index])  
    8799        { 
    88           fs_json << "{\"id\": "<<it->first +1<<", "<<std::endl; 
    89           firstnode = false; 
     100          fs_json[index] << "{\"id\": "<<it->first +1<<", "<<std::endl; 
     101          firstnodes[index] = false; 
    90102        } 
    91103        else 
    92104        { 
    93           fs_json << ",{\"id\": "<<it->first +1<<", "<<std::endl; 
     105          fs_json[index] << ",{\"id\": "<<it->first +1<<", "<<std::endl; 
    94106        } 
    95107        if(it->second.filter_class == 1) // source filter 
    96           fs_json << "       \"label\": \""<<it->second.filter_name<<"\\n("<<it->second.field_id<<")\", "<<std::endl; 
     108          fs_json[index] << "       \"label\": \""<<it->second.filter_name<<"\\n("<<it->second.field_id<<")\", "<<std::endl; 
    97109        else 
    98           fs_json << "       \"label\": \""<<it->second.filter_name<<"\", "<<std::endl; 
    99         fs_json << "       \"class\": "<<it->second.filter_class<<", "<<std::endl; 
    100         fs_json << "       \"filled\": "<<it->second.filter_filled<<", "<<std::endl; 
    101         fs_json << "       \"type\": \""<<it->second.transform_type<<"\", "<<std::endl; 
    102         fs_json << "       \"entry\": "<<it->second.expected_entry_nb<<", "<<std::endl; 
    103         fs_json << "       \"inputs\": "<<it->second.inputs_complete<<", "<<std::endl; 
    104         fs_json << "       \"tag\": "<<it->second.filter_tag<<", "<<std::endl; 
    105         fs_json << "       \"cid\": "<<it->second.clusterID<<", "<<std::endl; 
    106         fs_json << "       \"distance\": "<<it->second.distance<<", "<<std::endl; 
    107         fs_json << "       \"attributes\": \""<<it->second.attributes<<"\"}"<<std::endl<<"      "; 
     110          fs_json[index] << "       \"label\": \""<<it->second.filter_name<<"\", "<<std::endl; 
     111        fs_json[index] << "       \"class\": "<<it->second.filter_class<<", "<<std::endl; 
     112        fs_json[index] << "       \"filled\": "<<it->second.filter_filled<<", "<<std::endl; 
     113        fs_json[index] << "       \"type\": \""<<it->second.transform_type<<"\", "<<std::endl; 
     114        fs_json[index] << "       \"entry\": "<<it->second.expected_entry_nb<<", "<<std::endl; 
     115        fs_json[index] << "       \"inputs\": "<<it->second.inputs_complete<<", "<<std::endl; 
     116        fs_json[index] << "       \"tag\": "<<it->second.filter_tag<<", "<<std::endl; 
     117        fs_json[index] << "       \"cid\": "<<it->second.clusterID<<", "<<std::endl; 
     118        fs_json[index] << "       \"distance\": "<<it->second.distance<<", "<<std::endl; 
     119        fs_json[index] << "       \"context\": \""<<it->second.node_context_id<<"\", "<<std::endl; 
     120        fs_json[index] << "       \"attributes\": \""<<it->second.attributes<<"\"}"<<std::endl<<"       "; 
    108121      } 
    109       fs_json << "    ],"<<std::endl; 
    110  
    111  
    112       fs_json << " \"edges\" : ["<<std::endl<<"      "; 
     122      for(int i=0; i<nbGraphContext; i++)  
     123      { 
     124        fs_json[i] << "    ],"<<std::endl; 
     125        fs_json[i] << " \"edges\" : ["<<std::endl<<"      "; 
     126      } 
    113127 
    114128      for (auto it=CWorkflowGraph::mapFieldToFilters_ptr_with_info->begin(); it != CWorkflowGraph::mapFieldToFilters_ptr_with_info->end(); it++) 
    115129      { 
    116         if(firstedge) 
     130        int index = (*CWorkflowGraph::mapContext_ptr)[it->second.edge_context_id]; 
     131        if(firstedges[index]) 
    117132        { 
    118           fs_json << "{\"id\": "<<it->first +1<<", "<<std::endl; 
    119           firstedge = false; 
     133          fs_json[index] << "{\"id\": "<<it->first +1<<", "<<std::endl; 
     134          firstedges[index] = false; 
    120135        } 
    121136        else 
    122137        { 
    123           fs_json << ",{\"id\": "<<it->first +1<<", "<<std::endl; 
     138          fs_json[index] << ",{\"id\": "<<it->first +1<<", "<<std::endl; 
    124139        } 
    125         fs_json << "       \"from\": "<<it->second.from+1<<", "<<std::endl; 
    126         fs_json << "       \"to\": "<<it->second.to+1<<", "<<std::endl; 
    127         fs_json << "       \"label\": \""<<it->second.field_id<<"\\n"<<it->second.date<<"\", "<<std::endl; 
     140        fs_json[index] << "       \"from\": "<<it->second.from+1<<", "<<std::endl; 
     141        fs_json[index] << "       \"to\": "<<it->second.to+1<<", "<<std::endl; 
     142        fs_json[index] << "       \"label\": \""<<it->second.field_id<<"\\n"<<it->second.date<<"\", "<<std::endl; 
    128143        // fs_json << "       \"title\": \""<<"Show more information about this field"<<"\", "<<std::endl; 
    129144        // fs_json << "       \"fid\": \""<<it->second.field_id<<"\", "<<std::endl; 
    130145        // fs_json << "       \"fname\": \""<<it->second.field_name<<"\", "<<std::endl; 
    131146        // fs_json << "       \"gid\": \""<<it->second.grid_id<<"\", "<<std::endl; 
    132         fs_json << "       \"date\": \""<<it->second.date<<"\", "<<std::endl; 
    133         fs_json << "       \"attributes\": \"id = "<<it->second.field_id<<"</br>"<<it->second.attributes<<"\"}"<<std::endl<<"      "; 
    134  
     147        fs_json[index] << "       \"date\": \""<<it->second.date<<"\", "<<std::endl; 
     148        fs_json[index] << "       \"context\": \""<<it->second.edge_context_id<<"\", "<<std::endl; 
     149        fs_json[index] << "       \"attributes\": \"id = "<<it->second.field_id<<"</br>"<<it->second.attributes<<"\"}"<<std::endl<<"       "; 
    135150      } 
    136       fs_json << "    ]}"<<std::endl; 
    137  
    138       fs_json.close(); 
     151      for(int i=0; i<nbGraphContext; i++) 
     152      { 
     153        fs_json[i] << "    ]}"<<std::endl; 
     154        fs_json[i].close(); 
     155      } 
    139156    } 
    140157  } 
  • XIOS/trunk/src/workflow_graph.cpp

    r1704 r1877  
    99 
    1010  std::unordered_map <size_t, int> *CWorkflowGraph::mapHashFilterID_ptr = 0; 
     11   
     12  std::unordered_map <StdString, int > *CWorkflowGraph::mapContext_ptr = 0; 
    1113 
    1214 
     
    125127  TRY 
    126128  { 
     129    if(!mapContext_ptr) mapContext_ptr = new std::unordered_map<StdString, int>; 
     130    std::string current_context_id = CContext::getCurrent()->getId(); 
     131    std::unordered_map<StdString,int>::const_iterator found = mapContext_ptr->find(current_context_id); 
     132    if (found == mapContext_ptr->end()) 
     133    { 
     134      std::pair<StdString, int> mypair (current_context_id, mapContext_ptr->size()); 
     135      mapContext_ptr->insert(mypair); 
     136    } 
     137 
    127138    (*mapFilters_ptr_with_info)[nodeID].filter_name = filterName; 
    128139    (*mapFilters_ptr_with_info)[nodeID].filter_class = filterClass; 
     
    131142    (*mapFilters_ptr_with_info)[nodeID].date = packet->date; 
    132143    (*mapFilters_ptr_with_info)[nodeID].timestamp = packet->timestamp; 
     144    (*mapFilters_ptr_with_info)[nodeID].node_context_id = CContext::getCurrent()->getId(); 
    133145  } 
    134146  CATCH 
     
    139151  TRY 
    140152  { 
     153    std::string current_context_id = CContext::getCurrent()->getId(); 
    141154    (*mapFieldToFilters_ptr_with_info)[edgeID].from = packet->src_filterID; 
    142155    (*mapFieldToFilters_ptr_with_info)[edgeID].to = toID; 
     
    148161    (*mapFieldToFilters_ptr_with_info)[edgeID].field = packet->field; 
    149162    (*mapFieldToFilters_ptr_with_info)[edgeID].attributes = packet->field->record4graphXiosAttributes(); 
     163    (*mapFieldToFilters_ptr_with_info)[edgeID].edge_context_id = CContext::getCurrent()->getId(); 
    150164  } 
    151165  CATCH 
  • XIOS/trunk/src/workflow_graph.hpp

    r1704 r1877  
    88#include "date.hpp" 
    99#include "duration.hpp" 
    10  
     10#include "context.hpp" 
    1111 
    1212namespace xios 
     
    3030    int clusterID; 
    3131    int distance; 
     32    StdString node_context_id; 
    3233  }; 
    3334 
     
    4344    CField *field; 
    4445    StdString attributes; 
    45      
     46    StdString edge_context_id; 
    4647  }; 
    4748 
     
    6869 
    6970      static std::unordered_map <size_t, int> *mapHashFilterID_ptr; 
     71       
     72      static std::unordered_map <StdString, int> *mapContext_ptr; 
    7073 
    7174 
Note: See TracChangeset for help on using the changeset viewer.