Changeset 881 for XIOS


Ignore:
Timestamp:
07/04/16 19:21:28 (8 years ago)
Author:
oabramkina
Message:

Commit for UGRID norms: bad allocations have been taken care of.

Location:
XIOS/trunk/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/io/nc4_data_output.cpp

    r879 r881  
    5050      void CNc4DataOutput::writeDomain_(CDomain* domain) 
    5151      { 
    52          if (domain->type == CDomain::type_attr::unstructured) 
    53          { 
    54        if (SuperClassWriter::useCFConvention) 
    55         writeUnstructuredDomain(domain) ; 
    56       else 
    57         writeUnstructuredDomainUgrid(domain) ; 
    58            return ; 
    59          } 
     52        if (domain->type == CDomain::type_attr::unstructured) 
     53        { 
     54          if (SuperClassWriter::useCFConvention) 
     55            writeUnstructuredDomain(domain) ; 
     56          else 
     57            writeUnstructuredDomainUgrid(domain) ; 
     58          return ; 
     59        } 
    6060 
    6161         CContext* context = CContext::getCurrent() ; 
     
    6666 
    6767         if (domain->isEmpty()) 
    68            if (SuperClass::type==MULTI_FILE) return ; 
     68           if (SuperClass::type==MULTI_FILE) return; 
    6969 
    7070         std::vector<StdString> dim0, dim1; 
     
    449449      StdString domid = domain->getDomainOutputName(); 
    450450      StdString domainName = domain->name; 
    451  
    452       if (domain->mesh->isWritten(domainName)) domain->mesh = CMesh::getMesh; 
    453  
     451      domain->assignMesh(domainName); 
    454452      //domain->mesh->createMesh(domain->lonvalue_srv, domain->latvalue_srv, domain->bounds_lon_srv, domain->bounds_lat_srv); 
    455453      domain->mesh->createMeshEpsilon(domain->lonvalue_srv, domain->latvalue_srv, domain->bounds_lon_srv, domain->bounds_lat_srv); 
     
    650648              if (domain->nvertex == 1) 
    651649              { 
    652                                 if ( (!domain->mesh->edgesAreWritten) && (!domain->mesh->facesAreWritten) ) 
     650                if ( (!domain->mesh->edgesAreWritten) && (!domain->mesh->facesAreWritten) ) 
    653651                { 
    654652                  SuperClassWriter::writeData(domain->mesh->node_lat, node_y, isCollective, 0); 
     
    658656              if (domain->nvertex == 2) 
    659657              { 
    660                                 if (!domain->mesh->facesAreWritten) 
     658                if (!domain->mesh->facesAreWritten) 
    661659                { 
    662660                  if (!domain->mesh->nodesAreWritten) 
  • XIOS/trunk/src/node/domain.cpp

    r878 r881  
    3636      , isRedistributed_(false) 
    3737   { 
    38            mesh = new CMesh(); 
     38           //mesh = new CMesh(); 
    3939        } 
    4040 
     
    4747      , isRedistributed_(false) 
    4848   { 
    49            mesh = new CMesh(); 
     49           //mesh = new CMesh(); 
    5050        } 
    5151 
    5252   CDomain::~CDomain(void) 
    5353   { 
    54            delete mesh; 
     54           //delete mesh; 
    5555   } 
    5656 
    5757   ///--------------------------------------------------------------- 
     58 
     59   void CDomain::assignMesh(const StdString meshName) 
     60   { 
     61     mesh = CMesh::getMesh(meshName); 
     62   } 
    5863 
    5964   CDomain* CDomain::createDomain() 
  • XIOS/trunk/src/node/domain.hpp

    r878 r881  
    6767          
    6868         CMesh* mesh; 
     69         void assignMesh(const StdString); 
    6970         
    7071         virtual void parse(xml::CXMLNode & node); 
  • XIOS/trunk/src/node/mesh.cpp

    r879 r881  
    2626  } 
    2727 
    28   std::map <StdString, CMesh*> CMesh::meshList = std::map <StdString, CMesh*>(); 
    29   CMesh* CMesh::getMesh; 
     28  std::map <StdString, CMesh> CMesh::meshList = std::map <StdString, CMesh>(); 
     29  //CMesh* CMesh::getMesh; 
    3030 
    3131///--------------------------------------------------------------- 
    3232/*! 
    33  * \fn bool CMesh::isWritten (StdString meshName) 
    34  * Checks if a mesh has been written, updates the list of meshes stored in meshList 
     33 * \fn bool CMesh::getMesh (StdString meshName) 
     34 * Returns a pointer to a mesh. If a mesh has not been created, creates it and adds its name to the list of meshes meshList. 
    3535 * \param [in] meshName  The name of a mesh ("name" attribute of a domain). 
    3636 */ 
    37   bool CMesh::isWritten (StdString meshName) 
    38   { 
    39     if ( CMesh::meshList.begin() != CMesh::meshList.end() ) 
    40     { 
    41       if ( CMesh::meshList.find(meshName) != CMesh::meshList.end() ) 
    42       { 
    43         CMesh::getMesh = meshList[meshName]; 
    44         return true; 
    45       } 
    46       else 
    47       { 
    48         CMesh::meshList.insert( make_pair(meshName, this) ); 
    49         return false; 
    50       } 
    51     } 
    52     else 
    53     { 
    54       CMesh::meshList.insert( make_pair(meshName, this) ); 
    55       return false; 
    56     } 
     37  CMesh::CMesh* CMesh::getMesh (StdString meshName) 
     38  { 
     39    if ( CMesh::meshList.find(meshName) == CMesh::meshList.end() ) 
     40    { 
     41      CMesh::CMesh newMesh; 
     42      CMesh::meshList.insert( make_pair(meshName, newMesh) ); 
     43 
     44    } 
     45    return &meshList[meshName]; 
    5746  } 
    5847 
     
    7160 * Precision check is implemented with two hash values for each dimension, longitude and latitude. 
    7261 * \param [in] lon Node longitude in degrees. 
    73  * \param [in] lat Node latitude in degress ranged from 0 to 360. 
     62 * \param [in] lat Node latitude in degrees ranged from 0 to 360. 
    7463 * \return node index if a node exists; -1 otherwise 
    7564 */ 
     
    145134 * Creates two hash values for each dimension, longitude and latitude. 
    146135 * \param [in] lon Node longitude in degrees. 
    147  * \param [in] lat Node latitude in degress ranged from 0 to 360. 
     136 * \param [in] lat Node latitude in degrees ranged from 0 to 360. 
    148137 */ 
     138 
    149139  void hashDblDbl (double lon, double lat) 
    150140  { 
     
    217207 * \param [in] latvalue  Array of latitudes. 
    218208 * \param [in] bounds_lon Array of boundary longitudes. Its size depends on the element type. 
    219  * \param [in] bounds_lat Array of boundarry latitudes. Its size depends on the element type. 
     209 * \param [in] bounds_lat Array of boundary latitudes. Its size depends on the element type. 
    220210 */ 
    221211  void CMesh::createMesh(const CArray<double, 1>& lonvalue, const CArray<double, 1>& latvalue, 
     
    357347 * \param [in] latvalue  Array of latitudes. 
    358348 * \param [in] bounds_lon Array of boundary longitudes. Its size depends on the element type. 
    359  * \param [in] bounds_lat Array of boundarry latitudes. Its size depends on the element type. 
     349 * \param [in] bounds_lat Array of boundary latitudes. Its size depends on the element type. 
    360350 */ 
    361351  void CMesh::createMeshEpsilon(const CArray<double, 1>& lonvalue, const CArray<double, 1>& latvalue, 
  • XIOS/trunk/src/node/mesh.hpp

    r879 r881  
    99  
    1010#include "array_new.hpp" 
     11#include "client_client_dht_template.hpp" 
    1112 
    1213namespace xios { 
     
    5354            const CArray<double, 2>&, const CArray<double, 2>& ); 
    5455                         
    55       void createMeshEpsilon(const CArray<double, 1>&, const CArray<double, 1>&,  
     56      void createMeshEpsilon(const CArray<double, 1>&, const CArray<double, 1>&, 
    5657            const CArray<double, 2>&, const CArray<double, 2>& ); 
    5758             
    58       bool isWritten (StdString);     
    59       static CMesh* getMesh; 
    60            
    61        private: 
     59      static CMesh* getMesh(StdString); 
    6260 
    63       static std::map <StdString, CMesh*> meshList; 
     61    private: 
     62 
     63      static std::map <StdString, CMesh> meshList; 
    6464 
    6565      size_t nodeIndex (double, double);       
Note: See TracChangeset for help on using the changeset viewer.