Changeset 1172


Ignore:
Timestamp:
06/15/17 19:32:13 (4 years ago)
Author:
yushan
Message:

save dev. need to unify the file type when using EP

Location:
XIOS/dev/branch_yushan_merged
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/branch_yushan_merged/extern/remap/src/elt.hpp

    r1016 r1172  
    5353struct Elt : Polyg 
    5454{ 
    55         Elt() {} 
    56         Elt(const double *bounds_lon, const double *bounds_lat, int max_num_vert) 
    57         { 
    58                 int k = 0; 
    59                 vertex[k++] = xyz(bounds_lon[0], bounds_lat[0]); 
    60                 for (int i = 1; i < max_num_vert; i++) 
    61                 { 
    62                         vertex[k] = xyz(bounds_lon[i], bounds_lat[i]); 
    63                         /* netCDF convention: if first vertex repeats element is finished (at least three vertices == triagle) */ 
    64                         if (k >= 3 && squaredist(vertex[k], vertex[0]) < EPS*EPS)  
    65                                 break; 
    66                         /* eliminate zero edges: move to next vertex only if it is different */ 
    67                         if (squaredist(vertex[k], vertex[k-1]) > EPS*EPS) 
    68                                 k++; 
    69                         else 
    70                                 /* cout << "Removed edge " << k << " due to zero length (coinciding endpoints)." << endl */ ; 
    71                 } 
    72                 n = k; 
    73                 x = barycentre(vertex, n); 
    74         } 
     55  Elt() {} 
     56  Elt(const double *bounds_lon, const double *bounds_lat, int max_num_vert) 
     57  { 
     58    int k = 0; 
     59    vertex[k++] = xyz(bounds_lon[0], bounds_lat[0]); 
     60    for (int i = 1; i < max_num_vert; i++) 
     61    { 
     62      vertex[k] = xyz(bounds_lon[i], bounds_lat[i]); 
     63      /* netCDF convention: if first vertex repeats element is finished (at least three vertices == triagle) */ 
     64      if (k >= 3 && squaredist(vertex[k], vertex[0]) < EPS*EPS)  
     65        break; 
     66      /* eliminate zero edges: move to next vertex only if it is different */ 
     67      if (squaredist(vertex[k], vertex[k-1]) > EPS*EPS) 
     68        k++; 
     69      //else cout << "Removed edge " << k << " due to zero length (coinciding endpoints)." << endl ; 
     70    } 
     71    n = k; 
     72    x = barycentre(vertex, n); 
     73  } 
    7574 
    7675        Elt& operator=(const Elt& rhs) 
     
    9695        } 
    9796 
    98         void delete_intersections() 
    99         { 
    100                 for (list<Polyg*>::iterator it = this->is.begin(); it != this->is.end(); it++) 
    101                 { 
    102                         Polyg* poly = *it; 
    103                         delete poly; 
    104                 } 
    105         } 
     97  void delete_intersections() 
     98  { 
     99    for (list<Polyg*>::iterator it = this->is.begin(); it != this->is.end(); it++) 
     100    { 
     101      Polyg* poly = *it; 
     102      delete poly; 
     103    } 
     104  } 
    106105 
    107106  void insert_vertex(int i, const Coord& v) 
  • XIOS/dev/branch_yushan_merged/extern/remap/src/node.cpp

    r1155 r1172  
    472472        q->child.resize(MAX_NODE_SZ/2 + 1); 
    473473        assert(thIs->child.size() == MAX_NODE_SZ+1); 
    474         thIs->tree->ref = thIs->closest(thIs->child, FARTHEST); // farthest from centre 
     474        if(thIs->closest(thIs->child, FARTHEST) == 0)  
     475          thIs->tree->ref = thIs->closest(thIs->child, FARTHEST); // farthest from centre 
     476           
     477        thIs->tree->ref = thIs->closest(thIs->child, FARTHEST); // farthest from centre 
     478         
     479           
    475480        std::sort(thIs->child.begin(), thIs->child.end(), compareDist); 
    476481        for (int i = 0; i < MAX_NODE_SZ+1; i++) 
  • XIOS/dev/branch_yushan_merged/extern/remap/src/parallel_tree.cpp

    r1155 r1172  
    315315{ 
    316316 
    317         int assignLevel = 2; 
    318         int nbSampleNodes = 2*ipow(MAX_NODE_SZ + 1, assignLevel); 
     317  int assignLevel = 2; 
     318  int nbSampleNodes = 2*ipow(MAX_NODE_SZ + 1, assignLevel); 
    319319 
    320320 
     
    326326  MPI_Comm_size(communicator,&commSize) ; 
    327327   
    328         // make multiple of two 
    329         nbSampleNodes /= 2; 
    330         nbSampleNodes *= 2; 
    331 //  assert( nbTot > nbSampleNodes*commSize) ; 
     328  // make multiple of two 
     329  nbSampleNodes /= 2; 
     330  nbSampleNodes *= 2; 
     331  //assert( nbTot > nbSampleNodes*commSize) ; 
    332332     
    333333  int nbSampleNodes1 = nbSampleNodes * (nb1*commSize)/(1.*nbTot) ; 
     
    335335   
    336336 
    337 //      assert(node.size() > nbSampleNodes); 
    338 //      assert(node2.size() > nbSampleNodes); 
    339 //      assert(node.size() + node2.size() > nbSampleNodes); 
    340         vector<Node> sampleNodes; sampleNodes.reserve(nbSampleNodes1+nbSampleNodes2); 
    341  
    342         vector<int> randomArray1(node.size()); 
    343         randomizeArray(randomArray1); 
    344         vector<int> randomArray2(node2.size()); 
    345         randomizeArray(randomArray2); 
     337  //assert(node.size() > nbSampleNodes); 
     338  //assert(node2.size() > nbSampleNodes); 
     339  //assert(node.size() + node2.size() > nbSampleNodes); 
     340  vector<Node> sampleNodes; sampleNodes.reserve(nbSampleNodes1+nbSampleNodes2); 
     341 
     342  vector<int> randomArray1(node.size()); 
     343  randomizeArray(randomArray1); 
     344  vector<int> randomArray2(node2.size()); 
     345  randomizeArray(randomArray2); 
    346346 
    347347/*       
  • XIOS/dev/branch_yushan_merged/extern/remap/src/tree.cpp

    r1134 r1172  
    2929void CBasicTree::routeNodes(vector<int>& route, vector<Node>& nodes, int assignLevel) 
    3030{ 
    31         for (int i = 0; i < nodes.size(); i++) 
    32         { 
    33                 root->routeNode(&nodes[i], assignLevel); 
    34                 route[i] = nodes[i].route; 
    35         } 
     31  for (int i = 0; i < nodes.size(); i++) 
     32  { 
     33    root->routeNode(&nodes[i], assignLevel); 
     34    route[i] = nodes[i].route; 
     35  } 
    3636} 
    3737 
    3838void CBasicTree::routeIntersections(vector<vector<int> >& routes, vector<Node>& nodes) 
    3939{ 
    40         for (int i = 0; i < nodes.size(); i++) 
    41                 root->routeIntersection(routes[i], &nodes[i]); 
     40  for (int i = 0; i < nodes.size(); i++) 
     41    root->routeIntersection(routes[i], &nodes[i]); 
    4242} 
    4343 
    4444void CBasicTree::build(vector<Node>& nodes) 
    4545{ 
    46         newRoot(1); 
    47         insertNodes(nodes); 
     46  newRoot(1); 
     47  insertNodes(nodes); 
    4848} 
    4949 
    5050void CBasicTree::output(ostream& flux, int level) 
    5151{ 
    52         root->output(flux,level,0) ; 
     52  root->output(flux,level,0) ; 
    5353} 
    5454void CBasicTree::slim(int nbIts) 
    5555{ 
    56         for (int i = 0; i < nbIts; i++) 
    57         { 
    58                 for (int level = root->level - 1; level > 0; level--) 
    59                 { 
    60                         slim2(root, level); 
    61                         ri = 0; 
    62                         emptyPool(); 
    63                 } 
    64  
    65                 for (int level = 2; level < root->level; level++) 
    66                 { 
    67                         slim2(root, level); 
    68                         ri = 0; 
    69                         emptyPool(); 
    70                 } 
    71         } 
     56  for (int i = 0; i < nbIts; i++) 
     57  { 
     58    for (int level = root->level - 1; level > 0; level--) 
     59    { 
     60      slim2(root, level); 
     61      ri = 0; 
     62      emptyPool(); 
     63    } 
     64 
     65    for (int level = 2; level < root->level; level++) 
     66    { 
     67      slim2(root, level); 
     68      ri = 0; 
     69      emptyPool(); 
     70    } 
     71  } 
    7272} 
    7373 
     
    7676void CBasicTree::insertNode(NodePtr node) 
    7777{ 
    78         node->tree = this; 
    79         increaseLevelSize(0); 
    80         push_back(node); 
    81  
    82         NodePtr q; 
    83         while (pool.size()) 
    84         { 
    85                 q = pool.front(); 
    86                 pool.pop_front(); 
    87                 q = insert(q, root); 
    88                 if (ri) 
    89                 { 
    90                         delete q; 
    91                         ri = 0; 
    92                 } 
    93         } 
     78  node->tree = this; 
     79  increaseLevelSize(0); 
     80  push_back(node); 
     81 
     82  NodePtr q; 
     83  while (pool.size()) 
     84  { 
     85    q = pool.front(); 
     86    pool.pop_front(); 
     87    q = insert(q, root); 
     88    if (ri) 
     89    { 
     90      delete q; 
     91      ri = 0; 
     92    } 
     93  } 
    9494} 
    9595 
    9696void CBasicTree::emptyPool(void) 
    9797{ 
    98         while (pool.size()) 
    99         { 
    100                 NodePtr q = pool.front(); 
    101                 pool.pop_front(); 
    102                 q = insert(q, root); 
    103                 if (ri) 
    104                 { 
    105                         delete q; 
    106                         ri = 0; 
    107                 } 
    108         } 
     98  while (pool.size()) 
     99  { 
     100    NodePtr q = pool.front(); 
     101    pool.pop_front(); 
     102    q = insert(q, root); 
     103    if (ri) 
     104    { 
     105      delete q; 
     106      ri = 0; 
     107    } 
     108  } 
    109109} 
    110110 
  • XIOS/dev/branch_yushan_merged/extern/remap/src/tree.hpp

    r923 r1172  
    1414class CBasicTree 
    1515{ 
    16 public: 
     16  public: 
    1717 
    18         NodePtr root; /* The main tree is stored as Nodes which can be reached through traversal starting here */ 
    19         NodePtr ref; // FIXME this reference, set by a node is odd, try to remove 
    20         int ri; /** this is set to one by a node in case of reinsertion */ 
    21         vector<int> levelSize; /** e.g. levelSize[0] == leafs.size() */ 
    22         vector<Node> leafs; /** leafs are stored in vector for easy access and rest of the tree nodes as separate allocations, only reachable through tree traversal */ 
     18  NodePtr root; /* The main tree is stored as Nodes which can be reached through traversal starting here */ 
     19  NodePtr ref; // FIXME this reference, set by a node is odd, try to remove 
     20  int ri; /** this is set to one by a node in case of reinsertion */ 
     21  vector<int> levelSize; /** e.g. levelSize[0] == leafs.size() */ 
     22  vector<Node> leafs; /** leafs are stored in vector for easy access and rest of the tree nodes as separate allocations, only reachable through tree traversal */ 
    2323 
    24         CBasicTree() : ri(0), levelSize(MAX_LEVEL_SIZE), root(NULL), isAssignedLevel(false), okSplit(true), isActiveOkSplit(false) {}  
    25         ~CBasicTree();  
    26         void build(vector<Node>& nodes); 
    27         void slim(int nbIts = 1); 
    28         virtual void insertNodes(vector<Node>& node) = 0; 
     24  CBasicTree() : ri(0), levelSize(MAX_LEVEL_SIZE), root(NULL), isAssignedLevel(false), okSplit(true), isActiveOkSplit(false) {}  
     25  ~CBasicTree();  
     26  void build(vector<Node>& nodes); 
     27  void slim(int nbIts = 1); 
     28  virtual void insertNodes(vector<Node>& node) = 0; 
    2929 
    30         void routeNodes(vector<int>& route, vector<Node>& nodes, int assignLevel); 
    31         void routeIntersections(vector<vector<int> >& route, vector<Node>& nodes); 
     30  void routeNodes(vector<int>& route, vector<Node>& nodes, int assignLevel); 
     31  void routeIntersections(vector<vector<int> >& route, vector<Node>& nodes); 
    3232 
    33         void push_back(NodePtr node); 
    34         void push_front(NodePtr node); 
    35         void increaseLevelSize(int level); 
    36         void decreaseLevelSize(int level); 
    37         void newRoot(int level); 
    38         void insertNode(NodePtr node); 
     33  void push_back(NodePtr node); 
     34  void push_front(NodePtr node); 
     35  void increaseLevelSize(int level); 
     36  void decreaseLevelSize(int level); 
     37  void newRoot(int level); 
     38  void insertNode(NodePtr node); 
    3939  void output(ostream& flux, int level) ; 
    4040 
    41         int keepNodes; 
     41  int keepNodes; 
    4242  bool isAssignedLevel ;  
    4343  int assignLevel; 
     
    5050 
    5151   
    52 private: 
    53         deque<NodePtr > pool; 
     52  private: 
     53  deque<NodePtr > pool; 
    5454         
    5555  bool okSplit ; 
    5656  
    57 protected: 
     57  protected: 
    5858  void emptyPool(); 
    59   CBasicTree(int keepNodes_, int assignLevel_) : ri(0), levelSize(MAX_LEVEL_SIZE), root(NULL), keepNodes(keepNodes_), assignLevel(assignLevel_), isAssignedLevel(true), okSplit(true), isActiveOkSplit(false) {}  
     59  CBasicTree(int keepNodes_, int assignLevel_) : ri(0), levelSize(MAX_LEVEL_SIZE), root(NULL), keepNodes(keepNodes_), assignLevel(assignLevel_), isAssignedLevel(true),  
     60                                                 okSplit(true), isActiveOkSplit(false) {}  
    6061}; 
    6162 
    6263class CTree : public CBasicTree 
    6364{ 
    64 public: 
    65         void insertNodes(vector<Node>& nodes); 
     65  public: 
     66  void insertNodes(vector<Node>& nodes); 
    6667}; 
    6768 
     
    6970{ 
    7071 
    71 public: 
    72         CSampleTree(int keepNodes_, int assignLevel_) : CBasicTree(keepNodes_,assignLevel_) {} 
     72  public: 
     73  CSampleTree(int keepNodes_, int assignLevel_) : CBasicTree(keepNodes_,assignLevel_) {} 
    7374  void slimAssignedLevel() ; 
    7475  void removeExtraNode(void) ; 
    75         void insertNodes(vector<Node>& nodes); 
     76  void insertNodes(vector<Node>& nodes); 
    7677}; 
    7778 
  • XIOS/dev/branch_yushan_merged/inputs/REMAP/iodef.xml

    r1164 r1172  
    3434 
    3535   <file_definition type="one_file" par_access="collective" output_freq="1ts" output_level="10" enabled=".TRUE."> 
     36       
     37      <file_group id="read_then_write_files" enabled=".TRUE."> 
     38       <file id="output_regular_pole" name="output_dst_regular" > 
     39          <field field_ref="tmp_field_0" name="field_regular_0" enabled=".TRUE."/> 
     40          <field field_ref="dst_field_regular" name="field_regular" enabled=".TRUE."/> 
     41          <field field_ref="dst_field_regular_pole_0" name="field_regular_pole_0" enabled=".FALSE." /> 
     42          <field field_ref="dst_field_regular_pole_1" name="field_regular_pole_1" enabled=".FALSE." /> 
     43       </file> 
     44       <file id="output_dst_curvilinear" name="output_dst_curvilinear" enabled=".TRUE." > 
     45          <field field_ref="tmp_field_1" operation="instant"/> 
     46       </file> 
     47       <file id="output_dst_unstructured" name="output_dst_unstructured" enabled=".TRUE." > 
     48          <field field_ref="tmp_field_2" operation="instant"/> 
     49       </file> 
     50     </file_group> 
     51 
    3652      <file_group id="write_files" > 
    37         <file id="output_2D" name="output_2D" > 
     53        <file id="output_2D" name="output_2D" enabled=".TRUE."> 
    3854          <field field_ref="src_field_2D" name="field_src" /> 
    3955          <field field_ref="src_field_2D_clone" name="field_src_clone" default_value="100000" /> 
     
    4460          <field field_ref="dst_field_2D_extract" name="field_dst_regular_4" /> 
    4561        </file>  
    46        <file id="output_3D" name="output_3D" enabled=".TRUE." > 
     62       <file id="output_3D" name="output_3D" enabled=".TRUE."> 
    4763          <field field_ref="src_field_3D" name="field_src" /> 
    4864          <field field_ref="src_field_3D_pression" name="field" /> 
     
    6682       </file> 
    6783      </file_group> 
    68      <file_group id="read_then_write_files" enabled=".TRUE."> 
    69        <file id="output_regular_pole" name="output_dst_regular" > 
    70           <field field_ref="tmp_field_0" name="field_regular_0" /> 
    71           <field field_ref="dst_field_regular" name="field_regular" /> 
    72           <field field_ref="dst_field_regular_pole_0" name="field_regular_pole_0" enabled=".FALSE." /> 
    73           <field field_ref="dst_field_regular_pole_1" name="field_regular_pole_1" enabled=".FALSE." /> 
    74        </file> 
    75        <file id="output_dst_curvilinear" name="output_dst_curvilinear"> 
    76           <field field_ref="tmp_field_1" operation="instant"/> 
    77        </file> 
    78        <file id="output_dst_unstructured" name="output_dst_unstructured" > 
    79           <field field_ref="tmp_field_2" operation="instant"/> 
    80        </file> 
    81      </file_group> 
     84      
    8285   </file_definition> 
    8386 
  • XIOS/dev/branch_yushan_merged/src/client_client_dht_template_impl.hpp

    r1164 r1172  
    718718    MPI_Irecv(&recvBuff[0]+2*idx, 2, MPI_INT, 
    719719              recvRank[idx], MPI_DHT_INDEX_0, this->internalComm_, &request[nRequest]); 
    720     printf("proc %d recv from proc %d with tag %d\n", my_rank, recvRank[idx], MPI_DHT_INDEX_0);           
    721720    ++nRequest; 
    722721  } 
     
    735734    MPI_Isend(&sendBuff[idx*2], 2, MPI_INT, 
    736735              sendRank[idx], MPI_DHT_INDEX_0, this->internalComm_, &request[nRequest]); 
    737     printf("proc %d send to proc %d with tag %d\n", my_rank, sendRank[idx], MPI_DHT_INDEX_0); 
    738736    ++nRequest; 
    739737  } 
  • XIOS/dev/branch_yushan_merged/src/io/inetcdf4.cpp

    r1138 r1172  
    2121        comm = NULL; 
    2222    } 
     23 
    2324    mpi = comm && !multifile; 
    2425    MPI_Info m_info = MPI_INFO_NULL_STD; 
  • XIOS/dev/branch_yushan_merged/src/io/nc4_data_input.cpp

    r1138 r1172  
    5555    CArray<double,1> fieldData(grid->getWrittenDataSize()); 
    5656    if (!field->default_value.isEmpty()) fieldData = field->default_value; 
    57  
     57    #ifdef _usingEP 
     58    SuperClass::type = ONE_FILE; 
     59    //printf("SuperClass::type = %d\n", SuperClass::type); 
     60    #endif 
    5861    switch (SuperClass::type) 
    5962    { 
  • XIOS/dev/branch_yushan_merged/src/io/nc4_data_output.cpp

    r1160 r1172  
    11021102 
    11031103            SuperClassWriter::definition_end(); 
    1104  
     1104            printf("SuperClass::type = %d\n", SuperClass::type); 
    11051105            switch (SuperClass::type) 
    11061106            { 
  • XIOS/dev/branch_yushan_merged/src/node/file.cpp

    r1160 r1172  
    579579 
    580580      #ifdef _usingEP 
    581       if(omp_get_num_threads() != 1 ) multifile = true; 
    582       #endif 
    583  
     581      //printf("multifile was %d\n", multifile); 
     582      multifile = true; 
    584583      if (isOpen) data_out->closeFile(); 
    585584      if (time_counter_name.isEmpty()) data_in = shared_ptr<CDataInput>(new CNc4DataInput(oss.str(), static_cast< ::MPI_Comm >(fileComm.mpi_comm), multifile, isCollective)); 
    586585      else data_in = shared_ptr<CDataInput>(new CNc4DataInput(oss.str(), static_cast< ::MPI_Comm >(fileComm.mpi_comm), multifile, isCollective, time_counter_name)); 
    587586      isOpen = true; 
     587      #else 
     588      if (isOpen) data_out->closeFile(); 
     589      if (time_counter_name.isEmpty()) data_in = shared_ptr<CDataInput>(new CNc4DataInput(oss.str(), static_cast< ::MPI_Comm >(fileComm.mpi_comm), multifile, isCollective)); 
     590      else data_in = shared_ptr<CDataInput>(new CNc4DataInput(oss.str(), static_cast< ::MPI_Comm >(fileComm.mpi_comm), multifile, isCollective, time_counter_name)); 
     591      isOpen = true; 
     592      #endif 
     593 
     594       
    588595    } 
    589596  } 
Note: See TracChangeset for help on using the changeset viewer.