Ignore:
Timestamp:
08/24/15 14:53:27 (9 years ago)
Author:
mhnguyen
Message:

Change name of several axis attributes and remove some redundant variable of domain

+) Change name of axis attributes to make them consistent with ones of domain
+) Remove zoom_client_* of domain

Test
+) On Curie
+) All tests pass and are correct

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/node/domain.cpp

    r665 r666  
    138138     checkLocalIDomain(); 
    139139     checkLocalJDomain(); 
    140  
    141      ibegin_client = ibegin; ni_client = ni; iend_client = ibegin + ni - 1; 
    142      jbegin_client = jbegin; nj_client = nj; jend_client = jbegin + nj - 1; 
    143140 
    144141     if (i_index.isEmpty()) 
     
    340337            data_i_index.resize(dni) ; 
    341338            data_j_index.resize(dni) ; 
    342             data_n_index.setValue(dni); 
     339 
    343340            for (int i = 0; i < dni; ++i) 
    344341            { 
     
    353350            data_j_index.resize(dni) ; 
    354351 
    355             data_n_index.setValue(dni); 
    356  
    357352            for(int count = 0, j = 0; j  < data_nj.getValue(); ++j) 
    358353            { 
     
    367362   } 
    368363 
    369    void CDomain::completeLonClient() 
     364   //---------------------------------------------------------------- 
     365   void CDomain::completeLonLatClient(void) 
    370366   { 
    371367     int i,j,k ; 
    372368     CArray<double,1> lonvalue_temp(ni*nj) ; 
    373369     CArray<double,2> bounds_lon_temp(nvertex,ni*nj); 
    374  
    375      if (!lonvalue_1d.isEmpty() && !lonvalue_2d.isEmpty()) 
    376        ERROR("CDomain::completeLonLatClient(void)", 
    377             <<"Only one longitude value can be used but both lonvalue_1d and lonvalue_2d are defined! "<<endl 
    378             <<"Define only one longitude value: lonvalue_1d or lonvalue_2d "); 
    379  
    380      if (!lonvalue_1d.isEmpty() && lonvalue_2d.isEmpty()) 
    381      { 
    382        if (lonvalue_1d.numElements() != i_index.numElements()) 
    383          ERROR("CDomain::completeLonLatClient(void)", 
    384                <<"lonvalue_1d has not the same size as the local domain"<<endl 
    385                <<"Local size is "<<i_index.numElements()<<endl 
    386                <<"lonvalue_1d size is "<<lonvalue_1d.numElements()); 
    387      } 
    388  
    389      if (lonvalue_1d.isEmpty() && !lonvalue_2d.isEmpty()) 
    390      { 
    391         if ((lonvalue_2d.extent(0) != ni) || 
    392             (lonvalue_2d.extent(1) != nj)) 
    393            ERROR("CDomain::completeLonLatClient(void)", 
    394                  <<"the lonvalue has not the same size as the local domain"<<endl 
    395                  <<"Local size is "<<ni<<"x"<<nj<<endl 
    396                  <<"Lonvalue size is "<<lonvalue_2d.extent(0)<<"x"<<lonvalue_2d.extent(1)); 
    397      } 
     370     CArray<double,1> latvalue_temp(ni*nj) ; 
     371     CArray<double,2> bounds_lat_temp(nvertex,ni*nj); 
    398372 
    399373     if (!lonvalue_2d.isEmpty()) 
     
    403377          { 
    404378            lonvalue_temp(i+j*ni) = lonvalue_2d(i,j); 
     379            latvalue_temp(i+j*ni) = latvalue_2d(i,j); 
    405380            if (hasBounds) 
    406381            { 
    407382              k=j*ni+i; 
    408               for(int n=0;n<nvertex;++n) bounds_lon_temp(n,k) = bounds_lon_2d(n,i,j); 
     383              for(int n=0;n<nvertex;++n) 
     384              { 
     385                bounds_lon_temp(n,k) = bounds_lon_2d(n,i,j); 
     386                bounds_lat_temp(n,k) = bounds_lat_2d(n,i,j); 
     387              } 
    409388            } 
    410389          } 
     
    415394       if (type_attr::rectilinear == type) 
    416395       { 
    417          if (ni == lonvalue_1d.numElements()) 
     396         if ((ni == lonvalue_1d.numElements()) && (nj == latvalue_1d.numElements())) 
    418397         { 
    419398           for(j=0;j<nj;++j) 
     
    422401               k=j*ni+i; 
    423402               lonvalue_temp(k) = lonvalue_1d(i); 
     403               latvalue_temp(k) = latvalue_1d(j); 
    424404               if (hasBounds) 
    425405               { 
    426                  for(int n=0;n<nvertex;++n) bounds_lon_temp(n,k) = bounds_lon_1d(n,i); 
     406                 for(int n=0;n<nvertex;++n) 
     407                 { 
     408                   bounds_lon_temp(n,k) = bounds_lon_1d(n,i); 
     409                   bounds_lat_temp(n,k) = bounds_lat_1d(n,j); 
     410                 } 
    427411               } 
    428412             } 
     
    430414          else 
    431415            ERROR("CDomain::completeLonClient(void)", 
    432                  <<"The lonvalue_1d has not the same size as the local domain"<<endl 
    433                  <<"Local size is "<<ni<<endl 
    434                  <<"Lonvalue_1d size is "<<lonvalue_1d.numElements()); 
     416                 <<"lonvalue_1d and latvalue_1d has not the same size as the local domain"<<endl 
     417                 <<"Local size is "<<ni<<"x " << nj<< endl 
     418                 <<"lonvalue_1d size is "<<lonvalue_1d.numElements() 
     419                 <<"latvalue_1d size is "<<latvalue_1d.numElements()); 
    435420       } 
    436421       else if (type==type_attr::curvilinear || type==type_attr::unstructured) 
    437422       { 
    438423         lonvalue_temp=lonvalue_1d; 
     424         latvalue_temp=latvalue_1d; 
    439425         if (hasBounds) 
    440426         { 
    441427           bounds_lon_temp=bounds_lon_1d; 
    442          } 
    443        } 
    444      } 
    445  
    446      StdSize dm = zoom_ni_client * zoom_nj_client; 
    447  
    448       // Make sure that this attribute is non-empty for every client. 
    449      if (0 != dm) 
    450      { 
    451        lonvalue_client.resize(dm); 
    452        if (hasBounds) bounds_lon_client.resize(nvertex, dm); 
    453      } 
    454  
    455  
    456      for (i = 0; i < zoom_ni_client; ++i) 
    457      { 
    458        for (j = 0; j < zoom_nj_client; ++j) 
    459        { 
    460          lonvalue_client(i + j * zoom_ni_client) = lonvalue_temp( (i + zoom_ibegin_client-ibegin) + (j + zoom_jbegin_client -jbegin)*ni ); 
    461          if (hasBounds) 
    462          { 
    463            for(int n=0;n<nvertex;n++) 
    464            { 
    465              bounds_lon_client(n,i + j * zoom_ni_client) = bounds_lon_temp( n, (i + zoom_ibegin_client - ibegin) + (j + zoom_jbegin_client -jbegin)*ni ); 
    466            } 
    467          } 
    468        } 
    469      } 
    470    } 
    471  
    472    void CDomain::completeLatClient() 
    473    { 
    474      int i,j,k; 
    475      CArray<double,1> latvalue_temp(ni*nj) ; 
    476      CArray<double,2> bounds_lat_temp(nvertex,ni*nj); 
    477  
    478      if (!latvalue_1d.isEmpty() && !latvalue_2d.isEmpty()) 
    479        ERROR("CDomain::completeLonLatClient(void)", 
    480             <<"Only one longitude value can be used but both latvalue_1d and latvalue_2d are defined! "<<endl 
    481             <<"Define only one longitude value: latvalue_1d or latvalue_2d "); 
    482  
    483      if (!latvalue_1d.isEmpty() && latvalue_2d.isEmpty()) 
    484      { 
    485        if (latvalue_1d.numElements() != i_index.numElements()) 
    486          ERROR("CDomain::completeLonLatClient(void)", 
    487                <<"the latvalue_1d has not the same size as the local domain"<<endl 
    488                <<"Local size is "<<i_index.numElements()<<endl 
    489                <<"Mask size is "<<latvalue_1d.numElements()); 
    490      } 
    491  
    492      if (latvalue_1d.isEmpty() && !latvalue_2d.isEmpty()) 
    493      { 
    494         if ((latvalue_2d.extent(0) != ni) || 
    495             (latvalue_2d.extent(1) != nj)) 
    496            ERROR("CDomain::completeLonLatClient(void)", 
    497                  <<"the mask has not the same size as the local domain"<<endl 
    498                  <<"Local size is "<<ni<<"x"<<nj<<endl 
    499                  <<"Mask size is "<<latvalue_2d.extent(0)<<"x"<<latvalue_2d.extent(1)); 
    500      } 
    501  
    502      if (!latvalue_2d.isEmpty()) 
    503      { 
    504         for (j = 0; j < nj; ++j) 
    505           for (i = 0; i < ni; ++i) 
    506           { 
    507             latvalue_temp(i+j*ni) = latvalue_2d(i,j); 
    508             if (hasBounds) 
    509             { 
    510               k=j*ni+i; 
    511               for(int n=0;n<nvertex;n++) bounds_lat_temp(n,k) = bounds_lat_2d(n,i,j); 
    512             } 
    513           } 
    514      } 
    515  
    516      if (!latvalue_1d.isEmpty()) 
    517      { 
    518        if (type_attr::rectilinear == type) 
    519        { 
    520  
    521          if (nj == latvalue_1d.numElements()) 
    522          { 
    523            for(j=0;j<nj;++j) 
    524              for(i=0;i<ni;++i) 
    525              { 
    526                k=j*ni+i; 
    527                latvalue_temp(k) = latvalue_1d(j); 
    528                if (hasBounds) 
    529                { 
    530                  for(int n=0;n<nvertex;n++) bounds_lat_temp(n,k) = bounds_lat_1d(n,j); 
    531                } 
    532              } 
    533           } 
    534           else 
    535             ERROR("CDomain::completeLonClient(void)", 
    536                  <<"The latvalue_1d has not the same size as the local domain"<<endl 
    537                  <<"Local size is "<<nj<<endl 
    538                  <<"Latvalue_1d size is "<<latvalue_1d.numElements()); 
    539        } 
    540        else if (type==type_attr::curvilinear || type==type_attr::unstructured) 
    541        { 
    542          latvalue_temp=latvalue_1d; 
    543          if (hasBounds) 
    544          { 
    545428           bounds_lat_temp=bounds_lat_1d; 
    546429         } 
     
    548431     } 
    549432 
    550      StdSize dm = zoom_ni_client * zoom_nj_client; 
     433    int i_ind,j_ind; 
     434    int global_zoom_iend=global_zoom_ibegin+global_zoom_ni-1; 
     435    int global_zoom_jend=global_zoom_jbegin+global_zoom_nj-1; 
     436 
     437    int globalIndexCountZoom = 0; 
     438    int nbIndex = i_index.numElements(); 
     439    for (i = 0; i < nbIndex; ++i) 
     440    { 
     441      i_ind=i_index(i); 
     442      j_ind=j_index(i); 
     443 
     444      if (i_ind >= global_zoom_ibegin && i_ind <= global_zoom_iend && j_ind >= global_zoom_jbegin && j_ind <= global_zoom_jend) 
     445      { 
     446        ++globalIndexCountZoom; 
     447      } 
     448    } 
    551449 
    552450      // Make sure that this attribute is non-empty for every client. 
    553      if (0 != dm) 
    554      { 
    555        latvalue_client.resize(dm); 
    556        if (hasBounds) bounds_lat_client.resize(nvertex,dm); 
    557      } 
    558  
    559      for (i = 0; i < zoom_ni_client; i++) 
    560      { 
    561        for (j = 0; j < zoom_nj_client; j++) 
     451     if (0 != globalIndexCountZoom) 
     452     { 
     453       lonvalue_client.resize(globalIndexCountZoom); 
     454       latvalue_client.resize(globalIndexCountZoom); 
     455       if (hasBounds) 
    562456       { 
    563          latvalue_client(i + j * zoom_ni_client) = latvalue_temp( (i + zoom_ibegin_client-ibegin) + (j + zoom_jbegin_client -jbegin)*ni ); 
     457         bounds_lon_client.resize(nvertex,globalIndexCountZoom); 
     458         bounds_lat_client.resize(nvertex,globalIndexCountZoom); 
     459       } 
     460     } 
     461 
     462     int nCountZoom = 0; 
     463     for (i = 0; i < nbIndex; ++i) 
     464     { 
     465       i_ind=i_index(i); 
     466       j_ind=j_index(i); 
     467 
     468       if (i_ind >= global_zoom_ibegin && i_ind <= global_zoom_iend && j_ind >= global_zoom_jbegin && j_ind <= global_zoom_jend) 
     469       { 
     470         lonvalue_client(nCountZoom) = lonvalue_temp(i); 
     471         latvalue_client(nCountZoom) = latvalue_temp(i); 
    564472         if (hasBounds) 
    565473         { 
    566            for(int n=0;n<nvertex;n++) 
     474           for (int n = 0; n < nvertex; ++n) 
    567475           { 
    568              bounds_lat_client(n,i + j * zoom_ni_client) = bounds_lat_temp( n, (i + zoom_ibegin_client - ibegin) + (j + zoom_jbegin_client -jbegin)*ni ); 
     476             bounds_lon_client(n,nCountZoom) = bounds_lon_temp(n,i); 
     477             bounds_lat_client(n,nCountZoom) = bounds_lat_temp(n,i); 
    569478           } 
    570479         } 
     480         ++nCountZoom; 
    571481       } 
    572482     } 
    573    } 
    574  
    575    //---------------------------------------------------------------- 
    576    void CDomain::completeLonLatClient(void) 
    577    { 
    578      completeLonClient(); 
    579      completeLatClient(); 
    580    } 
    581  
    582  
    583    //---------------------------------------------------------------- 
    584    void CDomain::checkZoom(void) 
    585    { 
    586       int global_zoom_iend=global_zoom_ibegin+global_zoom_ni-1 ; 
    587       zoom_ibegin_client = ibegin_client > global_zoom_ibegin ? ibegin_client : global_zoom_ibegin ; 
    588       zoom_iend_client = iend_client < global_zoom_iend ? iend_client : global_zoom_iend ; 
    589       zoom_ni_client=zoom_iend_client-zoom_ibegin_client+1 ; 
    590       if (zoom_ni_client<0) zoom_ni_client=0 ; 
    591  
    592  
    593       int global_zoom_jend=global_zoom_jbegin+global_zoom_nj-1 ; 
    594       zoom_jbegin_client = jbegin_client > global_zoom_jbegin ? jbegin_client : global_zoom_jbegin ; 
    595       zoom_jend_client = jend_client < global_zoom_jend ? jend_client : global_zoom_jend ; 
    596       zoom_nj_client=zoom_jend_client-zoom_jbegin_client+1 ; 
    597       if (zoom_nj_client<0) zoom_nj_client=0; 
    598483   } 
    599484 
     
    691576     hasLonLat = (!latvalue_1d.isEmpty() && !lonvalue_1d.isEmpty()) || 
    692577                 (!latvalue_2d.isEmpty() && !lonvalue_2d.isEmpty()); 
     578     if (hasLonLat) 
     579     { 
     580       if (!lonvalue_1d.isEmpty() && !lonvalue_2d.isEmpty()) 
     581         ERROR("CDomain::completeLonLatClient(void)", 
     582              <<"Only one longitude value can be used but both lonvalue_1d and lonvalue_2d are defined! "<<endl 
     583              <<"Define only one longitude value: lonvalue_1d or lonvalue_2d "); 
     584 
     585       if (!lonvalue_1d.isEmpty() && lonvalue_2d.isEmpty()) 
     586       { 
     587         if (lonvalue_1d.numElements() != i_index.numElements()) 
     588           ERROR("CDomain::completeLonLatClient(void)", 
     589                 <<"lonvalue_1d has not the same size as the local domain"<<endl 
     590                 <<"Local size is "<<i_index.numElements()<<endl 
     591                 <<"lonvalue_1d size is "<<lonvalue_1d.numElements()); 
     592       } 
     593 
     594       if (lonvalue_1d.isEmpty() && !lonvalue_2d.isEmpty()) 
     595       { 
     596          if ((lonvalue_2d.extent(0) != ni) || 
     597              (lonvalue_2d.extent(1) != nj)) 
     598             ERROR("CDomain::completeLonLatClient(void)", 
     599                   <<"the lonvalue has not the same size as the local domain"<<endl 
     600                   <<"Local size is "<<ni<<"x"<<nj<<endl 
     601                   <<"Lonvalue size is "<<lonvalue_2d.extent(0)<<"x"<<lonvalue_2d.extent(1)); 
     602       } 
     603 
     604       if (!latvalue_1d.isEmpty() && !latvalue_2d.isEmpty()) 
     605         ERROR("CDomain::completeLonLatClient(void)", 
     606              <<"Only one longitude value can be used but both latvalue_1d and latvalue_2d are defined! "<<endl 
     607              <<"Define only one longitude value: latvalue_1d or latvalue_2d "); 
     608 
     609       if (!latvalue_1d.isEmpty() && latvalue_2d.isEmpty()) 
     610       { 
     611         if (latvalue_1d.numElements() != i_index.numElements()) 
     612           ERROR("CDomain::completeLonLatClient(void)", 
     613                 <<"the latvalue_1d has not the same size as the local domain"<<endl 
     614                 <<"Local size is "<<i_index.numElements()<<endl 
     615                 <<"Mask size is "<<latvalue_1d.numElements()); 
     616       } 
     617 
     618       if (latvalue_1d.isEmpty() && !latvalue_2d.isEmpty()) 
     619       { 
     620          if ((latvalue_2d.extent(0) != ni) || 
     621              (latvalue_2d.extent(1) != nj)) 
     622             ERROR("CDomain::completeLonLatClient(void)", 
     623                   <<"the mask has not the same size as the local domain"<<endl 
     624                   <<"Local size is "<<ni<<"x"<<nj<<endl 
     625                   <<"Mask size is "<<latvalue_2d.extent(0)<<"x"<<latvalue_2d.extent(1)); 
     626       } 
     627     } 
    693628   } 
    694629 
     
    697632     CContext* context=CContext::getCurrent() ; 
    698633 
    699      this->checkZoom(); 
    700634     if (this->isClientAfterTransformationChecked) return; 
    701635     if (context->hasClient) 
     
    742676     CContext* context=CContext::getCurrent() ; 
    743677 
    744      this->checkZoom(); 
    745678     if (this->isChecked) return; 
    746679     if (context->hasClient) 
     
    759692 
    760693      this->checkDomain(); 
    761       this->checkZoom(); 
    762694      this->checkLonLat(); 
    763695      this->checkBounds(); 
     
    769701         this->checkDomainData(); 
    770702         this->checkCompression(); 
    771          this->completeLonLatClient(); 
     703 
    772704      } 
    773705      else 
     
    777709      if (context->hasClient) 
    778710      { 
    779         computeConnectedServer() ; 
    780         sendServerAttribut() ; 
    781         sendLonLatArea() ; 
     711        this->computeConnectedServer(); 
     712        this->completeLonLatClient(); 
     713        this->sendServerAttribut(); 
     714        this->sendLonLatArea(); 
    782715      } 
    783716 
     
    837770  void CDomain::computeConnectedServer(void) 
    838771  { 
    839     ibegin_client=ibegin; ni_client=ni; iend_client=ibegin_client + ni_client - 1; 
    840     jbegin_client=jbegin; nj_client=nj; jend_client=jbegin_client + nj_client - 1; 
    841  
    842772    CContext* context=CContext::getCurrent() ; 
    843773    CContextClient* client=context->client ; 
     
    846776 
    847777    int i,j,i_ind,j_ind, nbIndex; 
    848     int zoom_iend=global_zoom_ibegin+global_zoom_ni-1 ; 
    849     int zoom_jend=global_zoom_jbegin+global_zoom_nj-1 ; 
     778    int global_zoom_iend=global_zoom_ibegin+global_zoom_ni-1 ; 
     779    int global_zoom_jend=global_zoom_jbegin+global_zoom_nj-1 ; 
    850780 
    851781    // Precompute number of index 
     
    857787      j_ind=j_index(i); 
    858788 
    859       if (i_ind >= global_zoom_ibegin && i_ind <= zoom_iend && j_ind >= global_zoom_jbegin && j_ind <= zoom_jend) 
     789      if (i_ind >= global_zoom_ibegin && i_ind <= global_zoom_iend && j_ind >= global_zoom_jbegin && j_ind <= global_zoom_jend) 
    860790      { 
    861791        ++globalIndexCountZoom; 
     
    878808      globalIndexDomain(globalIndexCount) = globalIndex; 
    879809      ++globalIndexCount; 
    880       if (i_ind >= global_zoom_ibegin && i_ind <= zoom_iend && j_ind >= global_zoom_jbegin && j_ind <= zoom_jend) 
     810      if (i_ind >= global_zoom_ibegin && i_ind <= global_zoom_iend && j_ind >= global_zoom_jbegin && j_ind <= global_zoom_jend) 
    881811      { 
    882812        globalIndexDomainZoom(globalIndexCountZoom) = globalIndex; 
     
    10761006      { 
    10771007        idx = static_cast<int>(it->second[n]); 
    1078         i = i_index(idx); 
    1079         j = j_index(idx); 
    1080         ind = (i - zoom_ibegin_client) + (j - zoom_jbegin_client) * zoom_ni_client; 
    1081  
    1082         lon(n) = lonvalue_client(ind); 
    1083         lat(n) = latvalue_client(ind); 
     1008        lon(n) = lonvalue_client(idx); 
     1009        lat(n) = latvalue_client(idx); 
    10841010 
    10851011        if (hasBounds) 
     
    10881014          CArray<double,2>& boundslat = list_boundslat.back(); 
    10891015 
    1090           for (nv = 0; nv < nvertex; nv++) 
     1016          for (nv = 0; nv < nvertex; ++nv) 
    10911017          { 
    1092             boundslon(nv, n) = bounds_lon_client(nv, ind); 
    1093             boundslat(nv, n) = bounds_lat_client(nv, ind); 
     1018            boundslon(nv, n) = bounds_lon_client(nv, idx); 
     1019            boundslat(nv, n) = bounds_lat_client(nv, idx); 
    10941020          } 
    10951021        } 
     
    12521178      if (hasBounds) 
    12531179      { 
    1254         for (int nv = 0; nv < nvertex; nv++) 
     1180        for (int nv = 0; nv < nvertex; ++nv) 
    12551181          bounds_lon_srv(nv, ind_srv) = boundslon(nv, ind); 
    12561182      } 
Note: See TracChangeset for help on using the changeset viewer.