Ignore:
Timestamp:
01/25/17 16:25:17 (7 years ago)
Author:
yushan
Message:

initialize the branch

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/branch_yushan/src/transformation/domain_algorithm_interpolate.cpp

    r1014 r1037  
    4848 
    4949CDomainAlgorithmInterpolate::CDomainAlgorithmInterpolate(CDomain* domainDestination, CDomain* domainSource, CInterpolateDomain* interpDomain) 
    50 : CDomainAlgorithmTransformation(domainDestination, domainSource), interpDomain_(interpDomain), writeToFile_(false), readFromFile_(false) 
    51 { 
    52   CContext* context = CContext::getCurrent(); 
     50: CDomainAlgorithmTransformation(domainDestination, domainSource), interpDomain_(interpDomain), writeToFile_(false) 
     51{ 
    5352  interpDomain_->checkValid(domainSource); 
    54   fileToReadWrite_ = "xios_interpolation_weights_"; 
    55  
    56   if (interpDomain_->weight_filename.isEmpty()) 
    57   { 
    58     fileToReadWrite_ += context->getId() + "_" +  
    59                     domainSource->getDomainOutputName() + "_" +  
    60                     domainDestination->getDomainOutputName() + ".nc";     
    61   } 
    62   else  
    63     fileToReadWrite_ = interpDomain_->weight_filename; 
    64  
    65   ifstream f(fileToReadWrite_.c_str());   
    66   switch (interpDomain_->mode) 
    67   { 
    68     case CInterpolateDomain::mode_attr::read: 
    69       readFromFile_ = true;       
    70       break; 
    71     case CInterpolateDomain::mode_attr::compute: 
    72       readFromFile_ = false; 
    73       break; 
    74     case CInterpolateDomain::mode_attr::read_or_compute:       
    75       if (!f.good()) 
    76         readFromFile_ = false; 
    77       else 
    78         readFromFile_ = true; 
    79       break; 
    80     default: 
    81       break; 
    82   }  
    83  
    84   writeToFile_ = interpDomain_->write_weight;   
    85      
     53  if ((CInterpolateDomain::mode_attr::write == interpDomain_->mode) && 
     54      (!interpDomain_->file.isEmpty())) 
     55    writeToFile_ = true; 
    8656} 
    8757 
     
    384354  } 
    385355 
    386   if (writeToFile_ && !readFromFile_) 
     356  if (writeToFile_) 
    387357     writeRemapInfo(interpMapValue); 
    388358  exchangeRemapInfo(interpMapValue); 
     
    469439void CDomainAlgorithmInterpolate::computeIndexSourceMapping_(const std::vector<CArray<double,1>* >& dataAuxInputs) 
    470440{ 
    471   if (readFromFile_ && !writeToFile_ 
     441  if (CInterpolateDomain::mode_attr::read == interpDomain_->mode 
    472442    readRemapInfo(); 
    473443  else 
     
    478448 
    479449void CDomainAlgorithmInterpolate::writeRemapInfo(std::map<int,std::vector<std::pair<int,double> > >& interpMapValue) 
    480  
    481   writeInterpolationInfo(fileToReadWrite_, interpMapValue); 
     450{ 
     451  std::string filename = interpDomain_->file.getValue(); 
     452  writeInterpolationInfo(filename, interpMapValue); 
    482453} 
    483454 
    484455void CDomainAlgorithmInterpolate::readRemapInfo() 
    485  
     456{ 
     457  std::string filename = interpDomain_->file.getValue(); 
    486458  std::map<int,std::vector<std::pair<int,double> > > interpMapValue; 
    487   readInterpolationInfo(fileToReadWrite_, interpMapValue); 
     459  readInterpolationInfo(filename, interpMapValue); 
    488460 
    489461  exchangeRemapInfo(interpMapValue); 
     
    636608    int countBuff = 0; 
    637609    MPI_Get_count(&recvStatus, MPI_INT, &countBuff); 
     610    #ifdef _usingMPI 
    638611    clientSrcRank = recvStatus.MPI_SOURCE; 
    639  
     612    #elif _usingEP 
     613    clientSrcRank = recvStatus.ep_src; 
     614    #endif 
    640615    MPI_Recv((recvIndexSrcBuff + receivedSize), 
    641616             recvBuffSize, 
     
    681656                                                                const StdSize size) 
    682657{ 
    683   return CONetCDF4::addDimension(name, size);   
     658  CONetCDF4::addDimension(name, size);   
    684659} 
    685660 
     
    687662                                                               const std::vector<StdString>& dim) 
    688663{ 
    689   return CONetCDF4::addVariable(name, type, dim); 
    690 } 
    691  
    692 void CDomainAlgorithmInterpolate::WriteNetCdf::endDefinition() 
    693 { 
    694   CONetCDF4::definition_end(); 
     664  CONetCDF4::addVariable(name, type, dim); 
    695665} 
    696666 
     
    756726  MPI_Scan(&localNbWeight, &startIndex, 1, MPI_LONG, MPI_SUM, client->intraComm); 
    757727   
    758   if (0 == globalNbWeight) 
    759   { 
    760     info << "There is no interpolation weights calculated between " 
    761          << "domain source: " << domainSrc_->getDomainOutputName() 
    762          << " and domain destination: " << domainDest_->getDomainOutputName() 
    763          << std::endl; 
    764     return; 
    765   } 
    766  
    767728  std::vector<StdSize> start(1, startIndex - localNbWeight); 
    768729  std::vector<StdSize> count(1, localNbWeight); 
    769    
    770   WriteNetCdf netCdfWriter(filename, client->intraComm);   
     730 
     731  WriteNetCdf netCdfWriter(filename, client->intraComm); 
     732 
     733  // netCdfWriter = CONetCDF4(filename, false, false, true, client->intraComm, false); 
    771734 
    772735  // Define some dimensions 
     
    782745  netCdfWriter.addVariableWrite("weight", NC_DOUBLE, dims); 
    783746 
    784   // End of definition 
    785   netCdfWriter.endDefinition(); 
    786  
    787747  // // Write variables 
    788   if (0 != localNbWeight) 
    789   { 
    790     netCdfWriter.writeDataIndex(src_idx, "src_idx", false, 0, &start, &count); 
    791     netCdfWriter.writeDataIndex(dst_idx, "dst_idx", false, 0, &start, &count); 
    792     netCdfWriter.writeDataIndex(weights, "weight", false, 0, &start, &count); 
    793   } 
     748  netCdfWriter.writeDataIndex(src_idx, "src_idx", true, 0, &start, &count); 
     749  netCdfWriter.writeDataIndex(dst_idx, "dst_idx", true, 0, &start, &count); 
     750  netCdfWriter.writeDataIndex(weights, "weight", true, 0, &start, &count); 
    794751 
    795752  netCdfWriter.closeFile(); 
Note: See TracChangeset for help on using the changeset viewer.