Ignore:
Timestamp:
07/30/15 15:18:00 (9 years ago)
Author:
mhnguyen
Message:

Adding interpolation test_remap

+) Add new test case for domain interpolation
+) Resolve circular dependence
+) Add function to read weigh file

Test
+) On Curie
+) test_remap can print out .nc

Location:
XIOS/trunk/src/transformation
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/transformation/domain_algorithm_interpolate_from_file.cpp

    r657 r660  
    1313#include "distribution_client.hpp" 
    1414#include "client_server_mapping_distributed.hpp" 
     15#include "netcdf.hpp" 
    1516 
    1617namespace xios { 
     
    3435  std::string filename = interpDomain_->file.getValue(); 
    3536  std::map<int,std::vector<std::pair<int,double> > > interpMapValue; 
    36 //  readInterpolationInfo(filename, interpMapValue); 
    37  
    38   randomizeInterpolationInfo(interpMapValue); 
     37  readInterpolationInfo(filename, interpMapValue); 
     38 
     39  //randomizeInterpolationInfo(interpMapValue); 
    3940  boost::unordered_map<size_t,int> globalIndexOfDomainDest; 
    4041  int ni = domainDest_->ni.getValue(); 
     
    232233                                                                std::map<int,std::vector<std::pair<int,double> > >& interpMapValue) 
    233234{ 
    234  
    235 } 
    236  
    237 } 
     235  int ncid ; 
     236  int weightDimId ; 
     237  size_t nbWeightGlo ; 
     238 
     239  CContext* context = CContext::getCurrent(); 
     240  CContextClient* client=context->client; 
     241  int clientRank = client->clientRank; 
     242  int clientSize = client->clientSize; 
     243   
     244  nc_open(filename.c_str(),NC_NOWRITE, &ncid) ; 
     245  nc_inq_dimid(ncid,"n_weight",&weightDimId) ; 
     246  nc_inq_dimlen(ncid,weightDimId,&nbWeightGlo) ; 
     247 
     248  size_t nbWeight ; 
     249  size_t start ; 
     250  size_t div = nbWeightGlo/clientSize ; 
     251  size_t mod = nbWeightGlo%clientSize ; 
     252  if (clientRank < mod) 
     253  { 
     254    nbWeight=div+1 ; 
     255    start=clientRank*(div+1) ; 
     256  } 
     257  else 
     258  { 
     259    nbWeight=div ; 
     260    start= mod * (div+1) + (clientRank-mod) * div ; 
     261  } 
     262   
     263   
     264 
     265  double* weight=new double[nbWeight] ; 
     266  int weightId ; 
     267  nc_inq_varid (ncid, "weight", &weightId) ; 
     268  nc_get_vara_double(ncid, weightId, &start, &nbWeight, weight) ; 
     269 
     270  long* srcIndex=new long[nbWeight] ;  
     271  int srcIndexId ; 
     272  nc_inq_varid (ncid, "src_idx", &srcIndexId) ; 
     273  nc_get_vara_long(ncid, srcIndexId, &start, &nbWeight, srcIndex) ; 
     274 
     275  long* dstIndex=new long[nbWeight] ;  
     276  int dstIndexId ; 
     277  nc_inq_varid (ncid, "dst_idx", &dstIndexId) ; 
     278  nc_get_vara_long(ncid, dstIndexId, &start, &nbWeight, dstIndex) ; 
     279         
     280  for(size_t ind=0; ind<nbWeight;++ind) 
     281    interpMapValue[dstIndex[ind]].push_back(make_pair(srcIndex[ind],weight[ind])); 
     282} 
     283 
     284} 
  • XIOS/trunk/src/transformation/grid_transformation.cpp

    r657 r660  
    1717#include "transformation_mapping.hpp" 
    1818#include "axis_algorithm_transformation.hpp" 
     19#include "distribution_client.hpp" 
    1920 
    2021namespace xios { 
Note: See TracChangeset for help on using the changeset viewer.