Changeset 2387


Ignore:
Timestamp:
07/26/22 17:14:27 (22 months ago)
Author:
jderouillat
Message:

Extend domain name management using hash table to unstructured domain.

File:
1 edited

Legend:

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

    r2386 r2387  
    5858        StdString lonName,latName ; 
    5959 
     60        // Check that the name associated to the current element is not in conflict with an existing element (due to CGrid::duplicateSentGrid) 
     61        if (!domain->lonvalue.isEmpty() ) 
     62        { 
     63          // The hash of the element will be associated to the default element name (= map key), and to the name really written 
     64          int globalHash = domain->computeAttributesHash( comm_file ); // Need a MPI_Comm to distribute without redundancy some attributs (value) 
     65         
     66          StdString defaultNameKey = domain->getDomainOutputName(); 
     67          if ( !relDomains_.count ( defaultNameKey ) ) 
     68          { 
     69            // if defaultNameKey not in the map, write the element such as it is defined 
     70            relDomains_.insert( make_pair( defaultNameKey, make_pair(globalHash, domain) ) ); 
     71          } 
     72          else // look if a hash associated this key is equal 
     73          { 
     74            bool elementIsInMap(false); 
     75            auto defaultNameKeyElements = relDomains_.equal_range( defaultNameKey ); 
     76            for (auto it = defaultNameKeyElements.first; it != defaultNameKeyElements.second; it++) 
     77            { 
     78              if ( it->second.first == globalHash ) 
     79              { 
     80                // if yes, associate the same ids to current element 
     81                domain->name = it->second.second->getDomainOutputName(); 
     82                domain->lon_name = it->second.second->lon_name; 
     83                domain->lat_name = it->second.second->lat_name; 
     84                if (domain->type == CDomain::type_attr::unstructured) 
     85                { 
     86                  domain->dim_i_name = it->second.second->dim_i_name; 
     87                  domain->dim_j_name = it->second.second->dim_j_name; 
     88                } 
     89                elementIsInMap = true; 
     90              } 
     91            } 
     92            // if no : inheritance has been excessive, define new names and store it (could be used by another grid) 
     93            if (!elementIsInMap)  // ! in MAP 
     94            { 
     95              domain->name =  domain->getId(); 
     96              domain->lon_name = "lon_"+domain->getId(); 
     97              domain->lat_name = "lat_"+domain->getId(); 
     98              if (domain->type == CDomain::type_attr::unstructured) 
     99              { 
     100                domain->dim_i_name = "cell_"+domain->getId(); 
     101                domain->dim_j_name = "nvertex_"+domain->getId(); 
     102              } 
     103              relDomains_.insert( make_pair( defaultNameKey, make_pair(globalHash, domain) ) ) ;          
     104            } 
     105          } 
     106        } 
     107 
    60108        if (domain->type == CDomain::type_attr::unstructured) 
    61109        { 
     
    73121         if (domain->isEmpty()) 
    74122           if (SuperClass::type==MULTI_FILE) return; 
    75  
    76  
    77          // Check that the name associated to the current element is not in conflict with an existing element (due to CGrid::duplicateSentGrid) 
    78          if (!domain->lonvalue.isEmpty() ) 
    79          { 
    80            // The hash of the element will be associated to the default element name (= map key), and to the name really written 
    81            int globalHash = domain->computeAttributesHash( comm_file ); // Need a MPI_Comm to distribute without redundancy some attributs (value) 
    82  
    83            StdString defaultNameKey = domain->getDomainOutputName(); 
    84            if ( !relDomains_.count ( defaultNameKey ) ) 
    85            { 
    86              // if defaultNameKey not in the map, write the element such as it is defined 
    87              relDomains_.insert( make_pair( defaultNameKey, make_pair(globalHash, domain) ) ); 
    88            } 
    89            else // look if a hash associated this key is equal 
    90            { 
    91              bool elementIsInMap(false); 
    92              auto defaultNameKeyElements = relDomains_.equal_range( defaultNameKey ); 
    93              for (auto it = defaultNameKeyElements.first; it != defaultNameKeyElements.second; it++) 
    94              { 
    95                if ( it->second.first == globalHash ) 
    96                { 
    97                  // if yes, associate the same ids to current element 
    98                  domain->name = it->second.second->getDomainOutputName(); 
    99                  domain->lon_name = it->second.second->lon_name; 
    100                  domain->lat_name = it->second.second->lat_name; 
    101                  elementIsInMap = true; 
    102                } 
    103              } 
    104              // if no : inheritance has been excessive, define new names and store it (could be used by another grid) 
    105              if (!elementIsInMap)  // ! in MAP 
    106              { 
    107                domain->name =  domain->getId(); 
    108                domain->lon_name = "lon_"+domain->getId(); 
    109                domain->lat_name = "lat_"+domain->getId(); 
    110                relDomains_.insert( make_pair( defaultNameKey, make_pair(globalHash, domain) ) ) ;          
    111              } 
    112            } 
    113          } 
    114123 
    115124          
     
    857866         else cellName="cell"; 
    858867         StdString dimXid = cellName+appendDomid; 
    859          StdString dimVertId = StdString("nvertex").append(appendDomid); 
     868         StdString dimVertId; 
     869         if (!domain->dim_j_name.isEmpty()) dimVertId=domain->dim_j_name; 
     870         else dimVertId = StdString("nvertex").append(appendDomid); 
    860871 
    861872         string lonid,latid,bounds_lonid,bounds_latid ; 
Note: See TracChangeset for help on using the changeset viewer.