Changeset 660


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
Files:
6 added
10 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/arch/arch-X64_CURIE.path

    r574 r660  
    11NETCDF_INCDIR="-I $NETCDF_INCDIR" 
    22NETCDF_LIBDIR="-L $NETCDF_LIBDIR" 
    3 NETCDF_LIB="-lnetcdf" 
     3NETCDF_LIB="-lnetcdf -lnetcdff" 
    44 
    55MPI_INCDIR="" 
  • XIOS/trunk/bld.cfg

    r657 r660  
    3131bld::target libxios.a 
    3232#bld::target generate_fortran_interface.exe  
    33 bld::target xios_server.exe test_client.exe parse_xml.exe test_complete.exe test_xios_interface.exe test_new_features.exe test_unstruct_complete.exe 
     33bld::target xios_server.exe test_remap.exe 
     34bld::target test_new_features.exe test_unstruct_complete.exe  
     35bld::target test_client.exe test_complete.exe 
    3436bld::exe_dep 
    3537 
     
    5658bld::excl_dep        use::mod_prism_proto 
    5759bld::excl_dep        use::mod_prism 
     60bld::excl_dep        use::netcdf 
    5861bld::excl_dep        inc::mpif.h 
  • XIOS/trunk/make_xios

    r601 r660  
    156156 
    157157XIOS_CINCDIR="$NETCDF_INCDIR $HDF5_INCDIR $MPI_INCDIR" 
    158 XIOS_FINCDIR="$XIOS_FINCDIR $MPI_INCDIR" 
     158XIOS_FINCDIR="$NETCDF_INCDIR $XIOS_FINCDIR $MPI_INCDIR" 
    159159 
    160160XIOS_LIB="$XIOS_LIB $NETCDF_LIBDIR $HDF5_LIBDIR $MPI_LIBDIR $NETCDF_LIB $HDF5_LIB $MPI_LIB" 
  • XIOS/trunk/src/distribution_client.cpp

    r657 r660  
    196196      nZoomEnd_.at((indexMap_[idx]+1))   = domList[domIndex]->global_zoom_jbegin + domList[domIndex]->global_zoom_nj-1; 
    197197 
    198       dataBegin_.at(indexMap_[idx]+1) = (2 == domList[domIndex]->data_dim) ? domList[domIndex]->data_jbegin.getValue() : -1; 
     198      dataBegin_.at(indexMap_[idx]+1) = domList[domIndex]->data_jbegin.getValue(); //(2 == domList[domIndex]->data_dim) ? domList[domIndex]->data_jbegin.getValue() : -1; 
    199199      dataIndex_.at(indexMap_[idx]+1).resize(domList[domIndex]->data_j_index.numElements()); 
    200200      dataIndex_.at(indexMap_[idx]+1) = domList[domIndex]->data_j_index; 
     
    212212      dataIndex_.at(indexMap_[idx]) = domList[domIndex]->data_i_index; 
    213213 
    214       dataNIndex_.at(idx) = domList[domIndex]->data_n_index.getValue(); 
     214      dataNIndex_.at(idx) = domList[domIndex]->data_i_index.numElements(); 
    215215      dataDims_.at(idx) = domList[domIndex]->data_dim.getValue(); 
    216216 
     
    617617                                        const int& dataDim, const int& ni, int& j) 
    618618{ 
     619//  int tempI = dataIIndex + dataIBegin, 
     620//      tempJ = (1 == dataDim) ? -1 
     621//                             : (dataJIndex + dataJBegin); 
     622//  int i = (dataDim == 1) ? (tempI - 1) % ni 
     623//                     : (tempI - 1) ; 
     624//  j = (dataDim == 1) ? (tempI - 1) / ni 
     625//                     : (tempJ - 1) ; 
     626 
    619627  int tempI = dataIIndex + dataIBegin, 
    620       tempJ = (1 == dataDim) ? -1 
    621                              : (dataJIndex + dataJBegin); 
    622   int i = (dataDim == 1) ? (tempI - 1) % ni 
    623                      : (tempI - 1) ; 
    624   j = (dataDim == 1) ? (tempI - 1) / ni 
    625                      : (tempJ - 1) ; 
     628      tempJ = (dataJIndex + dataJBegin); 
     629  int i = (dataDim == 1) ? (tempI) % ni 
     630                         : (tempI) ; 
     631  j = (dataDim == 1) ? (tempI) / ni 
     632                     : (tempJ) ; 
    626633 
    627634  return i; 
  • XIOS/trunk/src/node/domain.cpp

    r657 r660  
    135135         if (!area.isEmpty()) 
    136136           area.transposeSelf(1, 0); 
    137  
    138 //         ni=1 ; 
    139 //         ibegin=0 ; 
    140 //         iend=0 ; 
    141  
    142137      } 
    143138      else if ((ni_glo.isEmpty() || ni_glo.getValue() <= 0 ) || 
     
    332327      else if (data_dim.isEmpty()) 
    333328      { 
    334          ERROR("CDomain::checkAttributes(void)", 
    335                << "Data dimension undefined !") ; 
     329        data_dim.setValue(1); 
     330//         ERROR("CDomain::checkAttributes(void)", 
     331//               << "Data dimension undefined !") ; 
    336332      } 
    337333 
    338334      if (data_ibegin.isEmpty()) 
    339335         data_ibegin.setValue(0) ; 
    340       if (data_jbegin.isEmpty() && (data_dim.getValue() == 2)) 
     336      if (data_jbegin.isEmpty()) 
    341337         data_jbegin.setValue(0) ; 
    342338 
     
    353349      } 
    354350 
    355       if (data_dim.getValue() == 2) 
    356       { 
    357          if (!data_nj.isEmpty() && (data_nj.getValue() <= 0) ) 
     351      if (!data_nj.isEmpty() && (data_nj.getValue() <= 0) ) 
     352      { 
     353         ERROR("CDomain::checkAttributes(void)", 
     354               << "Data dimension is negative (data_nj).") ; 
     355      } 
     356 
     357      if (data_nj.isEmpty()) 
     358         data_nj.setValue((data_dim.getValue() == 1) 
     359                   ? (ni.getValue() * nj.getValue()) 
     360                   : nj.getValue()); 
     361 
     362   } 
     363 
     364   //---------------------------------------------------------------- 
     365 
     366   void CDomain::checkCompression(void) 
     367   { 
     368      if (!data_i_index.isEmpty()) 
     369      { 
     370//         int ssize = data_i_index.numElements(); 
     371//         if (!data_n_index.isEmpty() && 
     372//            (data_n_index.getValue() != ssize)) 
     373//         { 
     374//            ERROR("CDomain::checkAttributes(void)", 
     375//                  <<"Dimension data_i_index incompatible with data_n_index.") ; 
     376//         } 
     377//         else if (data_n_index.isEmpty()) 
     378//            data_n_index.setValue(ssize) ; 
     379          if (!data_j_index.isEmpty() && 
     380             (data_j_index.numElements() != data_i_index.numElements())) 
     381          { 
     382             ERROR("CDomain::checkAttributes(void)", 
     383                   <<"Dimension data_j_index incompatible with data_i_index.") ; 
     384          } 
     385 
     386         if (2 == data_dim.getValue()) 
    358387         { 
    359             ERROR("CDomain::checkAttributes(void)", 
    360                   << "Data dimension is negative (data_nj).") ; 
    361          } 
    362          else if (data_nj.isEmpty()) 
    363             data_nj.setValue(nj.getValue()) ; 
    364       } 
    365  
    366    } 
    367  
    368    //---------------------------------------------------------------- 
    369  
    370    void CDomain::checkCompression(void) 
    371    { 
    372       if (!data_i_index.isEmpty()) 
    373       { 
    374          int ssize = data_i_index.numElements(); 
    375          if (!data_n_index.isEmpty() && 
    376             (data_n_index.getValue() != ssize)) 
    377          { 
    378             ERROR("CDomain::checkAttributes(void)", 
    379                   <<"Dimension data_i_index incompatible with data_n_index.") ; 
    380          } 
    381          else if (data_n_index.isEmpty()) 
    382             data_n_index.setValue(ssize) ; 
    383  
    384          if (data_dim.getValue() == 2) 
    385          { 
    386             if (!data_j_index.isEmpty() && 
    387                (data_j_index.numElements() != data_i_index.numElements())) 
    388             { 
    389                ERROR("CDomain::checkAttributes(void)", 
    390                      <<"Dimension data_j_index incompatible with data_i_index.") ; 
    391             } 
    392             else if (data_j_index.isEmpty()) 
     388            if (data_j_index.isEmpty()) 
    393389            { 
    394390               ERROR("CDomain::checkAttributes(void)", 
     
    396392            } 
    397393         } 
     394         else // (1 == data_dim.getValue()) 
     395         { 
     396            if (data_j_index.isEmpty()) 
     397            { 
     398              const int dni = data_ni.getValue(); 
     399              data_j_index.resize(dni); 
     400              for (int j = 0; j < dni; ++j) data_j_index(j) = 0; 
     401            } 
     402 
     403         } 
    398404      } 
    399405      else 
    400406      { 
    401          if (!data_n_index.isEmpty() || 
    402             ((data_dim.getValue() == 2) && (!data_j_index.isEmpty()))) 
     407//         if (!data_n_index.isEmpty() || 
     408//            ((data_dim.getValue() == 2) && (!data_j_index.isEmpty()))) 
     409//            ERROR("CDomain::checkAttributes(void)", << "data_i_index undefined") ; 
     410         if ((data_dim.getValue() == 2) && (!data_j_index.isEmpty())) 
    403411            ERROR("CDomain::checkAttributes(void)", << "data_i_index undefined") ; 
    404       } 
    405  
    406       if (data_n_index.isEmpty()) 
    407       { // -> bloc re-vérifié OK 
    408          if (data_dim.getValue() == 1) 
     412 
     413         if (1 == data_dim.getValue()) 
    409414         { 
    410415            const int dni = data_ni.getValue(); 
    411416            data_i_index.resize(dni) ; 
     417            data_j_index.resize(dni) ; 
    412418            data_n_index.setValue(dni); 
    413             for (int i = 0; i < dni; i++) data_i_index(i) = i+1 ; 
     419            for (int i = 0; i < dni; ++i) 
     420            { 
     421              data_i_index(i) = i; 
     422              data_j_index(i) = 0; 
     423            } 
    414424         } 
    415425         else   // (data_dim == 2) 
     
    421431            data_n_index.setValue(dni); 
    422432 
    423             for(int count = 0, j = 0; j  < data_nj.getValue(); j++) 
     433            for(int count = 0, j = 0; j  < data_nj.getValue(); ++j) 
    424434            { 
    425                for(int i = 0; i < data_ni.getValue(); i++, count++) 
     435               for(int i = 0; i < data_ni.getValue(); ++i, ++count) 
    426436               { 
    427                   data_i_index(count) = i+1 ; 
    428                   data_j_index(count) = j+1 ; 
     437                  data_i_index(count) = i; 
     438                  data_j_index(count) = j; 
    429439               } 
    430440            } 
    431441         } 
    432442      } 
     443 
     444//      if (data_n_index.isEmpty()) 
     445//      { // -> bloc re-vérifié OK 
     446//         if (data_dim.getValue() == 1) 
     447//         { 
     448//            const int dni = data_ni.getValue(); 
     449//            data_i_index.resize(dni) ; 
     450//            data_n_index.setValue(dni); 
     451//            for (int i = 0; i < dni; i++) data_i_index(i) = i+1 ; 
     452//         } 
     453//         else   // (data_dim == 2) 
     454//         { 
     455//            const int dni = data_ni.getValue() * data_nj.getValue(); 
     456//            data_i_index.resize(dni) ; 
     457//            data_j_index.resize(dni) ; 
     458// 
     459//            data_n_index.setValue(dni); 
     460// 
     461//            for(int count = 0, j = 0; j  < data_nj.getValue(); j++) 
     462//            { 
     463//               for(int i = 0; i < data_ni.getValue(); i++, count++) 
     464//               { 
     465//                  data_i_index(count) = i+1 ; 
     466//                  data_j_index(count) = j+1 ; 
     467//               } 
     468//            } 
     469//         } 
     470//      } 
    433471   } 
    434472 
  • XIOS/trunk/src/node/grid.cpp

    r657 r660  
    1515#include "server_distribution_description.hpp" 
    1616#include "client_server_mapping_distributed.hpp" 
     17#include "distribution_client.hpp" 
     18#include "grid_transformation.hpp" 
    1719 
    1820namespace xios { 
  • XIOS/trunk/src/node/grid.hpp

    r657 r660  
    1111#include "array_new.hpp" 
    1212#include "attribute_array.hpp" 
    13 #include "distribution_client.hpp" 
    1413#include "distribution_server.hpp" 
    1514#include "client_server_mapping.hpp" 
    1615#include "utils.hpp" 
    1716#include "transformation_enum.hpp" 
    18 #include "grid_transformation.hpp" 
    1917 
    2018namespace xios { 
  • XIOS/trunk/src/test/test_unstruct_complete.f90

    r659 r660  
    190190    IF (mask(ind)) THEN 
    191191      data_n_index=data_n_index+1 
    192       data_i_index(data_n_index)=ind 
     192      data_i_index(data_n_index)=ind-1 
    193193      field_A_compressed(data_n_index,:)=field_A_srf(ind,:) 
    194194    ENDIF 
     
    200200 
    201201  CALL xios_set_axis_attr("axis_srf",size=llm ,value=lval) ; 
    202 !  CALL xios_set_domain_attr("domain_srf",ni_glo=ncell_glo, ni=ncell, ibegin=1, i_index=RESHAPE(i_index,(/ncell,1/) )) 
    203202  CALL xios_set_domain_attr("domain_srf", ni_glo=ncell_glo, ni=ncell, ibegin=1, i_index=i_index) 
    204203  CALL xios_set_domain_attr("domain_srf", type='unstructured', data_dim=1, data_ni=data_n_index, & 
     
    206205  CALL xios_set_domain_attr("domain_srf", lonvalue=lon, latvalue=lat) 
    207206  CALL xios_set_domain_attr("domain_srf", nvertex=4, bounds_lon=bounds_lon, bounds_lat=bounds_lat) 
    208 !  CALL xios_set_domain_attr("domain_srf", mask=RESHAPE(mask,(/ncell,1/) )) 
     207 
    209208 
    210209 
  • 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.