Changeset 2613


Ignore:
Timestamp:
03/08/24 17:05:40 (2 months ago)
Author:
jderouillat
Message:

Fix the attached mode for scalar output, and some bugs revealed by the adastra porting in debug mode

Location:
XIOS3/trunk/src
Files:
6 edited

Legend:

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

    r2600 r2613  
    411411                       start[0]=domain->ibeginValue_; 
    412412                       count[0]=domain->niValue_; 
    413                        CArray<double,1> lon = domain->lonvalue(Range(0,domain->niValue_-1)); 
     413                       CArray<double,1> lon; 
     414                       lon.resize( domain->niValue_); 
     415                       for (int i=0;i<domain->niValue_;i++) lon(i) = domain->lonvalue(i); 
    414416                       SuperClassWriter::writeData(CArray<double,1>(lon.copy()), lonid, isCollective, 0,&start,&count); 
    415417                     } 
  • XIOS3/trunk/src/io/onetcdf4.cpp

    r2600 r2613  
    478478                normalizingWeight = userChunkingWeights[i]; 
    479479              } 
    480  
    481             std::vector<double> chunkingRatioPerDims; // will store coefficients used to compute chunk size 
    482             double productRatios = 1; // last_coeff = pow( shrink_ratio / (product of all ratios), 1/countChunkingDims ) 
    483             for (int i=0;i<userChunkingWeights.size();i++) 
     480            if (normalizingWeight!=0) // no chunk for scalar 
    484481            { 
    485               chunkingRatioPerDims.push_back( userChunkingWeights[i] / normalizingWeight ); 
    486               if (chunkingRatioPerDims[i]) productRatios *= chunkingRatioPerDims[i]; 
    487             } 
    488             for (int i=0;i<userChunkingWeights.size();i++) 
    489             { 
    490               chunkingRatioPerDims[i] *= pow( chunkingRatio / productRatios, 1./countChunkingDims ); 
    491             } 
    492              
    493             std::vector<double>::iterator itChunkingRatios = chunkingRatioPerDims.begin(); 
    494             //itId = dim.rbegin(); 
    495             double correctionFromPreviousDim = 1.; 
    496             for (vector<StdSize>::reverse_iterator itDim = dimsizes.rbegin(); itDim != dimsizes.rend(); ++itDim, ++itChunkingRatios, ++itId) 
    497             { 
    498               *itChunkingRatios *= correctionFromPreviousDim; 
    499               correctionFromPreviousDim = 1; 
    500               if (*itChunkingRatios > 1) // else target larger than size ! 
     482              std::vector<double> chunkingRatioPerDims; // will store coefficients used to compute chunk size 
     483              double productRatios = 1; // last_coeff = pow( shrink_ratio / (product of all ratios), 1/countChunkingDims ) 
     484              for (int i=0;i<userChunkingWeights.size();i++) 
    501485              { 
    502                 StdSize dimensionSize = *itDim; 
    503                 //info(0) << *itId << " " << *itDim << " " << *itChunkingRatios << " " << (*itDim)/(*itChunkingRatios) << endl; 
    504                 *itDim = ceil( *itDim / ceil(*itChunkingRatios) ); 
    505                 correctionFromPreviousDim = *itChunkingRatios/ ((double)dimensionSize/(*itDim)); 
     486                chunkingRatioPerDims.push_back( userChunkingWeights[i] / normalizingWeight ); 
     487                if (chunkingRatioPerDims[i]) productRatios *= chunkingRatioPerDims[i]; 
    506488              } 
    507             } 
     489              for (int i=0;i<userChunkingWeights.size();i++) 
     490              { 
     491                chunkingRatioPerDims[i] *= pow( chunkingRatio / productRatios, 1./countChunkingDims ); 
     492              } 
     493               
     494              std::vector<double>::iterator itChunkingRatios = chunkingRatioPerDims.begin(); 
     495              //itId = dim.rbegin(); 
     496              double correctionFromPreviousDim = 1.; 
     497              for (vector<StdSize>::reverse_iterator itDim = dimsizes.rbegin(); itDim != dimsizes.rend(); ++itDim, ++itChunkingRatios, ++itId) 
     498              { 
     499                *itChunkingRatios *= correctionFromPreviousDim; 
     500                correctionFromPreviousDim = 1; 
     501                if (*itChunkingRatios > 1) // else target larger than size ! 
     502                { 
     503                  StdSize dimensionSize = *itDim; 
     504                  //info(0) << *itId << " " << *itDim << " " << *itChunkingRatios << " " << (*itDim)/(*itChunkingRatios) << endl; 
     505                  *itDim = ceil( *itDim / ceil(*itChunkingRatios) ); 
     506                  correctionFromPreviousDim = *itChunkingRatios/ ((double)dimensionSize/(*itDim)); 
     507                } 
     508              } 
     509            } 
    508510            int storageType = (0 == dimSize) ? NC_CONTIGUOUS : NC_CHUNKED; 
    509511            CNetCdfInterface::defVarChunking(grpid, varid, storageType, &dimsizes[0]); 
  • XIOS3/trunk/src/manager/contexts_manager.cpp

    r2580 r2613  
    237237    if (comm!=MPI_COMM_NULL)  
    238238    { 
    239       MPI_Bcast(&ret,1,MPI_INT,0,comm) ; 
     239      int cast_ret = 0; 
     240      if (commRank==0) cast_ret = ret; 
     241      MPI_Bcast(&cast_ret,1,MPI_INT,0,comm) ; 
     242      ret = cast_ret; 
    240243      if (ret) 
    241244      { 
  • XIOS3/trunk/src/node/axis.cpp

    r2606 r2613  
    310310     int sz(1); 
    311311     MPI_Comm_size( comm, &sz ); 
    312      size_t distributedHash = 0; 
     312     unsigned long long distributedHash = 0; 
    313313     if (sz!=1) // compute the connector only if the element is distributed 
    314314     { 
     
    324324       gridTransformConnector->transfer(this->value, distributedValue ); 
    325325           
    326        size_t localHash = 0; 
    327        for (int iloc=0; iloc<localSize ; iloc++ ) localHash+=globalIndex(iloc)*distributedValue(iloc); 
     326       unsigned long long localHash = 0; 
     327       for (int iloc=0; iloc<localSize ; iloc++ ) localHash+=((unsigned long long)(abs(globalIndex(iloc)*distributedValue(iloc))))%LLONG_MAX; 
    328328       distributedHash = 0; 
    329        MPI_Allreduce( &localHash, &distributedHash, 1, MPI_UNSIGNED_LONG, MPI_SUM, comm  ); 
     329       MPI_Allreduce( &localHash, &distributedHash, 1, MPI_UNSIGNED_LONG_LONG, MPI_SUM, comm  ); 
    330330     } 
    331331     else // if the element is not distributed, the local hash is valid 
     
    333333       int globalSize = this->n_glo.getValue(); 
    334334       int localSize = globalSize; 
    335        size_t localHash = 0; 
    336        for (int iloc=0; iloc<localSize ; iloc++ ) localHash+=iloc*this->value(iloc); 
     335       unsigned long long localHash = 0; 
     336       for (int iloc=0; iloc<localSize ; iloc++ ) localHash+=((unsigned long long)(abs(iloc*this->value(iloc))))%LLONG_MAX; 
    337337       distributedHash = localHash; 
    338338     } 
  • XIOS3/trunk/src/node/domain.cpp

    r2606 r2613  
    18091809     int sz(1); 
    18101810     MPI_Comm_size( comm, &sz ); 
    1811      size_t distributedHash = 0; 
     1811     unsigned long long distributedHash = 0; 
    18121812     if (sz!=1) // compute the connector only if the element is distributed 
    18131813     { 
     
    18261826       // Compute the distributed hash (v0) of the element 
    18271827       // it will be associated to the default element name (= map key), and to the name really written 
    1828        size_t localHash = 0; 
    1829        for (int iloc=0; iloc<localSize ; iloc++ ) localHash+=globalIndex(iloc)*lon_distributedValue(iloc)*lat_distributedValue(iloc); 
     1828       unsigned long long localHash = 0; 
     1829       for (int iloc=0; iloc<localSize ; iloc++ ) 
     1830       { 
     1831         localHash+=((unsigned long long)(abs(globalIndex(iloc)*lon_distributedValue(iloc)*lat_distributedValue(iloc))))%LLONG_MAX; 
     1832       } 
    18301833       distributedHash = 0; 
    1831        MPI_Allreduce( &localHash, &distributedHash, 1, MPI_UNSIGNED_LONG, MPI_SUM, comm  ); 
     1834       MPI_Allreduce( &localHash, &distributedHash, 1, MPI_UNSIGNED_LONG_LONG, MPI_SUM, comm  ); 
    18321835     } 
    18331836     else // if the element is not distributed, the local hash is valid 
     
    18351838       int globalSize = this->ni_glo.getValue()*this->nj_glo.getValue(); 
    18361839       int localSize = globalSize; 
    1837        size_t localHash = 0; 
    1838        for (int iloc=0; iloc<localSize ; iloc++ ) localHash+=iloc*this->lonvalue(iloc)*this->latvalue(iloc); 
     1840       unsigned long long localHash = 0; 
     1841       for (int iloc=0; iloc<localSize ; iloc++ ) localHash+=((unsigned long long)(abs(iloc*this->lonvalue(iloc)*this->latvalue(iloc))))%LLONG_MAX; 
    18391842       distributedHash = localHash; 
    18401843     } 
  • XIOS3/trunk/src/transformation/scalar_algorithm/scalar_algorithm_redistribute.cpp

    r2507 r2613  
    9595    CArray<double,1> valSrc, valDst ; 
    9696    valSrc.resize(scalarSource->getLocalView(CElementView::FULL)->getSize()) ; 
    97     valDst.resize(scalarDestination->getLocalView(CElementView::FULL)->getSize()) ; 
    98      
    99     if (scalarSource->hasValue()) 
    100     { 
    101       if (valSrc.numElements()>0)  valSrc(0)=scalarSource->value ; 
    102       transformConnector->transfer(valSrc, valDst) ; 
    103       if (valDst.numElements()>0)  scalarDestination->value = valDst(0) ; 
    104     } 
    10597 
    10698    if (scalarSource->hasBounds())  
     
    124116     
    125117    transformMask->transfer(workflow, mask, false) ;    
    126     scalarDestination->mask = mask(0) ; 
     118    if (mask.numElements()>0) 
     119    { 
     120      scalarDestination->mask = mask(0) ; 
     121    } 
    127122 
    128123    scalarDestination->checkAttributes() ; 
     124    this->computeAlgorithm(scalarSource->getLocalView(CElementView::WORKFLOW), scalarDestination->getLocalView(CElementView::WORKFLOW)) ; 
     125 
     126    valDst.resize(scalarDestination->getLocalView(CElementView::FULL)->getSize()) ; 
     127    if (scalarSource->hasValue()) 
     128    { 
     129      if (valSrc.numElements()>0)  valSrc(0)=scalarSource->value ; 
     130      transformConnector->transfer(valSrc, valDst) ; 
     131      if (valDst.numElements()>0)  scalarDestination->value = valDst(0) ; 
     132    } 
    129133  } 
    130134  CATCH 
Note: See TracChangeset for help on using the changeset viewer.