Ignore:
Timestamp:
07/26/22 15:26:52 (2 years ago)
Author:
jderouillat
Message:

Set the code structure to compute the hash value of an element based on its attributs, use for now before writing an element in a file

File:
1 edited

Legend:

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

    r2385 r2386  
    7878         if (!domain->lonvalue.isEmpty() ) 
    7979         { 
    80            int globalSize = domain->ni_glo.getValue()*domain->nj_glo.getValue(); 
    81            CArray<size_t,1> globalIndex; // No redundancy globalIndex will be computed with the connector 
    82            shared_ptr<CGridTransformConnector> gridTransformConnector; 
    83            // Compute a without redundancy element FULL view to enable a consistent hash computation 
    84            domain->getLocalView(CElementView::FULL)->createWithoutRedundancyFullViewConnector( globalSize, comm_file, gridTransformConnector, globalIndex ); 
    85            int localSize = globalIndex.numElements(); 
    86             
    87            CArray<double,1> lon_distributedValue, lat_distributedValue ; 
    88            gridTransformConnector->transfer(domain->lonvalue, lon_distributedValue ); 
    89            gridTransformConnector->transfer(domain->latvalue, lat_distributedValue ); 
    90  
    91            // Compute the distributed hash (v0) of the element 
    92            // it will be associated to the default element name (= map key), and to the name really written 
    93            int localHash = 0; 
    94            for (int iloc=0; iloc<localSize ; iloc++ ) localHash+=globalIndex(iloc)*lon_distributedValue(iloc)*lat_distributedValue(iloc); 
    95            int globalHash(0); 
    96            MPI_Allreduce( &localHash, &globalHash, 1, MPI_INT, MPI_SUM, comm_file  ); 
    97           
     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 
    9883           StdString defaultNameKey = domain->getDomainOutputName(); 
    9984           if ( !relDomains_.count ( defaultNameKey ) ) 
     
    10561041        if (!axis->value.isEmpty() ) 
    10571042        { 
    1058            int globalSize = axis->n_glo.getValue(); 
    1059            CArray<size_t,1> globalIndex; // No redundancy globalIndex will be computed with the connector 
    1060            shared_ptr<CGridTransformConnector> gridTransformConnector; 
    1061            // Compute a without redundancy element FULL view to enable a consistent hash computation 
    1062            axis->getLocalView(CElementView::FULL)->createWithoutRedundancyFullViewConnector( globalSize, comm_file, gridTransformConnector, globalIndex ); 
    1063            int localSize = globalIndex.numElements(); 
    1064  
    1065           CArray<double,1> distributedValue ; 
    1066           gridTransformConnector->transfer(axis->value, distributedValue ); 
    1067          
    1068           // Compute the distributed hash (v0) of the element 
    1069           // it will be associated to the default element name (= map key), and to the name really written 
    1070           int localHash = 0; 
    1071           for (int iloc=0; iloc<localSize ; iloc++ ) localHash+=globalIndex(iloc)*distributedValue(iloc); 
    1072           int globalHash(0); 
    1073           MPI_Allreduce( &localHash, &globalHash, 1, MPI_INT, MPI_SUM, comm_file  ); 
     1043          // The hash of the element will be associated to the default element name (= map key), and to the name really written 
     1044          int globalHash = axis->computeAttributesHash( comm_file ); // Need a MPI_Comm to distribute without redundancy some attributs (value) 
    10741045 
    10751046          StdString defaultNameKey = axis->getAxisOutputName(); 
Note: See TracChangeset for help on using the changeset viewer.