Changeset 761


Ignore:
Timestamp:
10/26/15 17:05:06 (8 years ago)
Author:
rlacroix
Message:

Fix: Longitudes, latitutes and their bounds were incorrect when using a zoom.

File:
1 edited

Legend:

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

    r760 r761  
    749749   void CDomain::completeLonLatClient(void) 
    750750   { 
    751      int i,j,k ; 
    752      CArray<double,1> lonvalue_temp(ni * nj); 
    753      CArray<double,2> bounds_lon_temp(nvertex, ni * nj); 
    754      CArray<double,1> latvalue_temp(ni * nj); 
    755      CArray<double,2> bounds_lat_temp(nvertex, ni * nj); 
    756  
    757751     if (!lonvalue_2d.isEmpty()) 
    758752     { 
    759         for (j = 0; j < nj; ++j) 
    760           for (i = 0; i < ni; ++i) 
    761           { 
    762             lonvalue_temp(i + j * ni) = lonvalue_2d(i,j); 
    763             latvalue_temp(i + j * ni) = latvalue_2d(i,j); 
    764             if (hasBounds) 
    765             { 
    766               k = j * ni + i; 
    767               for (int n = 0; n < nvertex; ++n) 
    768               { 
    769                 bounds_lon_temp(n,k) = bounds_lon_2d(n,i,j); 
    770                 bounds_lat_temp(n,k) = bounds_lat_2d(n,i,j); 
    771               } 
    772             } 
    773           } 
    774         lonvalue_1d.free(); 
    775      } 
    776  
    777      if (!lonvalue_1d.isEmpty()) 
     753       lonvalue_client.resize(ni * nj); 
     754       latvalue_client.resize(ni * nj); 
     755       if (hasBounds) 
     756       { 
     757         bounds_lon_client.resize(nvertex, ni * nj); 
     758         bounds_lat_client.resize(nvertex, ni * nj); 
     759       } 
     760 
     761       for (int j = 0; j < nj; ++j) 
     762       { 
     763         for (int i = 0; i < ni; ++i) 
     764         { 
     765           int k = j * ni + i; 
     766 
     767           lonvalue_client(k) = lonvalue_2d(i,j); 
     768           latvalue_client(k) = latvalue_2d(i,j); 
     769 
     770           if (hasBounds) 
     771           { 
     772             for (int n = 0; n < nvertex; ++n) 
     773             { 
     774               bounds_lon_client(n,k) = bounds_lon_2d(n,i,j); 
     775               bounds_lat_client(n,k) = bounds_lat_2d(n,i,j); 
     776             } 
     777           } 
     778         } 
     779       } 
     780     } 
     781     else if (!lonvalue_1d.isEmpty()) 
    778782     { 
    779783       if (type_attr::rectilinear == type) 
     
    781785         if (ni == lonvalue_1d.numElements() && nj == latvalue_1d.numElements()) 
    782786         { 
    783            for (j = 0; j < nj; ++j) 
    784              for (i = 0; i < ni; ++i) 
     787           lonvalue_client.resize(ni * nj); 
     788           latvalue_client.resize(ni * nj); 
     789           if (hasBounds) 
     790           { 
     791             bounds_lon_client.resize(nvertex, ni * nj); 
     792             bounds_lat_client.resize(nvertex, ni * nj); 
     793           } 
     794 
     795           for (int j = 0; j < nj; ++j) 
     796           { 
     797             for (int i = 0; i < ni; ++i) 
    785798             { 
    786                k = j * ni + i; 
    787                lonvalue_temp(k) = lonvalue_1d(i); 
    788                latvalue_temp(k) = latvalue_1d(j); 
     799               int k = j * ni + i; 
     800 
     801               lonvalue_client(k) = lonvalue_1d(i); 
     802               latvalue_client(k) = latvalue_1d(j); 
     803 
    789804               if (hasBounds) 
    790805               { 
    791806                 for (int n = 0; n < nvertex; ++n) 
    792807                 { 
    793                    bounds_lon_temp(n,k) = bounds_lon_1d(n,i); 
    794                    bounds_lat_temp(n,k) = bounds_lat_1d(n,j); 
     808                   bounds_lon_client(n,k) = bounds_lon_1d(n,i); 
     809                   bounds_lat_client(n,k) = bounds_lat_1d(n,j); 
    795810                 } 
    796811               } 
    797812             } 
    798           } 
    799           else 
    800             ERROR("CDomain::completeLonClient(void)", 
    801                   << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " 
    802                   << "'lonvalue_1d' and 'latvalue_1d' does not have the same size as the local domain." << std::endl 
    803                   << "'lonvalue_1d' size is " << lonvalue_1d.numElements() << " but it should be " << ni.getValue() << '.' << std::endl 
    804                   << "'latvalue_1d' size is " << latvalue_1d.numElements() << " but it should be " << nj.getValue() << '.'); 
     813           } 
     814         } 
     815         else 
     816           ERROR("CDomain::completeLonClient(void)", 
     817                 << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " 
     818                 << "'lonvalue_1d' and 'latvalue_1d' does not have the same size as the local domain." << std::endl 
     819                 << "'lonvalue_1d' size is " << lonvalue_1d.numElements() << " but it should be " << ni.getValue() << '.' << std::endl 
     820                 << "'latvalue_1d' size is " << latvalue_1d.numElements() << " but it should be " << nj.getValue() << '.'); 
    805821       } 
    806822       else if (type == type_attr::curvilinear || type == type_attr::unstructured) 
    807823       { 
    808          lonvalue_temp = lonvalue_1d; 
    809          latvalue_temp = latvalue_1d; 
     824         lonvalue_client.reference(lonvalue_1d); 
     825         latvalue_client.reference(latvalue_1d); 
    810826         if (hasBounds) 
    811827         { 
    812            bounds_lon_temp = bounds_lon_1d; 
    813            bounds_lat_temp = bounds_lat_1d; 
     828           bounds_lon_client.reference(bounds_lon_1d); 
     829           bounds_lat_client.reference(bounds_lat_1d); 
    814830         } 
    815        } 
    816        lonvalue_2d.free(); 
    817      } 
    818  
    819     int i_ind,j_ind; 
    820     int global_zoom_iend=global_zoom_ibegin+global_zoom_ni-1; 
    821     int global_zoom_jend=global_zoom_jbegin+global_zoom_nj-1; 
    822  
    823     int globalIndexCountZoom = 0; 
    824     int nbIndex = i_index.numElements(); 
    825     for (i = 0; i < nbIndex; ++i) 
    826     { 
    827       i_ind=i_index(i); 
    828       j_ind=j_index(i); 
    829  
    830       if (i_ind >= global_zoom_ibegin && i_ind <= global_zoom_iend && j_ind >= global_zoom_jbegin && j_ind <= global_zoom_jend) 
    831       { 
    832         ++globalIndexCountZoom; 
    833       } 
    834     } 
    835  
    836       // Make sure that this attribute is non-empty for every client. 
    837      if (0 != globalIndexCountZoom) 
    838      { 
    839        lonvalue_client.resize(globalIndexCountZoom); 
    840        latvalue_client.resize(globalIndexCountZoom); 
    841        if (hasBounds) 
    842        { 
    843          bounds_lon_client.resize(nvertex,globalIndexCountZoom); 
    844          bounds_lat_client.resize(nvertex,globalIndexCountZoom); 
    845        } 
    846      } 
    847  
    848      int nCountZoom = 0; 
    849      for (i = 0; i < nbIndex; ++i) 
    850      { 
    851        i_ind=i_index(i); 
    852        j_ind=j_index(i); 
    853  
    854        if (i_ind >= global_zoom_ibegin && i_ind <= global_zoom_iend && j_ind >= global_zoom_jbegin && j_ind <= global_zoom_jend) 
    855        { 
    856          lonvalue_client(nCountZoom) = lonvalue_temp(i); 
    857          latvalue_client(nCountZoom) = latvalue_temp(i); 
    858          if (hasBounds) 
    859          { 
    860            for (int n = 0; n < nvertex; ++n) 
    861            { 
    862              bounds_lon_client(n,nCountZoom) = bounds_lon_temp(n,i); 
    863              bounds_lat_client(n,nCountZoom) = bounds_lat_temp(n,i); 
    864            } 
    865          } 
    866          ++nCountZoom; 
    867831       } 
    868832     } 
Note: See TracChangeset for help on using the changeset viewer.