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

Changing some domain attributes

+) Longitude and latitude from now on can be 2 dimension array

Test
+) On Curie
+) test_client, test_complete pass and are correct

File:
1 edited

Legend:

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

    r663 r664  
    2727      , isChecked(false), relFiles(), isClientChecked(false), nbConnectedClients_(), indSrv_(), connectedServerRank_() 
    2828      , hasBounds(false), hasArea(false), isDistributed_(false), nGlobDomain_(), isUnstructed_(false) 
    29       , global_zoom_ni(0), global_zoom_ibegin(0), global_zoom_nj(0), global_zoom_jbegin(0), maskInter_() 
     29      , global_zoom_ni(0), global_zoom_ibegin(0), global_zoom_nj(0), global_zoom_jbegin(0) 
    3030      , isClientAfterTransformationChecked(false) 
     31      , lonvalue_client(), latvalue_client(), bounds_lon_client(), bounds_lat_client() 
    3132   { /* Ne rien faire de plus */ } 
    3233 
     
    3536      , isChecked(false), relFiles(), isClientChecked(false), nbConnectedClients_(), indSrv_(), connectedServerRank_() 
    3637      , hasBounds(false), hasArea(false), isDistributed_(false), nGlobDomain_(), isUnstructed_(false) 
    37       , global_zoom_ni(0), global_zoom_ibegin(0), global_zoom_nj(0), global_zoom_jbegin(0), maskInter_() 
     38      , global_zoom_ni(0), global_zoom_ibegin(0), global_zoom_nj(0), global_zoom_jbegin(0) 
    3839      , isClientAfterTransformationChecked(false) 
     40      , lonvalue_client(), latvalue_client(), bounds_lon_client(), bounds_lat_client() 
    3941   { /* Ne rien faire de plus */ } 
    4042 
     
    9597   void CDomain::checkDomain(void) 
    9698   { 
    97       if (!type.isEmpty() && type==type_attr::unstructured) 
    98       { 
    99          if (ni_glo.isEmpty() || ni_glo <= 0 ) 
    100          { 
    101             ERROR("CDomain::checkAttributes(void)", 
    102                << "[ Id = " << this->getId() << " ] " 
    103                << "The global domain is badly defined," 
    104                << " check the \'ni_glo\'  value !") 
    105          } 
    106          isUnstructed_ = true; 
    107          nj_glo = 1; 
    108          nj = 1; 
    109          jbegin = 0; 
    110          if (ni.isEmpty()) ni = i_index.numElements(); 
    111          j_index.resize(ni); 
    112          for(int i=0;i<ni;++i) j_index(i)=0; 
    113  
    114 //         nj_glo=ni_glo ; 
    115 //         ni_glo=1 ; 
    116 //         if (!ni.isEmpty()) nj=ni ; 
    117 //         if (!ibegin.isEmpty()) jbegin=ibegin ; 
    118 //         if (!iend.isEmpty()) jend=iend ; 
    119 //         if (!i_index.isEmpty()) 
    120 //         { 
    121 //          j_index.resize(1,nj) ; 
    122 //          for(int i=0;i<ni;i++) j_index(0,i)=i_index(i,0) ; 
    123 //          i_index.resize(1,nj) ; 
    124 //          for(int j=0;j<nj;j++) i_index(0,j)=0 ; 
    125 //         } 
    126 // 
    127 //         if (!mask.isEmpty()) 
    128 //         { 
    129 //          CArray<int,2> mask_tmp(nj,1); 
    130 //          mask_tmp = mask ; 
    131 //          mask.resize(1,nj) ; 
    132 //          for(int j=0;j<nj;j++) mask(0,j)=mask_tmp(j,0) ; 
    133 //         } 
    134  
    135          if (!area.isEmpty()) 
    136            area.transposeSelf(1, 0); 
    137       } 
    138       else if ((ni_glo.isEmpty() || ni_glo.getValue() <= 0 ) || 
    139           (nj_glo.isEmpty() || nj_glo.getValue() <= 0 )) 
    140       { 
    141          ERROR("CDomain::checkAttributes(void)", 
    142                << "[ Id = " << this->getId() << " ] " 
    143                << "The global domain is badly defined," 
    144                << " check the \'ni_glo\' et \'nj_glo\' values !") 
    145       } 
    146  
    147       isDistributed_ = !ibegin.isEmpty() || !ni.isEmpty() || !jbegin.isEmpty() || !nj.isEmpty(); 
    148  
    149       checkLocalIDomain(); 
    150       checkLocalJDomain(); 
    151  
    152       ibegin_client = ibegin; ni_client = ni; iend_client = ibegin + ni - 1; 
    153       jbegin_client = jbegin; nj_client = nj; jend_client = jbegin + nj - 1; 
    154  
    155       if (i_index.isEmpty()) 
    156       { 
    157         i_index.resize(ni*nj); 
    158         for (int j = 0; j < nj; ++j) 
    159           for (int i = 0; i < ni; ++i) i_index(i+j*ni) = i+ibegin; 
    160       } 
    161  
    162       if (j_index.isEmpty()) 
    163       { 
    164         j_index.resize(ni*nj); 
    165         for (int j = 0; j < nj; ++j) 
    166           for (int i = 0; i < ni; ++i) j_index(i+j*ni) = j+jbegin; 
    167       } 
    168       computeNGlobDomain(); 
    169  
    170       if (0 == global_zoom_ni) global_zoom_ni = ni_glo; 
    171       if (0 == global_zoom_nj) global_zoom_nj = nj_glo; 
     99     if (type.isEmpty()) 
     100     { 
     101       ERROR("CDomain::checkDomain(void)", 
     102             << "[ Id = " << this->getId() << " ] " 
     103             << "The domain type is not defined," 
     104             << " check the 'type'  value !") 
     105     } 
     106 
     107     if (type==type_attr::unstructured) 
     108     { 
     109        if (ni_glo.isEmpty() || ni_glo <= 0 ) 
     110        { 
     111           ERROR("CDomain::checkAttributes(void)", 
     112              << "[ Id = " << this->getId() << " ] " 
     113              << "The global domain is badly defined," 
     114              << " check the \'ni_glo\'  value !") 
     115        } 
     116        isUnstructed_ = true; 
     117        nj_glo = 1; 
     118        nj = 1; 
     119        jbegin = 0; 
     120        if (ni.isEmpty()) ni = i_index.numElements(); 
     121        j_index.resize(ni); 
     122        for(int i=0;i<ni;++i) j_index(i)=0; 
     123 
     124        if (!area.isEmpty()) 
     125          area.transposeSelf(1, 0); 
     126     } 
     127     else if ((ni_glo.isEmpty() || ni_glo.getValue() <= 0 ) || 
     128         (nj_glo.isEmpty() || nj_glo.getValue() <= 0 )) 
     129     { 
     130        ERROR("CDomain::checkAttributes(void)", 
     131              << "[ Id = " << this->getId() << " ] " 
     132              << "The global domain is badly defined," 
     133              << " check the \'ni_glo\' et \'nj_glo\' values !") 
     134     } 
     135 
     136     isDistributed_ = !ibegin.isEmpty() || !ni.isEmpty() || !jbegin.isEmpty() || !nj.isEmpty(); 
     137 
     138     checkLocalIDomain(); 
     139     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; 
     143 
     144     if (i_index.isEmpty()) 
     145     { 
     146       i_index.resize(ni*nj); 
     147       for (int j = 0; j < nj; ++j) 
     148         for (int i = 0; i < ni; ++i) i_index(i+j*ni) = i+ibegin; 
     149     } 
     150 
     151     if (j_index.isEmpty()) 
     152     { 
     153       j_index.resize(ni*nj); 
     154       for (int j = 0; j < nj; ++j) 
     155         for (int i = 0; i < ni; ++i) j_index(i+j*ni) = j+jbegin; 
     156     } 
     157     computeNGlobDomain(); 
     158 
     159     if (0 == global_zoom_ni) global_zoom_ni = ni_glo; 
     160     if (0 == global_zoom_nj) global_zoom_nj = nj_glo; 
    172161   } 
    173162 
     
    229218          jend_mask = jbegin.getValue() + nj.getValue() - 1; 
    230219 
    231       if (!mask_1D.isEmpty() && !mask_2D.isEmpty()) 
     220      if (!mask_1d.isEmpty() && !mask_2d.isEmpty()) 
    232221        ERROR("CDomain::checkMask(void)", 
    233              <<"Only one mask is used but both mask_1D and mask_2D are defined! "<<endl 
    234              <<"Define only one mask: mask_1D or mask_2D "); 
    235  
    236       if (!mask_1D.isEmpty() && mask_2D.isEmpty()) 
    237       { 
    238         if (mask_1D.numElements() != i_index.numElements()) 
     222             <<"Only one mask is used but both mask_1d and mask_2d are defined! "<<endl 
     223             <<"Define only one mask: mask_1d or mask_2d "); 
     224 
     225      if (!mask_1d.isEmpty() && mask_2d.isEmpty()) 
     226      { 
     227        if (mask_1d.numElements() != i_index.numElements()) 
    239228          ERROR("CDomain::checkMask(void)", 
    240                 <<"the mask_1D has not the same size than the local domain"<<endl 
     229                <<"the mask_1d has not the same size as the local domain"<<endl 
    241230                <<"Local size is "<<i_index.numElements()<<endl 
    242                 <<"Mask size is "<<mask_1D.numElements()); 
    243       } 
    244  
    245       if (mask_1D.isEmpty() && !mask_2D.isEmpty()) 
    246       { 
    247          if ((mask_2D.extent(0) != ni) || 
    248              (mask_2D.extent(1) != nj)) 
     231                <<"Mask size is "<<mask_1d.numElements()); 
     232      } 
     233 
     234      if (mask_1d.isEmpty() && !mask_2d.isEmpty()) 
     235      { 
     236         if ((mask_2d.extent(0) != ni) || 
     237             (mask_2d.extent(1) != nj)) 
    249238            ERROR("CDomain::checkMask(void)", 
    250                   <<"the mask has not the same size than the local domain"<<endl 
     239                  <<"the mask has not the same size as the local domain"<<endl 
    251240                  <<"Local size is "<<ni<<"x"<<nj<<endl 
    252                   <<"Mask size is "<<mask.extent(0)<<"x"<<mask.extent(1)); 
    253       } 
    254  
    255       if (!mask_1D.isEmpty()) 
    256       { 
    257         maskInter_.resize(mask_1D.numElements()); 
    258         maskInter_ = mask_1D; 
    259       } 
    260       else if (!mask_2D.isEmpty()) 
    261       { 
    262         maskInter_.resize(mask_2D.extent(0) * mask_2D.extent(0)); 
     241                  <<"Mask size is "<<mask_2d.extent(0)<<"x"<<mask_2d.extent(1)); 
     242      } 
     243 
     244      if (!mask_2d.isEmpty()) 
     245      { 
     246        mask_1d.resize(mask_2d.extent(0) * mask_2d.extent(1)); 
    263247        for (int j = 0; j < nj; ++j) 
    264           for (int i = 0; i < ni; ++i) maskInter_(i+j*ni) = mask_2D(i,j); 
     248          for (int i = 0; i < ni; ++i) mask_1d(i+j*ni) = mask_2d(i,j); 
    265249      } 
    266250      else 
    267251      { 
    268         maskInter_.resize(i_index.numElements()); 
    269         for (int i = 0; i < i_index.numElements(); ++i) maskInter_(i) = true; 
    270       } 
    271  
    272       if (!mask.isEmpty()) 
    273       { 
    274         maskInter_.resize(mask.extent(0) * mask.extent(1)); 
    275         for (int j = 0; j < nj; ++j) 
    276           for (int i = 0; i < ni; ++i) maskInter_(i+j*ni) = mask(i,j); 
    277       } 
    278       else 
    279       { 
    280         maskInter_.resize(ni*nj); 
    281         for (int i = 0; i < maskInter_.numElements(); ++i) maskInter_(i) = true; 
    282       } 
    283  
    284       if (!mask.isEmpty()) 
    285       { 
    286          if ((mask.extent(0) != ni) || 
    287              (mask.extent(1) != nj)) 
    288             ERROR("CDomain::checkAttributes(void)", 
    289                   <<"the mask has not the same size than the local domain"<<endl 
    290                    <<"Local size is "<<ni<<"x"<<nj<<endl 
    291                   <<"Mask size is "<<mask.extent(0)<<"x"<<mask.extent(1)); 
    292 //         for (int i = 0; i < ni; i++) 
    293 //         { 
    294 //            for (int j = 0; j < nj; j++) 
    295 //            { 
    296 //               if (i < ibegin_mask && i > iend_mask && 
    297 //                   j < jbegin_mask && j > jend_mask ) 
    298 //                     mask(i,j) = false; 
    299 //            } 
    300 //         } 
    301       } 
    302       else // (!mask.hasValue()) 
    303       { // Si aucun masque n'est défini, 
    304         // on en crée un nouveau qui valide l'intégralité du domaine. 
    305          mask.resize(ni,nj) ; 
    306          for (int i = 0; i < ni.getValue(); i++) 
    307          { 
    308             for (int j = 0; j < nj.getValue(); j++) 
    309             { 
    310                if (i >= ibegin_mask && i <= iend_mask && 
    311                    j >= jbegin_mask && j <= jend_mask ) 
    312                      mask(i,j) = true; 
    313                else  mask(i,j) = false; 
    314             } 
    315          } 
     252        mask_1d.resize(i_index.numElements()); 
     253        for (int i = 0; i < i_index.numElements(); ++i) mask_1d(i) = true; 
    316254      } 
    317255   } 
     
    319257 
    320258   //---------------------------------------------------------------- 
    321  
    322259   void CDomain::checkDomainData(void) 
    323260   { 
     
    331268      { 
    332269        data_dim.setValue(1); 
    333 //         ERROR("CDomain::checkAttributes(void)", 
    334 //               << "Data dimension undefined !") ; 
    335270      } 
    336271 
     
    366301 
    367302   //---------------------------------------------------------------- 
    368  
    369303   void CDomain::checkCompression(void) 
    370304   { 
    371305      if (!data_i_index.isEmpty()) 
    372306      { 
    373 //         int ssize = data_i_index.numElements(); 
    374 //         if (!data_n_index.isEmpty() && 
    375 //            (data_n_index.getValue() != ssize)) 
    376 //         { 
    377 //            ERROR("CDomain::checkAttributes(void)", 
    378 //                  <<"Dimension data_i_index incompatible with data_n_index.") ; 
    379 //         } 
    380 //         else if (data_n_index.isEmpty()) 
    381 //            data_n_index.setValue(ssize) ; 
    382           if (!data_j_index.isEmpty() && 
    383              (data_j_index.numElements() != data_i_index.numElements())) 
     307        if (!data_j_index.isEmpty() && 
     308           (data_j_index.numElements() != data_i_index.numElements())) 
     309        { 
     310           ERROR("CDomain::checkAttributes(void)", 
     311                 <<"Dimension data_j_index incompatible with data_i_index.") ; 
     312        } 
     313 
     314       if (2 == data_dim.getValue()) 
     315       { 
     316          if (data_j_index.isEmpty()) 
    384317          { 
    385318             ERROR("CDomain::checkAttributes(void)", 
    386                    <<"Dimension data_j_index incompatible with data_i_index.") ; 
     319                   <<"data_j_index must be defined !") ; 
    387320          } 
    388  
    389          if (2 == data_dim.getValue()) 
    390          { 
    391             if (data_j_index.isEmpty()) 
    392             { 
    393                ERROR("CDomain::checkAttributes(void)", 
    394                      <<"data_j_index must be defined !") ; 
    395             } 
    396          } 
    397          else // (1 == data_dim.getValue()) 
    398          { 
    399             if (data_j_index.isEmpty()) 
    400             { 
    401               const int dni = data_ni.getValue(); 
    402               data_j_index.resize(dni); 
    403               for (int j = 0; j < dni; ++j) data_j_index(j) = 0; 
    404             } 
    405  
    406          } 
     321       } 
     322       else // (1 == data_dim.getValue()) 
     323       { 
     324          if (data_j_index.isEmpty()) 
     325          { 
     326            const int dni = data_ni.getValue(); 
     327            data_j_index.resize(dni); 
     328            for (int j = 0; j < dni; ++j) data_j_index(j) = 0; 
     329          } 
     330       } 
    407331      } 
    408332      else 
    409333      { 
    410 //         if (!data_n_index.isEmpty() || 
    411 //            ((data_dim.getValue() == 2) && (!data_j_index.isEmpty()))) 
    412 //            ERROR("CDomain::checkAttributes(void)", << "data_i_index undefined") ; 
    413334         if ((data_dim.getValue() == 2) && (!data_j_index.isEmpty())) 
    414335            ERROR("CDomain::checkAttributes(void)", << "data_i_index undefined") ; 
     
    444365         } 
    445366      } 
    446  
    447 //      if (data_n_index.isEmpty()) 
    448 //      { // -> bloc re-vérifié OK 
    449 //         if (data_dim.getValue() == 1) 
    450 //         { 
    451 //            const int dni = data_ni.getValue(); 
    452 //            data_i_index.resize(dni) ; 
    453 //            data_n_index.setValue(dni); 
    454 //            for (int i = 0; i < dni; i++) data_i_index(i) = i+1 ; 
    455 //         } 
    456 //         else   // (data_dim == 2) 
    457 //         { 
    458 //            const int dni = data_ni.getValue() * data_nj.getValue(); 
    459 //            data_i_index.resize(dni) ; 
    460 //            data_j_index.resize(dni) ; 
    461 // 
    462 //            data_n_index.setValue(dni); 
    463 // 
    464 //            for(int count = 0, j = 0; j  < data_nj.getValue(); j++) 
    465 //            { 
    466 //               for(int i = 0; i < data_ni.getValue(); i++, count++) 
    467 //               { 
    468 //                  data_i_index(count) = i+1 ; 
    469 //                  data_j_index(count) = j+1 ; 
    470 //               } 
    471 //            } 
    472 //         } 
    473 //      } 
    474    } 
    475  
    476    //---------------------------------------------------------------- 
    477  
    478    void CDomain::completeLonLatClient(void) 
    479    { 
    480       int i,j,k ; 
    481       CArray<double,1> lonvalue_temp(ni*nj) ; 
    482       CArray<double,1> latvalue_temp(ni*nj) ; 
    483       CArray<double,2> bounds_lon_temp(nvertex,ni*nj) ; 
    484       CArray<double,2> bounds_lat_temp(nvertex,ni*nj) ; 
    485  
    486       if (type.isEmpty()) 
    487       { 
    488         if ( lonvalue.numElements() == ni*nj && latvalue.numElements() == ni*nj ) 
    489         { 
    490           type.setValue(type_attr::curvilinear) ; 
    491           isCurvilinear=true ; 
    492         } 
    493         else if ( lonvalue.numElements() == ni && latvalue.numElements() == nj ) 
    494         { 
    495           type.setValue(type_attr::regular) ; 
    496           isCurvilinear=false ; 
    497         } 
    498         else ERROR("void CDomain::completeLonLatClient(void)",<<"the grid is nor curvilinear, nor cartesian, because the size of longitude and latitude array is not coherent with the domain size"<<endl 
    499                                                               <<"lonvalue size = " << lonvalue.numElements() << "different of ni or ni*nj"<<endl 
    500                                                               <<"latvalue size = " << latvalue.numElements() << "different of nj or ni*nj" ) ; 
    501       } 
    502       if (type==type_attr::curvilinear || type==type_attr::unstructured) 
    503       { 
    504         lonvalue_temp=lonvalue ; 
    505         latvalue_temp=latvalue ; 
    506         if (hasBounds) bounds_lon_temp=bounds_lon ; 
    507         if (hasBounds) bounds_lat_temp=bounds_lat ; 
    508       } 
    509       else 
    510       { 
    511         for(j=0;j<nj;j++) 
    512           for(i=0;i<ni;i++) 
     367   } 
     368 
     369   void CDomain::completeLonClient() 
     370   { 
     371     int i,j,k ; 
     372     CArray<double,1> lonvalue_temp(ni*nj) ; 
     373     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     } 
     398 
     399     if (!lonvalue_2d.isEmpty()) 
     400     { 
     401        for (j = 0; j < nj; ++j) 
     402          for (i = 0; i < ni; ++i) 
    513403          { 
    514             k=j*ni+i ; 
    515             lonvalue_temp(k)=lonvalue(i) ; 
    516             latvalue_temp(k)=latvalue(j) ; 
     404            lonvalue_temp(i+j*ni) = lonvalue_2d(i,j); 
    517405            if (hasBounds) 
    518406            { 
    519               for(int n=0;n<nvertex;n++) 
    520               { 
    521                 bounds_lon_temp(n,k)=bounds_lon(n,i) ; 
    522                 bounds_lat_temp(n,k)=bounds_lat(n,j) ; 
    523               } 
     407              k=j*ni+i; 
     408              for(int n=0;n<nvertex;++n) bounds_lon_temp(n,k) = bounds_lon_2d(n,i,j); 
    524409            } 
    525410          } 
    526       } 
    527  
    528       StdSize dm = zoom_ni_client * zoom_nj_client; 
     411     } 
     412 
     413     if (!lonvalue_1d.isEmpty()) 
     414     { 
     415       if (type_attr::rectilinear == type) 
     416       { 
     417         if (ni == lonvalue_1d.numElements()) 
     418         { 
     419           for(j=0;j<nj;++j) 
     420             for(i=0;i<ni;++i) 
     421             { 
     422               k=j*ni+i; 
     423               lonvalue_temp(k) = lonvalue_1d(i); 
     424               if (hasBounds) 
     425               { 
     426                 for(int n=0;n<nvertex;++n) bounds_lon_temp(n,k) = bounds_lon_1d(n,i); 
     427               } 
     428             } 
     429          } 
     430          else 
     431            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()); 
     435       } 
     436       else if (type==type_attr::curvilinear || type==type_attr::unstructured) 
     437       { 
     438         lonvalue_temp=lonvalue_1d; 
     439         if (hasBounds) 
     440         { 
     441           bounds_lon_temp=bounds_lon_1d; 
     442         } 
     443       } 
     444     } 
     445 
     446     StdSize dm = zoom_ni_client * zoom_nj_client; 
    529447 
    530448      // Make sure that this attribute is non-empty for every client. 
    531       if (0 != dm) 
    532       { 
    533         lonvalue.resize(dm); 
    534         latvalue.resize(dm); 
    535       } 
    536  
    537  
    538       for (int i = 0; i < zoom_ni_client; i++) 
    539       { 
    540         for (int j = 0; j < zoom_nj_client; j++) 
    541         { 
    542           lonvalue(i + j * zoom_ni_client) = lonvalue_temp( (i + zoom_ibegin_client-ibegin) + (j + zoom_jbegin_client -jbegin)*ni ); 
    543           latvalue(i + j * zoom_ni_client) = latvalue_temp( (i + zoom_ibegin_client - ibegin)+(j + zoom_jbegin_client - jbegin)*ni ); 
    544           if (hasBounds) 
     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) 
    545506          { 
    546             for(int n=0;n<nvertex;n++) 
     507            latvalue_temp(i+j*ni) = latvalue_2d(i,j); 
     508            if (hasBounds) 
    547509            { 
    548               bounds_lon(n,i + j * zoom_ni_client) = bounds_lon_temp( n, (i + zoom_ibegin_client - ibegin) + (j + zoom_jbegin_client -jbegin)*ni ); 
    549               bounds_lat(n,i + j * zoom_ni_client) = bounds_lat_temp( n, (i + zoom_ibegin_client - ibegin)+(j + zoom_jbegin_client -jbegin)*ni ); 
     510              k=j*ni+i; 
     511              for(int n=0;n<nvertex;n++) bounds_lat_temp(n,k) = bounds_lat_2d(n,i,j); 
    550512            } 
    551513          } 
    552         } 
    553       } 
    554     } 
    555  
     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         { 
     545           bounds_lat_temp=bounds_lat_1d; 
     546         } 
     547       } 
     548     } 
     549 
     550     StdSize dm = zoom_ni_client * zoom_nj_client; 
     551 
     552      // 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++) 
     562       { 
     563         latvalue_client(i + j * zoom_ni_client) = latvalue_temp( (i + zoom_ibegin_client-ibegin) + (j + zoom_jbegin_client -jbegin)*ni ); 
     564         if (hasBounds) 
     565         { 
     566           for(int n=0;n<nvertex;n++) 
     567           { 
     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 ); 
     569           } 
     570         } 
     571       } 
     572     } 
     573   } 
    556574 
    557575   //---------------------------------------------------------------- 
    558576 
     577   void CDomain::completeLonLatClient(void) 
     578   { 
     579     completeLonClient(); 
     580     completeLatClient(); 
     581//      int i,j,k ; 
     582//      CArray<double,1> lonvalue_temp(ni*nj) ; 
     583//      CArray<double,1> latvalue_temp(ni*nj) ; 
     584//      CArray<double,2> bounds_lon_temp(nvertex,ni*nj); 
     585//      CArray<double,2> bounds_lat_temp(nvertex,ni*nj); 
     586// 
     587//      if (type.isEmpty()) 
     588//      { 
     589//        if ( lonvalue.numElements() == ni*nj && latvalue.numElements() == ni*nj ) 
     590//        { 
     591//          type.setValue(type_attr::curvilinear) ; 
     592//          isCurvilinear=true ; 
     593//        } 
     594//        else if ( lonvalue.numElements() == ni && latvalue.numElements() == nj ) 
     595//        { 
     596//          type.setValue(type_attr::regular) ; 
     597//          isCurvilinear=false ; 
     598//        } 
     599//        else ERROR("void CDomain::completeLonLatClient(void)",<<"the grid is nor curvilinear, nor cartesian, because the size of longitude and latitude array is not coherent with the domain size"<<endl 
     600//                                                              <<"lonvalue size = " << lonvalue.numElements() << "different of ni or ni*nj"<<endl 
     601//                                                              <<"latvalue size = " << latvalue.numElements() << "different of nj or ni*nj" ) ; 
     602//      } 
     603//      if (type==type_attr::curvilinear || type==type_attr::unstructured) 
     604//      { 
     605//        lonvalue_temp=lonvalue ; 
     606//        latvalue_temp=latvalue ; 
     607//        if (hasBounds) bounds_lon_temp=bounds_lon ; 
     608//        if (hasBounds) bounds_lat_temp=bounds_lat ; 
     609//      }checkBounds 
     610//      else 
     611//      { 
     612//        for(j=0;j<nj;j++) 
     613//          for(i=0;i<ni;i++) 
     614//          { 
     615//            k=j*ni+i ; 
     616//            lonvalue_temp(k)=lonvalue(i) ; 
     617//            latvalue_temp(k)=latvalue(j) ; 
     618//            if (hasBounds) 
     619//            { 
     620//              for(int n=0;n<nvertex;n++) 
     621//              { 
     622//                bounds_lon_temp(n,k)=bounds_lon(n,i) ; 
     623//                bounds_lat_temp(n,k)=bounds_lat(n,j) ; 
     624//              } 
     625//            } 
     626//          } 
     627//      } 
     628// 
     629//      StdSize dm = zoom_ni_client * zoom_nj_client; 
     630// 
     631//      // Make sure that this attribute is non-empty for every client. 
     632//      if (0 != dm) 
     633//      { 
     634//        lonvalue.resize(dm); 
     635//        latvalue.resize(dm); 
     636//      } 
     637// 
     638// 
     639//      for (int i = 0; i < zoom_ni_client; i++) 
     640//      { 
     641//        for (int j = 0; j < zoom_nj_client; j++) 
     642//        { 
     643//          lonvalue(i + j * zoom_ni_client) = lonvalue_temp( (i + zoom_ibegin_client-ibegin) + (j + zoom_jbegin_client -jbegin)*ni ); 
     644//          latvalue(i + j * zoom_ni_client) = latvalue_temp( (i + zoom_ibegin_client - ibegin)+(j + zoom_jbegin_client - jbegin)*ni ); 
     645//          if (hasBounds) 
     646//          { 
     647//            for(int n=0;n<nvertex;n++) 
     648//            { 
     649//              bounds_lon(n,i + j * zoom_ni_client) = bounds_lon_temp( n, (i + zoom_ibegin_client - ibegin) + (j + zoom_jbegin_client -jbegin)*ni ); 
     650//              bounds_lat(n,i + j * zoom_ni_client) = bounds_lat_temp( n, (i + zoom_ibegin_client - ibegin)+(j + zoom_jbegin_client -jbegin)*ni ); 
     651//            } 
     652//          } 
     653//        } 
     654//      } 
     655    } 
     656 
     657 
     658   //---------------------------------------------------------------- 
     659 
    559660   void CDomain::checkZoom(void) 
    560661   { 
    561       // compute client zoom indices 
    562       // compute client zoom indices 
    563 //      if (0 == global_zoom_ni) global_zoom_ni = ni_glo; 
    564 //      if (0 == global_zoom_nj) global_zoom_nj = nj_glo; 
    565  
    566662      int global_zoom_iend=global_zoom_ibegin+global_zoom_ni-1 ; 
    567663      zoom_ibegin_client = ibegin_client > global_zoom_ibegin ? ibegin_client : global_zoom_ibegin ; 
     
    580676   void CDomain::checkBounds(void) 
    581677   { 
    582      if (!nvertex.isEmpty() && !bounds_lon.isEmpty() && !bounds_lat.isEmpty()) 
    583      { 
     678     if (!nvertex.isEmpty() && (0 != nvertex.getValue())) 
     679     { 
     680       if (!bounds_lon_1d.isEmpty() && !bounds_lon_2d.isEmpty()) 
     681         ERROR("CDomain::checkBounds(void)", 
     682              <<"Only one longitude boundary value can be used but both bounds_lon_1d and bounds_lon_2d are defined! "<<endl 
     683              <<"Define only one longitude boundary value: lonvalue_1d or bounds_lon_2d "); 
     684 
     685       if (!bounds_lat_1d.isEmpty() && !bounds_lat_2d.isEmpty()) 
     686         ERROR("CDomain::checkBounds(void)", 
     687              <<"Only one latitude boundary value can be used but both bounds_lat_1d and bounds_lat_2d are defined! "<<endl 
     688              <<"Define only one latitude boundary value: bounds_lat_1d or bounds_lat_2d "); 
     689 
     690       if ((!bounds_lon_1d.isEmpty() && bounds_lat_1d.isEmpty()) || (bounds_lon_1d.isEmpty() && !bounds_lat_1d.isEmpty())) 
     691       { 
     692         ERROR("CDomain::checkBounds(void)", 
     693           <<"Only bounds_lon_1d or bounds_lat_1d is defined "<<endl 
     694           <<"Both must be defined "); 
     695       } 
     696 
     697       if ((!bounds_lon_2d.isEmpty() && bounds_lat_2d.isEmpty()) || (bounds_lon_2d.isEmpty() && !bounds_lat_2d.isEmpty())) 
     698       { 
     699         ERROR("CDomain::checkBounds(void)", 
     700           <<"Only bounds_lon_2d or bounds_lat_2d is defined "<<endl 
     701           <<"Both must be defined "); 
     702       } 
     703 
     704       if (!bounds_lon_1d.isEmpty() && (nvertex.getValue() != bounds_lon_1d.extent(0))) 
     705          ERROR("CDomain::checkBounds(void)", 
     706                <<"Only bounds_lon_1d and nvertex are not compatible"<<endl 
     707                <<"bounds_lon_1d dimension is " << bounds_lon_1d.extent(1) 
     708                <<"but nvertex is " << nvertex.getValue()); 
     709 
     710       if (!bounds_lon_2d.isEmpty() && (nvertex.getValue() != bounds_lon_2d.extent(0))) 
     711          ERROR("CDomain::checkBounds(void)", 
     712                <<"Only bounds_lon_2d and nvertex are not compatible"<<endl 
     713                <<"bounds_lon_2d dimension is " << bounds_lon_1d.extent(2) 
     714                <<"but nvertex is " << nvertex.getValue()); 
     715 
     716       if (!bounds_lon_1d.isEmpty() && lonvalue_1d.isEmpty()) 
     717           ERROR("CDomain::checkBounds(void)", 
     718                <<"Both bounds_lon_1d and lonvalue_1d must be defined"<<endl); 
     719 
     720       if (!bounds_lon_2d.isEmpty() && lonvalue_2d.isEmpty()) 
     721           ERROR("CDomain::checkBounds(void)", 
     722                <<"Both bounds_lon_1d and lonvalue_1d must be defined"<<endl); 
     723 
     724       if (!bounds_lat_1d.isEmpty() && (nvertex.getValue() != bounds_lat_1d.extent(0))) 
     725          ERROR("CDomain::checkBounds(void)", 
     726                <<"Only bounds_lat_1d and nvertex are not compatible"<<endl 
     727                <<"bounds_lat_1d dimension is " << bounds_lat_1d.extent(1) 
     728                <<"but nvertex is " << nvertex.getValue()); 
     729 
     730       if (!bounds_lat_2d.isEmpty() && (nvertex.getValue() != bounds_lat_2d.extent(0))) 
     731          ERROR("CDomain::checkBounds(void)", 
     732                <<"Only bounds_lat_2d and nvertex are not compatible"<<endl 
     733                <<"bounds_lat_2d dimension is " << bounds_lat_1d.extent(2) 
     734                <<"but nvertex is " << nvertex.getValue()); 
     735 
     736       if (!bounds_lat_1d.isEmpty() && latvalue_1d.isEmpty()) 
     737           ERROR("CDomain::checkBounds(void)", 
     738                <<"Both bounds_lat_1d and latvalue_1d must be defined"<<endl); 
     739 
     740       if (!bounds_lat_2d.isEmpty() && latvalue_2d.isEmpty()) 
     741           ERROR("CDomain::checkBounds(void)", 
     742                <<"Both bounds_lat_1d and latvalue_1d must be defined"<<endl); 
    584743       hasBounds=true ; 
    585744     } 
     
    604763   } 
    605764 
    606 //   void CDomain::checkAttributesOnClientBeforeTransformation() 
    607 //   { 
    608 //      if (this->isClientBeforeTransformationChecked) return; 
    609 //      CContext* context=CContext::getCurrent(); 
    610 // 
    611 //      this->checkDomain(); 
    612 //      this->checkBounds(); 
    613 //      this->checkArea(); 
    614 // 
    615 //      if (context->hasClient) 
    616 //      { 
    617 //        this->checkDomainData(); 
    618 //        this->checkCompression(); 
    619 //      } 
    620 // 
    621 //      this->isClientBeforeTransformationChecked = true; 
    622 //   } 
    623  
    624765   void CDomain::checkAttributesOnClientAfterTransformation() 
    625766   { 
     
    639780 
    640781   //---------------------------------------------------------------- 
    641    // Divide function checkAttributes into 2 seperate ones 
     782   // Divide function checkAttributes into 2 seperate onescheckBounds 
    642783   // This function only checks all attributes of current domain 
    643784   void CDomain::checkAttributesOnClient() 
     
    658799      else 
    659800      { // CÃŽté serveur uniquement 
    660 //         if (!this->isEmpty()) 
    661 // ne sert plus //   this->completeLonLatServer(); 
    662801      } 
    663802 
     
    676815     if (context->hasClient) 
    677816     { 
    678 //       this->computeConnectedServer(); 
    679 //       this->completeLonLatClient(); 
    680  
    681817       sendServerAttribut() ; 
    682818       sendLonLatArea() ; 
     
    705841      else 
    706842      { // CÃŽté serveur uniquement 
    707 //         if (!this->isEmpty()) 
    708 // ne sert plus //   this->completeLonLatServer(); 
    709843      } 
    710844 
     
    9321066        i = i_index(idx); 
    9331067        j = j_index(idx); 
    934         ind = n; 
    935 //        ind = (i - zoom_ibegin_client) + (j - zoom_jbegin_client) * zoom_ni_client; 
    936  
    937         lon(n) = lonvalue(ind); 
    938         lat(n) = latvalue(ind); 
     1068        ind = (i - zoom_ibegin_client) + (j - zoom_jbegin_client) * zoom_ni_client; 
     1069 
     1070        lon(n) = lonvalue_client(ind); 
     1071        lat(n) = latvalue_client(ind); 
    9391072 
    9401073        if (hasBounds) 
     
    9451078          for (nv = 0; nv < nvertex; nv++) 
    9461079          { 
    947             boundslon(nv, n) = bounds_lon(nv, ind); 
    948             boundslat(nv, n) = bounds_lat(nv, ind); 
     1080            boundslon(nv, n) = bounds_lon_client(nv, ind); 
     1081            boundslat(nv, n) = bounds_lat_client(nv, ind); 
    9491082          } 
    9501083        } 
Note: See TracChangeset for help on using the changeset viewer.