Changeset 1269 for XIOS/dev


Ignore:
Timestamp:
09/15/17 16:51:16 (7 years ago)
Author:
ymipsl
Message:

interpolate_domain : add new attribute "read_write_convention" which msut be "c" or fortran. The default remain fortran (global indices begin at 1)

YM

Location:
XIOS/dev/XIOS_DEV_CMIP6/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/XIOS_DEV_CMIP6/src/config/interpolate_domain_attribute.conf

    r1264 r1269  
    99DECLARE_ATTRIBUTE(StdString, weight_filename) 
    1010DECLARE_ATTRIBUTE(bool, write_weight) 
     11DECLARE_ENUM2(read_write_convention, c, fortran) 
  • XIOS/dev/XIOS_DEV_CMIP6/src/node/interpolate_domain.cpp

    r1264 r1269  
    6363    if (this->write_weight.isEmpty()) this->write_weight.setValue(false); 
    6464 
    65     StdString weightFile; 
    66     switch (this->mode) 
    67     { 
    68       case mode_attr::read: 
    69         if (this->weight_filename.isEmpty()) 
    70         { 
    71           if (!this->write_weight) 
    72             ERROR("void CInterpolateDomain::checkValid(CDomain* domainSrc)", 
    73                  << "Read mode is activated but there is no file specified." << std::endl 
    74                  << "Please define a correct file containing interpolation weights with option 'file'. "); 
    75         } 
    76         else 
    77         { 
    78           weightFile = this->weight_filename; 
    79           ifstream f(weightFile.c_str()); 
    80           if (!f.good()) 
    81             ERROR("void CInterpolateDomain::checkValid(CDomain* domainSrc)", 
    82                   << "Read mode is activated but file "  << weightFile << " doesn't exist." << std::endl 
    83                   << "Please check this file "); 
    84         } 
    85         break; 
    86       case mode_attr::compute: 
    87         break; 
    88       case mode_attr::read_or_compute: 
    89         if (!this->weight_filename.isEmpty() && !this->write_weight) 
    90         { 
    91           weightFile = this->weight_filename; 
    92           ifstream f(weightFile.c_str()); 
    93           if (!f.good()) 
    94             ERROR("void CInterpolateDomain::checkValid(CDomain* domainSrc)", 
    95                   << "read_or_compute mode is activated but file "  << weightFile << " doesn't exist." << std::endl 
    96                   << "Please check this file "); 
    97         } 
    98         break; 
    99       default: 
    100         break; 
    101     } 
     65    if (this->read_write_convention.isEmpty()) this->read_write_convention.setValue(read_write_convention_attr::fortran); 
    10266 
    10367  } 
  • XIOS/dev/XIOS_DEV_CMIP6/src/transformation/domain_algorithm_interpolate.cpp

    r1268 r1269  
    5656  renormalize = interpDomain_->renormalize ; 
    5757  quantity = interpDomain_->quantity ; 
     58 
     59  if (interpDomain_->read_write_convention == CInterpolateDomain::read_write_convention_attr::fortran) fortranConvention=true ; 
     60  else fortranConvention=false ; 
    5861   
    5962  fileToReadWrite_ = "xios_interpolation_weights_"; 
     
    768771 
    769772  int index = 0; 
     773  int indexOffset=0 ; 
     774  if (fortranConvention) indexOffset=1 ; 
    770775  for (it = itb; it !=ite; ++it) 
    771776  { 
     
    773778    for (int idx = 0; idx < tmp.size(); ++idx) 
    774779    { 
    775       dst_idx(index) = it->first + 1; 
    776       src_idx(index) = tmp[idx].first + 1; 
     780      dst_idx(index) = it->first + indexOffset; 
     781      src_idx(index) = tmp[idx].first + indexOffset; 
    777782      weights(index) = tmp[idx].second; 
    778783      ++index; 
     
    884889  nc_get_vara_long(ncid, dstIndexId, &start, &nbWeight, dstIndex) ; 
    885890 
    886   for(size_t ind=0; ind<nbWeight;++ind) 
    887     interpMapValue[dstIndex[ind]-1].push_back(make_pair(srcIndex[ind]-1,weight[ind])); 
    888 } 
     891  int indexOffset=0 ; 
     892  if (fortranConvention) indexOffset=1 ; 
     893    for(size_t ind=0; ind<nbWeight;++ind) 
     894      interpMapValue[dstIndex[ind]-indexOffset].push_back(make_pair(srcIndex[ind]-indexOffset,weight[ind])); 
     895 } 
    889896 
    890897void CDomainAlgorithmInterpolate::apply(const std::vector<std::pair<int,double> >& localIndex, 
  • XIOS/dev/XIOS_DEV_CMIP6/src/transformation/domain_algorithm_interpolate.hpp

    r1264 r1269  
    6363  bool readFromFile_; 
    6464  StdString fileToReadWrite_; 
     65  bool fortranConvention ; 
    6566 
    6667  // class WriteNetCdf; 
Note: See TracChangeset for help on using the changeset viewer.