Ignore:
Timestamp:
01/23/19 10:31:44 (5 years ago)
Author:
yushan
Message:

dev on ADA. add flag switch _usingEP/_usingMPI

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/branch_openmp/src/node/domain.cpp

    r1545 r1642  
    1919#include "client_server_mapping_distributed.hpp" 
    2020 
    21 using namespace ep_lib; 
    22  
    2321#include <algorithm> 
    2422 
     
    3230      , hasBounds(false), hasArea(false), isCompressible_(false), isUnstructed_(false) 
    3331      , isClientAfterTransformationChecked(false), hasLonLat(false) 
    34       , isRedistributed_(false), hasPole(false), doZoomByIndex_(false) 
     32      , isRedistributed_(false), hasPole(false) 
    3533      , lonvalue(), latvalue(), bounds_lonvalue(), bounds_latvalue() 
    3634      , globalLocalIndexMap_(), computedWrittenIndex_(false) 
    37           , clients() 
     35      , clients(), hasLatInReadFile_(false), hasBoundsLatInReadFile_(false) 
     36      , hasLonInReadFile_(false), hasBoundsLonInReadFile_(false) 
    3837   { 
    3938   } 
     
    4443      , hasBounds(false), hasArea(false), isCompressible_(false), isUnstructed_(false) 
    4544      , isClientAfterTransformationChecked(false), hasLonLat(false) 
    46       , isRedistributed_(false), hasPole(false), doZoomByIndex_(false) 
     45      , isRedistributed_(false), hasPole(false) 
    4746      , lonvalue(), latvalue(), bounds_lonvalue(), bounds_latvalue() 
    4847      , globalLocalIndexMap_(), computedWrittenIndex_(false) 
    49           , clients() 
     48      , clients(), hasLatInReadFile_(false), hasBoundsLatInReadFile_(false) 
     49      , hasLonInReadFile_(false), hasBoundsLonInReadFile_(false) 
    5050   { 
    5151    } 
     
    5858 
    5959   void CDomain::assignMesh(const StdString meshName, const int nvertex) 
     60   TRY 
    6061   { 
    6162     mesh = CMesh::getMesh(meshName, nvertex); 
    6263   } 
     64   CATCH_DUMP_ATTR 
    6365 
    6466   CDomain* CDomain::createDomain() 
     67   TRY 
    6568   { 
    6669     CDomain* domain = CDomainGroup::get("domain_definition")->createChild(); 
    6770     return domain; 
    6871   } 
    69  
    70    std::map<StdString, ETranformationType> *CDomain::transformationMapList_ptr = 0; 
     72   CATCH 
     73 
     74   std::map<StdString, ETranformationType> CDomain::transformationMapList_ = std::map<StdString, ETranformationType>(); 
     75   bool CDomain::_dummyTransformationMapList = CDomain::initializeTransformationMap(CDomain::transformationMapList_); 
    7176 
    7277   bool CDomain::initializeTransformationMap(std::map<StdString, ETranformationType>& m) 
     78   TRY 
    7379   { 
    7480     m["zoom_domain"] = TRANS_ZOOM_DOMAIN; 
     
    7884     m["expand_domain"] = TRANS_EXPAND_DOMAIN; 
    7985     m["reorder_domain"] = TRANS_REORDER_DOMAIN; 
    80    } 
    81  
    82    bool CDomain::initializeTransformationMap() 
    83    { 
    84      CDomain::transformationMapList_ptr = new std::map<StdString, ETranformationType>(); 
    85      (*CDomain::transformationMapList_ptr)["zoom_domain"] = TRANS_ZOOM_DOMAIN; 
    86      (*CDomain::transformationMapList_ptr)["interpolate_domain"] = TRANS_INTERPOLATE_DOMAIN; 
    87      (*CDomain::transformationMapList_ptr)["generate_rectilinear_domain"] = TRANS_GENERATE_RECTILINEAR_DOMAIN; 
    88      (*CDomain::transformationMapList_ptr)["compute_connectivity_domain"] = TRANS_COMPUTE_CONNECTIVITY_DOMAIN; 
    89      (*CDomain::transformationMapList_ptr)["expand_domain"] = TRANS_EXPAND_DOMAIN; 
    90      (*CDomain::transformationMapList_ptr)["reorder_domain"] = TRANS_REORDER_DOMAIN; 
    91    } 
     86     m["extract_domain"] = TRANS_EXTRACT_DOMAIN; 
     87   } 
     88   CATCH 
    9289 
    9390   const std::set<StdString> & CDomain::getRelFiles(void) const 
     91   TRY 
    9492   { 
    9593      return (this->relFiles); 
    9694   } 
    97  
     95   CATCH 
    9896 
    9997   /*! 
     
    102100   */ 
    103101   int CDomain::getNumberWrittenIndexes(ep_lib::MPI_Comm writtenCom) 
     102   TRY 
    104103   { 
    105104     int writtenSize; 
     
    107106     return numberWrittenIndexes_[writtenSize]; 
    108107   } 
     108   CATCH_DUMP_ATTR 
    109109 
    110110   /*! 
     
    113113   */ 
    114114   int CDomain::getTotalNumberWrittenIndexes(ep_lib::MPI_Comm writtenCom) 
     115   TRY 
    115116   { 
    116117     int writtenSize; 
     
    118119     return totalNumberWrittenIndexes_[writtenSize]; 
    119120   } 
     121   CATCH_DUMP_ATTR 
    120122 
    121123   /*! 
     
    124126   */ 
    125127   int CDomain::getOffsetWrittenIndexes(ep_lib::MPI_Comm writtenCom) 
     128   TRY 
    126129   { 
    127130     int writtenSize; 
     
    129132     return offsetWrittenIndexes_[writtenSize]; 
    130133   } 
     134   CATCH_DUMP_ATTR 
    131135 
    132136   CArray<int, 1>& CDomain::getCompressedIndexToWriteOnServer(ep_lib::MPI_Comm writtenCom) 
     137   TRY 
    133138   { 
    134139     int writtenSize; 
     
    136141     return compressedIndexToWriteOnServer[writtenSize]; 
    137142   } 
     143   CATCH_DUMP_ATTR 
    138144 
    139145   //---------------------------------------------------------------- 
     
    145151    */ 
    146152   std::map<int, StdSize> CDomain::getAttributesBufferSize(CContextClient* client, bool bufferForWriting /*= false*/) 
     153   TRY 
    147154   { 
    148155 
     
    172179       // size estimation for sendIndex (and sendArea which is always smaller or equal) 
    173180       size_t sizeIndexEvent = 2 * sizeof(size_t) + 2 * CArray<int,1>::size(idxCount); 
    174        // if (isCompressible_) 
    175        // { 
    176        //   std::map<int, std::vector<int> >::const_iterator itWritten = indWrittenSrv_.find(rank); 
    177        //   size_t writtenIdxCount = (itWritten != itWrittenIndexEnd) ? itWritten->second.size() : 0; 
    178        //   sizeIndexEvent += CArray<int,1>::size(writtenIdxCount); 
    179        // } 
    180181 
    181182       // size estimation for sendLonLat 
     
    191192     return attributesSizes; 
    192193   } 
     194   CATCH_DUMP_ATTR 
    193195 
    194196   //---------------------------------------------------------------- 
    195197 
    196198   bool CDomain::isEmpty(void) const 
    197    { 
    198       return ((this->zoom_i_index.isEmpty()) || (0 == this->zoom_i_index.numElements())); 
    199  
    200    } 
     199   TRY 
     200   { 
     201     return ((this->i_index.isEmpty()) || (0 == this->i_index.numElements())); 
     202   } 
     203   CATCH 
    201204 
    202205   //---------------------------------------------------------------- 
    203206 
    204207   bool CDomain::IsWritten(const StdString & filename) const 
     208   TRY 
    205209   { 
    206210      return (this->relFiles.find(filename) != this->relFiles.end()); 
    207211   } 
     212   CATCH 
    208213 
    209214   bool CDomain::isWrittenCompressed(const StdString& filename) const 
     215   TRY 
    210216   { 
    211217      return (this->relFilesCompressed.find(filename) != this->relFilesCompressed.end()); 
    212218   } 
     219   CATCH 
    213220 
    214221   //---------------------------------------------------------------- 
    215222 
    216223   bool CDomain::isDistributed(void) const 
     224   TRY 
    217225   { 
    218226      bool distributed =  !((!ni.isEmpty() && (ni == ni_glo) && !nj.isEmpty() && (nj == nj_glo)) || 
     
    222230      return distributed; 
    223231   } 
     232   CATCH 
    224233 
    225234   //---------------------------------------------------------------- 
     
    231240    */ 
    232241   bool CDomain::isCompressible(void) const 
     242   TRY 
    233243   { 
    234244      return isCompressible_; 
    235245   } 
     246   CATCH 
    236247 
    237248   void CDomain::addRelFile(const StdString & filename) 
     249   TRY 
    238250   { 
    239251      this->relFiles.insert(filename); 
    240252   } 
     253   CATCH_DUMP_ATTR 
    241254 
    242255   void CDomain::addRelFileCompressed(const StdString& filename) 
     256   TRY 
    243257   { 
    244258      this->relFilesCompressed.insert(filename); 
    245259   } 
     260   CATCH_DUMP_ATTR 
    246261 
    247262   StdString CDomain::GetName(void)   { return (StdString("domain")); } 
     
    256271   */ 
    257272   bool CDomain::distributionAttributesHaveValue() const 
     273   TRY 
    258274   { 
    259275      bool hasValues = true; 
     
    267283      return hasValues; 
    268284   } 
     285   CATCH 
    269286 
    270287   /*! 
     
    276293   */ 
    277294   void CDomain::redistribute(int nbLocalDomain) 
     295   TRY 
    278296   { 
    279297     if (this->isRedistributed_) return; 
     
    438456     checkDomain(); 
    439457   } 
     458   CATCH_DUMP_ATTR 
    440459 
    441460   /*! 
     
    443462   */ 
    444463   void CDomain::fillInLonLat() 
     464   TRY 
    445465   { 
    446466     switch (type) 
     
    460480     } 
    461481     completeLonLatClient() ; 
    462  
    463    } 
     482   } 
     483   CATCH_DUMP_ATTR 
    464484 
    465485   /*! 
     
    469489   */ 
    470490   void CDomain::fillInRectilinearLonLat() 
    471    { 
    472      if (!lonvalue_rectilinear_read_from_file.isEmpty()) 
     491   TRY 
     492   { 
     493     if (!lonvalue_rectilinear_read_from_file.isEmpty() && lonvalue_2d.isEmpty() && lonvalue_1d.isEmpty()) 
    473494     { 
    474495       lonvalue_1d.resize(ni); 
     
    478499       lon_end.setValue(lonvalue_rectilinear_read_from_file(ni_glo-1)); 
    479500     } 
    480      else 
     501     else if (!hasLonInReadFile_) 
    481502     { 
    482503       if (!lonvalue_2d.isEmpty()) lonvalue_2d.free(); 
     
    504525 
    505526 
    506      if (!latvalue_rectilinear_read_from_file.isEmpty()) 
     527     if (!latvalue_rectilinear_read_from_file.isEmpty() && latvalue_2d.isEmpty() && latvalue_1d.isEmpty()) 
    507528     { 
    508529       latvalue_1d.resize(nj); 
     
    512533       lat_end.setValue(latvalue_rectilinear_read_from_file(nj_glo-1)); 
    513534     } 
    514      else 
     535     else if (!hasLatInReadFile_) 
    515536     { 
    516537       if (!latvalue_2d.isEmpty()) latvalue_1d.free(); 
     
    537558     } 
    538559   } 
     560   CATCH_DUMP_ATTR 
    539561 
    540562    /* 
    541       Fill in longitude and latitude of curvilinear domain read from a file 
    542       If there are already longitude and latitude defined by model. We just igonore reading value. 
     563      Fill in 2D longitude and latitude of curvilinear domain read from a file. 
     564      If there are already longitude and latitude defined by model. We just ignore read value. 
    543565    */ 
    544566   void CDomain::fillInCurvilinearLonLat() 
    545    { 
    546      if (!lonvalue_curvilinear_read_from_file.isEmpty() && lonvalue_2d.isEmpty()) 
     567   TRY 
     568   { 
     569     if (!lonvalue_curvilinear_read_from_file.isEmpty() && lonvalue_2d.isEmpty() && lonvalue_1d.isEmpty()) 
    547570     { 
    548571       lonvalue_2d.resize(ni,nj); 
     
    554577     } 
    555578 
    556      if (!latvalue_curvilinear_read_from_file.isEmpty() && latvalue_2d.isEmpty()) 
     579     if (!latvalue_curvilinear_read_from_file.isEmpty() && latvalue_2d.isEmpty() && latvalue_1d.isEmpty()) 
    557580     { 
    558581       latvalue_2d.resize(ni,nj); 
     
    564587     } 
    565588 
    566      if (!bounds_lonvalue_curvilinear_read_from_file.isEmpty() && bounds_lon_2d.isEmpty()) 
     589     if (!bounds_lonvalue_curvilinear_read_from_file.isEmpty() && bounds_lon_2d.isEmpty() && bounds_lon_1d.isEmpty()) 
    567590     { 
    568591       bounds_lon_2d.resize(nvertex,ni,nj); 
     
    575598     } 
    576599 
    577      if (!bounds_latvalue_curvilinear_read_from_file.isEmpty() && bounds_lat_2d.isEmpty()) 
     600     if (!bounds_latvalue_curvilinear_read_from_file.isEmpty() && bounds_lat_2d.isEmpty() && bounds_lat_1d.isEmpty()) 
    578601     { 
    579602       bounds_lat_2d.resize(nvertex,ni,nj); 
     
    585608       bounds_latvalue_curvilinear_read_from_file.free(); 
    586609     } 
    587  
    588    } 
     610   } 
     611   CATCH_DUMP_ATTR 
    589612 
    590613    /* 
     
    593616    */ 
    594617   void CDomain::fillInUnstructuredLonLat() 
     618   TRY 
    595619   { 
    596620     if (i_index.isEmpty()) 
     
    644668     } 
    645669   } 
     670   CATCH_DUMP_ATTR 
    646671 
    647672  /* 
     
    649674  */ 
    650675   void CDomain::AllgatherRectilinearLonLat(CArray<double,1>& lon, CArray<double,1>& lat, CArray<double,1>& lon_g, CArray<double,1>& lat_g) 
     676   TRY 
    651677   { 
    652678     CContext* context = CContext::getCurrent(); 
     
    664690     int v ; 
    665691     v=ibegin ; 
    666      ep_lib::MPI_Allgather(&v,1,MPI_INT,ibegin_g,1,MPI_INT,client->intraComm) ; 
     692     ep_lib::MPI_Allgather(&v,1,EP_INT,ibegin_g,1,EP_INT,client->intraComm) ; 
    667693     v=jbegin ; 
    668      ep_lib::MPI_Allgather(&v,1,MPI_INT,jbegin_g,1,MPI_INT,client->intraComm) ; 
     694     ep_lib::MPI_Allgather(&v,1,EP_INT,jbegin_g,1,EP_INT,client->intraComm) ; 
    669695     v=ni ; 
    670      ep_lib::MPI_Allgather(&v,1,MPI_INT,ni_g,1,MPI_INT,client->intraComm) ; 
     696     ep_lib::MPI_Allgather(&v,1,EP_INT,ni_g,1,EP_INT,client->intraComm) ; 
    671697     v=nj ; 
    672      ep_lib::MPI_Allgather(&v,1,MPI_INT,nj_g,1,MPI_INT,client->intraComm) ; 
    673  
    674      ep_lib::MPI_Allgatherv(lon.dataFirst(),ni,MPI_DOUBLE,lon_g.dataFirst(),ni_g, ibegin_g,MPI_DOUBLE,client->intraComm) ; 
    675      ep_lib::MPI_Allgatherv(lat.dataFirst(),nj,MPI_DOUBLE,lat_g.dataFirst(),nj_g, jbegin_g,MPI_DOUBLE,client->intraComm) ; 
     698     ep_lib::MPI_Allgather(&v,1,EP_INT,nj_g,1,EP_INT,client->intraComm) ; 
     699 
     700     ep_lib::MPI_Allgatherv(lon.dataFirst(),ni,EP_DOUBLE,lon_g.dataFirst(),ni_g, ibegin_g,EP_DOUBLE,client->intraComm) ; 
     701     ep_lib::MPI_Allgatherv(lat.dataFirst(),nj,EP_DOUBLE,lat_g.dataFirst(),nj_g, jbegin_g,EP_DOUBLE,client->intraComm) ; 
    676702 
    677703      delete[] ibegin_g ; 
     
    680706      delete[] nj_g ; 
    681707   } 
     708   CATCH_DUMP_ATTR 
    682709 
    683710   void CDomain::fillInRectilinearBoundLonLat(CArray<double,1>& lon, CArray<double,1>& lat, 
    684711                                              CArray<double,2>& boundsLon, CArray<double,2>& boundsLat) 
    685    { 
     712   TRY 
     713  { 
    686714     int i,j,k; 
    687715 
     
    782810      } 
    783811   } 
     812   CATCH_DUMP_ATTR 
    784813 
    785814   /* 
     
    787816   */ 
    788817   void CDomain::checkDomain(void) 
     818   TRY 
    789819   { 
    790820     if (type.isEmpty()) 
     
    877907         for (int i = 0; i < ni; ++i) j_index(i+j*ni) = j+jbegin; 
    878908     } 
    879       
    880      checkZoom(); 
    881    } 
    882  
    883    // Check global zoom of a domain 
    884    // If there is no zoom defined for the domain, zoom will have value of global doamin 
    885    void CDomain::checkZoom(void) 
    886    { 
    887      if (global_zoom_ibegin.isEmpty()) 
    888       global_zoom_ibegin.setValue(0); 
    889      if (global_zoom_ni.isEmpty()) 
    890       global_zoom_ni.setValue(ni_glo); 
    891      if (global_zoom_jbegin.isEmpty()) 
    892       global_zoom_jbegin.setValue(0); 
    893      if (global_zoom_nj.isEmpty()) 
    894       global_zoom_nj.setValue(nj_glo); 
    895     if (zoom_i_index.isEmpty()) zoom_i_index.setValue(i_index.getValue()); 
    896     if (zoom_j_index.isEmpty()) zoom_j_index.setValue(j_index.getValue()); 
    897     if (zoom_ibegin.isEmpty()) zoom_ibegin.setValue(ibegin); 
    898     if (zoom_ni.isEmpty()) zoom_ni.setValue(ni); 
    899     if (zoom_jbegin.isEmpty()) zoom_jbegin.setValue(jbegin); 
    900     if (zoom_nj.isEmpty()) zoom_nj.setValue(nj); 
    901    } 
     909   } 
     910   CATCH_DUMP_ATTR 
    902911 
    903912   size_t CDomain::getGlobalWrittenSize(void) 
    904913   { 
    905       return global_zoom_ni*global_zoom_nj ; 
     914     return ni_glo*nj_glo ; 
    906915   } 
    907916   //---------------------------------------------------------------- 
     
    909918   // Check validity of local domain on using the combination of 3 parameters: ibegin, ni and i_index 
    910919   void CDomain::checkLocalIDomain(void) 
     920   TRY 
    911921   { 
    912922      // If ibegin and ni are provided then we use them to check the validity of local domain 
     
    967977      } 
    968978   } 
     979   CATCH_DUMP_ATTR 
    969980 
    970981   // Check validity of local domain on using the combination of 3 parameters: jbegin, nj and j_index 
    971982   void CDomain::checkLocalJDomain(void) 
     983   TRY 
    972984   { 
    973985    // If jbegin and nj are provided then we use them to check the validity of local domain 
     
    10181030     } 
    10191031   } 
     1032   CATCH_DUMP_ATTR 
    10201033 
    10211034   //---------------------------------------------------------------- 
    10221035 
    10231036   void CDomain::checkMask(void) 
     1037   TRY 
    10241038   { 
    10251039      if (!mask_1d.isEmpty() && !mask_2d.isEmpty()) 
     
    10671081     } 
    10681082   } 
     1083   CATCH_DUMP_ATTR 
    10691084 
    10701085   //---------------------------------------------------------------- 
    10711086 
    10721087   void CDomain::checkDomainData(void) 
     1088   TRY 
    10731089   { 
    10741090      if (data_dim.isEmpty()) 
     
    11101126      } 
    11111127   } 
     1128   CATCH_DUMP_ATTR 
    11121129 
    11131130   //---------------------------------------------------------------- 
    11141131 
    11151132   void CDomain::checkCompression(void) 
    1116    { 
     1133   TRY 
     1134   { 
     1135     int i,j,ind; 
    11171136      if (!data_i_index.isEmpty()) 
    11181137      { 
     
    11351154                   << "'data_j_index' must be defined when 'data_i_index' is set and 'data_dim' is 2."); 
    11361155          } 
     1156          for (int k=0; k<data_i_index.numElements(); ++k) 
     1157          { 
     1158            i = data_i_index(k)+data_ibegin ; 
     1159            j = data_j_index(k)+data_jbegin ; 
     1160            if (i>=0 && i<ni && j>=0 && j<nj) 
     1161            { 
     1162              ind=j*ni+i ; 
     1163              if (!domainMask(ind)) 
     1164              { 
     1165                data_i_index(k) = -1; 
     1166                data_j_index(k) = -1; 
     1167              } 
     1168            } 
     1169            else 
     1170            { 
     1171              data_i_index(k) = -1; 
     1172              data_j_index(k) = -1; 
     1173            } 
     1174          } 
    11371175        } 
    11381176        else // (1 == data_dim) 
     
    11411179          { 
    11421180            data_j_index.resize(data_ni); 
    1143             for (int j = 0; j < data_ni; ++j) data_j_index(j) = 0; 
     1181            data_j_index = 0; 
     1182          } 
     1183          for (int k=0; k<data_i_index.numElements(); ++k) 
     1184          { 
     1185            i=data_i_index(k)+data_ibegin ; 
     1186            if (i>=0 && i < domainMask.size()) 
     1187            { 
     1188              if (!domainMask(i)) data_i_index(k) = -1; 
     1189            } 
     1190            else 
     1191              data_i_index(k) = -1; 
     1192 
     1193            if (!domainMask(i)) data_i_index(k) = -1; 
    11441194          } 
    11451195        } 
     
    11561206          data_i_index.resize(data_ni); 
    11571207          data_j_index.resize(data_ni); 
    1158  
    1159           for (int i = 0; i < data_ni; ++i) 
     1208          data_j_index = 0; 
     1209 
     1210          for (int k = 0; k < data_ni; ++k) 
    11601211          { 
    1161             data_i_index(i) = i; 
    1162             data_j_index(i) = 0; 
     1212            i=k+data_ibegin ; 
     1213            if (i>=0 && i < domainMask.size()) 
     1214            { 
     1215              if (domainMask(i)) 
     1216                data_i_index(k) = k; 
     1217              else 
     1218                data_i_index(k) = -1; 
     1219            } 
     1220            else 
     1221              data_i_index(k) = -1; 
    11631222          } 
    11641223        } 
     
    11691228          data_j_index.resize(dsize); 
    11701229 
    1171           for(int count = 0, j = 0; j < data_nj; ++j) 
     1230          for(int count = 0, kj = 0; kj < data_nj; ++kj) 
    11721231          { 
    1173             for(int i = 0; i < data_ni; ++i, ++count) 
     1232            for(int ki = 0; ki < data_ni; ++ki, ++count) 
    11741233            { 
    1175               data_i_index(count) = i; 
    1176               data_j_index(count) = j; 
     1234              i = ki + data_ibegin; 
     1235              j = kj + data_jbegin; 
     1236              ind=j*ni+i ; 
     1237              if (i>=0 && i<ni && j>=0 && j<nj) 
     1238              { 
     1239                if (domainMask(ind)) 
     1240                { 
     1241                  data_i_index(count) = ki; 
     1242                  data_j_index(count) = kj; 
     1243                } 
     1244                else 
     1245                { 
     1246                  data_i_index(count) = -1; 
     1247                  data_j_index(count) = -1; 
     1248                } 
     1249              } 
     1250              else 
     1251              { 
     1252                data_i_index(count) = -1; 
     1253                data_j_index(count) = -1; 
     1254              } 
    11771255            } 
    11781256          } 
     
    11801258      } 
    11811259   } 
     1260   CATCH_DUMP_ATTR 
    11821261 
    11831262   //---------------------------------------------------------------- 
    11841263   void CDomain::computeLocalMask(void) 
     1264   TRY 
    11851265   { 
    11861266     localMask.resize(i_index.numElements()) ; 
     
    12141294     } 
    12151295   } 
     1296   CATCH_DUMP_ATTR 
    12161297 
    12171298   void CDomain::checkEligibilityForCompressedOutput(void) 
     1299   TRY 
    12181300   { 
    12191301     // We don't check if the mask or the indexes are valid here, just if they have been defined at this point. 
    12201302     isCompressible_ = !mask_1d.isEmpty() || !mask_2d.isEmpty() || !data_i_index.isEmpty(); 
    12211303   } 
     1304   CATCH_DUMP_ATTR 
    12221305 
    12231306   //---------------------------------------------------------------- 
    12241307 
    12251308   /* 
    1226      Fill in longitude and latitude value from clients (or models) into internal values lonvalue, latvalue which 
    1227      will be used by XIOS. 
     1309     Fill in longitude, latitude, bounds, and area into internal values (lonvalue, latvalue, bounds_lonvalue, bounds_latvalue, areavalue) 
     1310     which will be used by XIOS. 
    12281311   */ 
    12291312   void CDomain::completeLonLatClient(void) 
     1313   TRY 
    12301314   { 
    12311315     bool lonlatValueExisted = (0 != lonvalue.numElements()) || (0 != latvalue.numElements()); 
    12321316     checkBounds() ; 
     1317     checkArea() ; 
     1318 
    12331319     if (!lonvalue_2d.isEmpty() && !lonlatValueExisted) 
    12341320     { 
     
    13251411       } 
    13261412     } 
    1327    } 
     1413 
     1414     if (!area.isEmpty() && areavalue.isEmpty()) 
     1415     { 
     1416        areavalue.resize(ni*nj); 
     1417       for (int j = 0; j < nj; ++j) 
     1418       { 
     1419         for (int i = 0; i < ni; ++i) 
     1420         { 
     1421           int k = j * ni + i; 
     1422           areavalue(k) = area(i,j); 
     1423         } 
     1424       } 
     1425     } 
     1426   } 
     1427   CATCH_DUMP_ATTR 
    13281428 
    13291429   /* 
     
    13311431   */ 
    13321432   void CDomain::convertLonLatValue(void) 
     1433   TRY 
    13331434   { 
    13341435     bool lonlatValueExisted = (0 != lonvalue.numElements()) || (0 != latvalue.numElements()); 
     
    14281529     } 
    14291530   } 
    1430  
     1531   CATCH_DUMP_ATTR 
    14311532 
    14321533   void CDomain::checkBounds(void) 
     1534   TRY 
    14331535   { 
    14341536     bool hasBoundValues = (0 != bounds_lonvalue.numElements()) || (0 != bounds_latvalue.numElements()); 
     
    14671569               << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " 
    14681570               << "'bounds_lon_1d' dimension is not compatible with 'nvertex'." << std::endl 
    1469                << "'bounds_lon_1d' dimension is " << bounds_lon_1d.extent(1) 
     1571               << "'bounds_lon_1d' dimension is " << bounds_lon_1d.extent(0) 
    14701572               << " but nvertex is " << nvertex.getValue() << "."); 
    14711573 
     
    14741576               << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " 
    14751577               << "'bounds_lon_2d' dimension is not compatible with 'nvertex'." << std::endl 
    1476                << "'bounds_lon_2d' dimension is " << bounds_lon_2d.extent(2) 
     1578               << "'bounds_lon_2d' dimension is " << bounds_lon_2d.extent(0) 
    14771579               << " but nvertex is " << nvertex.getValue() << "."); 
    14781580 
     
    14911593               << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " 
    14921594               << "'bounds_lat_1d' dimension is not compatible with 'nvertex'." << std::endl 
    1493                << "'bounds_lat_1d' dimension is " << bounds_lat_1d.extent(1) 
     1595               << "'bounds_lat_1d' dimension is " << bounds_lat_1d.extent(0) 
    14941596               << " but nvertex is " << nvertex.getValue() << "."); 
    14951597 
     
    14981600               << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " 
    14991601               << "'bounds_lat_2d' dimension is not compatible with 'nvertex'." << std::endl 
    1500                << "'bounds_lat_2d' dimension is " << bounds_lat_2d.extent(2) 
     1602               << "'bounds_lat_2d' dimension is " << bounds_lat_2d.extent(0) 
    15011603               << " but nvertex is " << nvertex.getValue() << "."); 
    15021604 
     
    15221624     } 
    15231625   } 
     1626   CATCH_DUMP_ATTR 
    15241627 
    15251628   void CDomain::checkArea(void) 
     1629   TRY 
    15261630   { 
    15271631     bool hasAreaValue = (!areavalue.isEmpty() && 0 != areavalue.numElements()); 
     
    15371641               << "Area size is " << area.extent(0) << " x " << area.extent(1) << "."); 
    15381642       } 
    1539        if (areavalue.isEmpty()) 
    1540        { 
    1541           areavalue.resize(ni*nj); 
    1542          for (int j = 0; j < nj; ++j) 
    1543          { 
    1544            for (int i = 0; i < ni; ++i) 
    1545            { 
    1546              int k = j * ni + i; 
    1547              areavalue(k) = area(i,j); 
    1548            } 
    1549          } 
    1550        } 
    1551      } 
    1552    } 
     1643//       if (areavalue.isEmpty()) 
     1644//       { 
     1645//          areavalue.resize(ni*nj); 
     1646//         for (int j = 0; j < nj; ++j) 
     1647//         { 
     1648//           for (int i = 0; i < ni; ++i) 
     1649//           { 
     1650//             int k = j * ni + i; 
     1651//             areavalue(k) = area(i,j); 
     1652//           } 
     1653//         } 
     1654//       } 
     1655     } 
     1656   } 
     1657   CATCH_DUMP_ATTR 
    15531658 
    15541659   void CDomain::checkLonLat() 
     1660   TRY 
    15551661   { 
    15561662     if (!hasLonLat) hasLonLat = (!latvalue_1d.isEmpty() && !lonvalue_1d.isEmpty()) || 
     
    16121718     } 
    16131719   } 
     1720   CATCH_DUMP_ATTR 
    16141721 
    16151722   void CDomain::checkAttributesOnClientAfterTransformation() 
     1723   TRY 
    16161724   { 
    16171725     CContext* context=CContext::getCurrent() ; 
     
    16281736     this->isClientAfterTransformationChecked = true; 
    16291737   } 
     1738   CATCH_DUMP_ATTR 
    16301739 
    16311740   //---------------------------------------------------------------- 
     
    16331742   // This function only checks all attributes of current domain 
    16341743   void CDomain::checkAttributesOnClient() 
     1744   TRY 
    16351745   { 
    16361746     if (this->isClientChecked) return; 
     
    16581768      this->isClientChecked = true; 
    16591769   } 
     1770   CATCH_DUMP_ATTR 
    16601771 
    16611772   // Send all checked attributes to server 
    16621773   void CDomain::sendCheckedAttributes() 
     1774   TRY 
    16631775   { 
    16641776     if (!this->isClientChecked) checkAttributesOnClient(); 
     
    16731785     this->isChecked = true; 
    16741786   } 
     1787   CATCH_DUMP_ATTR 
    16751788 
    16761789   void CDomain::checkAttributes(void) 
     1790   TRY 
    16771791   { 
    16781792      if (this->isChecked) return; 
     
    17041818      this->isChecked = true; 
    17051819   } 
     1820   CATCH_DUMP_ATTR 
    17061821 
    17071822  /*! 
     
    17121827  */ 
    17131828  void CDomain::computeConnectedClients() 
     1829  TRY 
    17141830  { 
    17151831    CContext* context=CContext::getCurrent() ; 
     
    17341850        if (indSrv_.find(nbServer) == indSrv_.end()) 
    17351851        { 
    1736           int i,j,i_ind,j_ind, nbIndex, nbIndexZoom; 
    1737           int global_zoom_iend=global_zoom_ibegin+global_zoom_ni-1; 
    1738           int global_zoom_jend=global_zoom_jbegin+global_zoom_nj-1; 
    1739  
    1740            // Precompute number of index 
    1741            int globalIndexCountZoom = 0; 
    1742            nbIndex = i_index.numElements(); 
    1743  
    1744            if (doZoomByIndex_) 
    1745            { 
    1746              globalIndexCountZoom = zoom_i_index.numElements(); 
    1747            } 
    1748            else 
    1749            { 
    1750              for (i = 0; i < nbIndex; ++i) 
    1751              { 
    1752                i_ind=i_index(i); 
    1753                j_ind=j_index(i); 
    1754  
    1755                if (i_ind >= global_zoom_ibegin && i_ind <= global_zoom_iend && j_ind >= global_zoom_jbegin && j_ind <= global_zoom_jend) 
    1756                { 
    1757                   ++globalIndexCountZoom; 
    1758                } 
    1759              } 
    1760            } 
    1761  
    1762            // Fill in index 
    1763            CArray<size_t,1> globalIndexDomainZoom(globalIndexCountZoom); 
    1764            CArray<size_t,1> localIndexDomainZoom(globalIndexCountZoom); 
    1765            CArray<size_t,1> globalIndexDomain(nbIndex); 
    1766            size_t globalIndex; 
    1767            int globalIndexCount = 0; 
    1768  
    1769            for (i = 0; i < nbIndex; ++i) 
    1770            { 
    1771              i_ind=i_index(i); 
    1772              j_ind=j_index(i); 
    1773              globalIndex = i_ind + j_ind * ni_glo; 
    1774              globalIndexDomain(i) = globalIndex; 
    1775            } 
    1776  
    1777            if (globalLocalIndexMap_.empty()) 
    1778            { 
    1779              for (i = 0; i < nbIndex; ++i) 
    1780                globalLocalIndexMap_[globalIndexDomain(i)] = i; 
    1781            } 
    1782  
    1783            globalIndexCountZoom = 0; 
    1784            if (doZoomByIndex_) 
    1785            { 
    1786              int nbIndexZoom = zoom_i_index.numElements(); 
    1787  
    1788              for (i = 0; i < nbIndexZoom; ++i) 
    1789              { 
    1790                i_ind=zoom_i_index(i); 
    1791                j_ind=zoom_j_index(i); 
    1792                globalIndex = i_ind + j_ind * ni_glo; 
    1793                globalIndexDomainZoom(globalIndexCountZoom) = globalIndex; 
    1794                ++globalIndexCountZoom; 
    1795              } 
    1796            } 
    1797            else 
    1798            { 
    1799              int global_zoom_iend=global_zoom_ibegin+global_zoom_ni-1; 
    1800              int global_zoom_jend=global_zoom_jbegin+global_zoom_nj-1; 
    1801              for (i = 0; i < nbIndex; ++i) 
    1802              { 
    1803                i_ind=i_index(i); 
    1804                j_ind=j_index(i); 
    1805                globalIndex = i_ind + j_ind * ni_glo; 
    1806                if (i_ind >= global_zoom_ibegin && i_ind <= global_zoom_iend && j_ind >= global_zoom_jbegin && j_ind <= global_zoom_jend) 
    1807                { 
    1808                   globalIndexDomainZoom(globalIndexCountZoom) = globalIndex; 
    1809                   ++globalIndexCountZoom; 
    1810                } 
    1811              } 
    1812  
    1813              int iend = ibegin + ni -1; 
    1814              int jend = jbegin + nj -1; 
    1815              zoom_ibegin = global_zoom_ibegin > ibegin ? global_zoom_ibegin.getValue() : ibegin; 
    1816              int zoom_iend  = global_zoom_iend < iend ? zoom_iend : iend ; 
    1817              zoom_ni     = zoom_iend-zoom_ibegin+1 ; 
    1818  
    1819              zoom_jbegin = global_zoom_jbegin > jbegin ? global_zoom_jbegin.getValue() : jbegin ; 
    1820              int zoom_jend   = global_zoom_jend < jend ? zoom_jend : jend; 
    1821              zoom_nj     = zoom_jend-zoom_jbegin+1; 
    1822            } 
    1823  
    1824            size_t globalSizeIndex = 1, indexBegin, indexEnd; 
    1825            int range, clientSize = client->clientSize; 
    1826            std::vector<int> nGlobDomain(2); 
    1827            nGlobDomain[0] = this->ni_glo; 
    1828            nGlobDomain[1] = this->nj_glo; 
    1829            for (int i = 0; i < nGlobDomain.size(); ++i) globalSizeIndex *= nGlobDomain[i]; 
    1830            indexBegin = 0; 
    1831            if (globalSizeIndex <= clientSize) 
    1832            { 
    1833              indexBegin = rank%globalSizeIndex; 
    1834              indexEnd = indexBegin; 
    1835            } 
    1836            else 
    1837            { 
    1838              for (int i = 0; i < clientSize; ++i) 
    1839              { 
    1840                range = globalSizeIndex / clientSize; 
    1841                if (i < (globalSizeIndex%clientSize)) ++range; 
    1842                if (i == client->clientRank) break; 
    1843                indexBegin += range; 
    1844              } 
    1845              indexEnd = indexBegin + range - 1; 
    1846            } 
    1847  
    1848            // Even if servers have no index, they must received something from client 
    1849            // We only use several client to send "empty" message to these servers 
    1850            CServerDistributionDescription serverDescription(nGlobDomain, nbServer); 
    1851            std::vector<int> serverZeroIndex; 
    1852            if (isUnstructed_) serverZeroIndex = serverDescription.computeServerGlobalIndexInRange(std::make_pair<size_t&,size_t&>(indexBegin, indexEnd), 0); 
    1853            else serverZeroIndex = serverDescription.computeServerGlobalIndexInRange(std::make_pair<size_t&,size_t&>(indexBegin, indexEnd), 1); 
    1854  
    1855            std::list<int> serverZeroIndexLeader; 
    1856            std::list<int> serverZeroIndexNotLeader; 
    1857            CContextClient::computeLeader(client->clientRank, client->clientSize, serverZeroIndex.size(), serverZeroIndexLeader, serverZeroIndexNotLeader); 
    1858            for (std::list<int>::iterator it = serverZeroIndexLeader.begin(); it != serverZeroIndexLeader.end(); ++it) 
    1859               *it = serverZeroIndex[*it]; 
    1860  
    1861            CClientServerMapping* clientServerMap = new CClientServerMappingDistributed(serverDescription.getGlobalIndexRange(), 
    1862                  client->intraComm); 
    1863            clientServerMap->computeServerIndexMapping(globalIndexDomain, nbServer); 
    1864            CClientServerMapping::GlobalIndexMap& globalIndexDomainOnServer = clientServerMap->getGlobalIndexOnServer(); 
    1865  
    1866            CClientServerMapping::GlobalIndexMap::const_iterator it  = globalIndexDomainOnServer.begin(), 
     1852          int i,j,i_ind,j_ind, nbIndex=i_index.numElements(); 
     1853          int globalIndexCount = i_index.numElements(); 
     1854          // Fill in index 
     1855          CArray<size_t,1> globalIndexDomain(nbIndex); 
     1856          size_t globalIndex; 
     1857 
     1858          for (i = 0; i < nbIndex; ++i) 
     1859          { 
     1860            i_ind=i_index(i); 
     1861            j_ind=j_index(i); 
     1862            globalIndex = i_ind + j_ind * ni_glo; 
     1863            globalIndexDomain(i) = globalIndex; 
     1864          } 
     1865 
     1866          if (globalLocalIndexMap_.empty()) 
     1867          { 
     1868            for (i = 0; i < nbIndex; ++i) 
     1869              globalLocalIndexMap_[globalIndexDomain(i)] = i; 
     1870          } 
     1871 
     1872          size_t globalSizeIndex = 1, indexBegin, indexEnd; 
     1873          int range, clientSize = client->clientSize; 
     1874          std::vector<int> nGlobDomain(2); 
     1875          nGlobDomain[0] = this->ni_glo; 
     1876          nGlobDomain[1] = this->nj_glo; 
     1877          for (int i = 0; i < nGlobDomain.size(); ++i) globalSizeIndex *= nGlobDomain[i]; 
     1878          indexBegin = 0; 
     1879          if (globalSizeIndex <= clientSize) 
     1880          { 
     1881            indexBegin = rank%globalSizeIndex; 
     1882            indexEnd = indexBegin; 
     1883          } 
     1884          else 
     1885          { 
     1886            for (int i = 0; i < clientSize; ++i) 
     1887            { 
     1888              range = globalSizeIndex / clientSize; 
     1889              if (i < (globalSizeIndex%clientSize)) ++range; 
     1890              if (i == client->clientRank) break; 
     1891              indexBegin += range; 
     1892            } 
     1893            indexEnd = indexBegin + range - 1; 
     1894          } 
     1895 
     1896          // Even if servers have no index, they must received something from client 
     1897          // We only use several client to send "empty" message to these servers 
     1898          CServerDistributionDescription serverDescription(nGlobDomain, nbServer); 
     1899          std::vector<int> serverZeroIndex; 
     1900          if (isUnstructed_) serverZeroIndex = serverDescription.computeServerGlobalIndexInRange(std::make_pair<size_t&,size_t&>(indexBegin, indexEnd), 0); 
     1901          else serverZeroIndex = serverDescription.computeServerGlobalIndexInRange(std::make_pair<size_t&,size_t&>(indexBegin, indexEnd), 1); 
     1902 
     1903          std::list<int> serverZeroIndexLeader; 
     1904          std::list<int> serverZeroIndexNotLeader; 
     1905          CContextClient::computeLeader(client->clientRank, client->clientSize, serverZeroIndex.size(), serverZeroIndexLeader, serverZeroIndexNotLeader); 
     1906          for (std::list<int>::iterator it = serverZeroIndexLeader.begin(); it != serverZeroIndexLeader.end(); ++it) 
     1907            *it = serverZeroIndex[*it]; 
     1908 
     1909          CClientServerMapping* clientServerMap = new CClientServerMappingDistributed(serverDescription.getGlobalIndexRange(), client->intraComm); 
     1910          clientServerMap->computeServerIndexMapping(globalIndexDomain, nbServer); 
     1911          CClientServerMapping::GlobalIndexMap& globalIndexDomainOnServer = clientServerMap->getGlobalIndexOnServer(); 
     1912 
     1913          CClientServerMapping::GlobalIndexMap::const_iterator it  = globalIndexDomainOnServer.begin(), 
    18671914                 ite = globalIndexDomainOnServer.end(); 
    1868            indSrv_[nbServer].swap(globalIndexDomainOnServer); 
    1869            connectedServerRank_[nbServer].clear(); 
    1870            for (it = indSrv_[nbServer].begin(); it != ite; ++it) 
    1871              connectedServerRank_[nbServer].push_back(it->first); 
    1872  
    1873            for (std::list<int>::const_iterator it = serverZeroIndexLeader.begin(); it != serverZeroIndexLeader.end(); ++it) 
    1874               connectedServerRank_[nbServer].push_back(*it); 
    1875  
    1876            // Even if a client has no index, it must connect to at least one server and 
    1877            // send an "empty" data to this server 
    1878            if (connectedServerRank_[nbServer].empty()) 
    1879               connectedServerRank_[nbServer].push_back(client->clientRank % client->serverSize); 
    1880  
    1881            nbSenders[nbServer] = clientServerMap->computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerRank_[nbServer]); 
    1882            delete clientServerMap; 
     1915          indSrv_[nbServer].swap(globalIndexDomainOnServer); 
     1916          connectedServerRank_[nbServer].clear(); 
     1917          for (it = indSrv_[nbServer].begin(); it != ite; ++it) 
     1918            connectedServerRank_[nbServer].push_back(it->first); 
     1919 
     1920          for (std::list<int>::const_iterator it = serverZeroIndexLeader.begin(); it != serverZeroIndexLeader.end(); ++it) 
     1921            connectedServerRank_[nbServer].push_back(*it); 
     1922 
     1923          // Even if a client has no index, it must connect to at least one server and 
     1924          // send an "empty" data to this server 
     1925          if (connectedServerRank_[nbServer].empty()) 
     1926            connectedServerRank_[nbServer].push_back(client->clientRank % client->serverSize); 
     1927 
     1928          // Now check if all servers have data to receive. If not, master client will send empty data. 
     1929          // This ensures that all servers will participate in collective calls upon receiving even if they have no date to receive. 
     1930          std::vector<int> counts (clientSize); 
     1931          std::vector<int> displs (clientSize); 
     1932          displs[0] = 0; 
     1933          int localCount = connectedServerRank_[nbServer].size() ; 
     1934          ep_lib::MPI_Gather(&localCount, 1, EP_INT, &counts[0], 1, EP_INT, 0, client->intraComm) ; 
     1935          for (int i = 0; i < clientSize-1; ++i) 
     1936          { 
     1937            displs[i+1] = displs[i] + counts[i]; 
     1938          } 
     1939          std::vector<int> allConnectedServers(displs[clientSize-1]+counts[clientSize-1]); 
     1940          ep_lib::MPI_Gatherv(&(connectedServerRank_[nbServer])[0], localCount, EP_INT, &allConnectedServers[0], &counts[0], &displs[0], EP_INT, 0, client->intraComm); 
     1941 
     1942          if ((allConnectedServers.size() != nbServer) && (rank == 0)) 
     1943          { 
     1944            std::vector<bool> isSrvConnected (nbServer, false); 
     1945            for (int i = 0; i < allConnectedServers.size(); ++i) isSrvConnected[allConnectedServers[i]] = true; 
     1946            for (int i = 0; i < nbServer; ++i) 
     1947            { 
     1948              if (!isSrvConnected[i]) connectedServerRank_[nbServer].push_back(i); 
     1949            } 
     1950          } 
     1951          nbSenders[nbServer] = clientServerMap->computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerRank_[nbServer]); 
     1952          delete clientServerMap; 
    18831953        } 
    18841954      } 
    18851955    } 
    18861956  } 
     1957  CATCH_DUMP_ATTR 
    18871958 
    18881959   /*! 
     
    18921963   */ 
    18931964   void CDomain::computeWrittenIndex() 
     1965   TRY 
    18941966   {   
    18951967      if (computedWrittenIndex_) return; 
     
    19001972 
    19011973      std::vector<int> nBegin(2), nSize(2), nBeginGlobal(2), nGlob(2); 
    1902       nBegin[0]       = zoom_ibegin;  nBegin[1] = zoom_jbegin; 
    1903       nSize[0]        = zoom_ni;      nSize[1]  = zoom_nj; 
     1974      nBegin[0]       = ibegin;  nBegin[1] = jbegin; 
     1975      nSize[0]        = ni;      nSize[1]  = nj; 
    19041976      nBeginGlobal[0] = 0; nBeginGlobal[1] = 0; 
    19051977      nGlob[0]        = ni_glo;   nGlob[1] = nj_glo; 
     
    19131985                                       itSrve = writtenGlobalIndex.end(), itSrv; 
    19141986 
    1915 //      for (itSrv = itSrvb; itSrv != itSrve; ++itSrv) 
    1916 //      { 
    1917 //        indGlo = *itSrv; 
    1918 //        if (ite != globalLocalIndexMap_.find(indGlo)) 
    1919 //        { 
    1920 //          ++nbWritten; 
    1921 //        } 
    1922 //      } 
    1923  
    1924 //      localIndexToWriteOnServer.resize(nbWritten); 
    19251987      localIndexToWriteOnServer.resize(writtenGlobalIndex.numElements()); 
    1926  
    19271988      nbWritten = 0; 
    19281989      for (itSrv = itSrvb; itSrv != itSrve; ++itSrv) 
     
    19321993        { 
    19331994          localIndexToWriteOnServer(nbWritten) = globalLocalIndexMap_[indGlo]; 
    1934           ++nbWritten; 
    19351995        } 
    19361996        else 
    19371997        { 
    1938           localIndexToWriteOnServer(nbWritten) = 0; 
    1939           ++nbWritten; 
    1940         } 
    1941       } 
    1942    } 
     1998          localIndexToWriteOnServer(nbWritten) = -1; 
     1999        } 
     2000        ++nbWritten; 
     2001      } 
     2002   } 
     2003   CATCH_DUMP_ATTR 
    19432004 
    19442005  void CDomain::computeWrittenCompressedIndex(ep_lib::MPI_Comm writtenComm) 
     2006  TRY 
    19452007  { 
    19462008    int writtenCommSize; 
     
    19562018 
    19572019      std::vector<int> nBegin(2), nSize(2), nBeginGlobal(2), nGlob(2); 
    1958       nBegin[0]       = zoom_ibegin;  nBegin[1] = zoom_jbegin; 
    1959       nSize[0]        = zoom_ni;      nSize[1]  = zoom_nj; 
     2020      nBegin[0]       = ibegin;  nBegin[1] = jbegin; 
     2021      nSize[0]        = ni;      nSize[1]  = nj; 
    19602022      nBeginGlobal[0] = 0; nBeginGlobal[1] = 0; 
    19612023      nGlob[0]        = ni_glo;   nGlob[1] = nj_glo; 
     
    20022064      { 
    20032065              
    2004         ep_lib::MPI_Allreduce(&numberWrittenIndexes_[writtenCommSize], &totalNumberWrittenIndexes_[writtenCommSize], 1, MPI_INT, MPI_SUM, writtenComm); 
    2005         ep_lib::MPI_Scan(&numberWrittenIndexes_[writtenCommSize], &offsetWrittenIndexes_[writtenCommSize], 1, MPI_INT, MPI_SUM, writtenComm); 
     2066        ep_lib::MPI_Allreduce(&numberWrittenIndexes_[writtenCommSize], &totalNumberWrittenIndexes_[writtenCommSize], 1, EP_INT, EP_SUM, writtenComm); 
     2067        ep_lib::MPI_Scan(&numberWrittenIndexes_[writtenCommSize], &offsetWrittenIndexes_[writtenCommSize], 1, EP_INT, EP_SUM, writtenComm); 
    20062068        offsetWrittenIndexes_[writtenCommSize] -= numberWrittenIndexes_[writtenCommSize]; 
    20072069      } 
     
    20102072      } 
    20112073  } 
     2074  CATCH_DUMP_ATTR 
    20122075 
    20132076  /*! 
     
    20162079  */ 
    20172080  void CDomain::sendAttributes() 
     2081  TRY 
    20182082  { 
    20192083    sendDistributionAttributes(); 
    20202084    sendIndex();        
    2021     sendMask(); 
    20222085    sendLonLat(); 
    20232086    sendArea();     
    20242087    sendDataIndex(); 
    20252088  } 
    2026  
     2089  CATCH 
    20272090  /*! 
    2028     Send global index and zoom index from client to connected client(s) 
    2029     zoom index can be smaller than global index 
     2091    Send global index from client to connected client(s) 
    20302092  */ 
    20312093  void CDomain::sendIndex() 
     2094  TRY 
    20322095  { 
    20332096    int ns, n, i, j, ind, nv, idx; 
     
    20412104 
    20422105      list<CMessage> list_msgsIndex; 
    2043       list<CArray<int,1> > list_indZoom, list_writtenInd, list_indGlob; 
     2106      list<CArray<int,1> > list_indGlob; 
    20442107 
    20452108      std::unordered_map<int, vector<size_t> >::const_iterator itIndex, iteIndex; 
     
    20722135    } 
    20732136  } 
     2137  CATCH_DUMP_ATTR 
    20742138 
    20752139  /*! 
     
    20792143  */ 
    20802144  void CDomain::sendDistributionAttributes(void) 
     2145  TRY 
    20812146  { 
    20822147    std::list<CContextClient*>::iterator it; 
     
    21152180          msg << isUnstructed_; 
    21162181          msg << ni_srv << ibegin_srv << nj_srv << jbegin_srv; 
    2117           msg << global_zoom_ni.getValue() << global_zoom_ibegin.getValue() << global_zoom_nj.getValue() << global_zoom_jbegin.getValue();         
     2182          msg << ni_glo.getValue() << nj_glo.getValue(); 
    21182183          msg << isCompressible_; 
    21192184 
     
    21252190    } 
    21262191  } 
    2127  
    2128   /*! 
    2129     Send mask index from client to connected(s) clients     
    2130   */ 
    2131   void CDomain::sendMask() 
    2132   { 
    2133     int ns, n, i, j, ind, nv, idx; 
    2134     std::list<CContextClient*>::iterator it; 
    2135     for (it=clients.begin(); it!=clients.end(); ++it) 
    2136     { 
    2137       CContextClient* client = *it; 
    2138       int serverSize = client->serverSize; 
    2139  
    2140       // send area for each connected server 
    2141       CEventClient eventMask(getType(), EVENT_ID_MASK); 
    2142  
    2143       list<CMessage> list_msgsMask; 
    2144       list<CArray<bool,1> > list_mask; 
    2145  
    2146       std::unordered_map<int, vector<size_t> >::const_iterator it, iteMap; 
    2147       iteMap = indSrv_[serverSize].end(); 
    2148       for (int k = 0; k < connectedServerRank_[serverSize].size(); ++k) 
    2149       { 
    2150         int nbData = 0; 
    2151         int rank = connectedServerRank_[serverSize][k]; 
    2152         it = indSrv_[serverSize].find(rank); 
    2153         if (iteMap != it) 
    2154           nbData = it->second.size(); 
    2155         list_mask.push_back(CArray<bool,1>(nbData)); 
    2156  
    2157         const std::vector<size_t>& temp = it->second; 
    2158         for (n = 0; n < nbData; ++n) 
    2159         { 
    2160           idx = static_cast<int>(it->second[n]); 
    2161           list_mask.back()(n) = domainMask(globalLocalIndexMap_[idx]); 
    2162         } 
    2163  
    2164         list_msgsMask.push_back(CMessage()); 
    2165         list_msgsMask.back() << this->getId() << list_mask.back(); 
    2166         eventMask.push(rank, nbSenders[serverSize][rank], list_msgsMask.back()); 
    2167       } 
    2168       client->sendEvent(eventMask); 
    2169     } 
    2170   } 
     2192  CATCH_DUMP_ATTR 
    21712193 
    21722194  /*! 
     
    21742196  */ 
    21752197  void CDomain::sendArea() 
     2198  TRY 
    21762199  { 
    21772200    if (!hasArea) return; 
     
    22172240    } 
    22182241  } 
     2242  CATCH_DUMP_ATTR 
    22192243 
    22202244  /*! 
     
    22242248  */ 
    22252249  void CDomain::sendLonLat() 
     2250  TRY 
    22262251  { 
    22272252    if (!hasLonLat) return; 
     
    23122337    } 
    23132338  } 
     2339  CATCH_DUMP_ATTR 
    23142340 
    23152341  /*! 
     
    23202346  */ 
    23212347  void CDomain::sendDataIndex() 
     2348  TRY 
    23222349  { 
    23232350    int ns, n, i, j, ind, nv, idx; 
     
    23882415    } 
    23892416  } 
     2417  CATCH 
    23902418   
    23912419  bool CDomain::dispatchEvent(CEventServer& event) 
     2420  TRY 
    23922421  { 
    23932422    if (SuperClass::dispatchEvent(event)) return true; 
     
    24022431        case EVENT_ID_INDEX: 
    24032432          recvIndex(event); 
    2404           return true; 
    2405           break; 
    2406         case EVENT_ID_MASK: 
    2407           recvMask(event); 
    24082433          return true; 
    24092434          break; 
     
    24312456    } 
    24322457  } 
     2458  CATCH 
    24332459 
    24342460  /*! 
     
    24372463  */ 
    24382464  void CDomain::recvIndex(CEventServer& event) 
     2465  TRY 
    24392466  { 
    24402467    string domainId; 
     
    24502477    get(domainId)->recvIndex(rankBuffers); 
    24512478  } 
     2479  CATCH 
    24522480 
    24532481  /*! 
     
    24572485  */ 
    24582486  void CDomain::recvIndex(std::map<int, CBufferIn*>& rankBuffers) 
     2487  TRY 
    24592488  { 
    24602489    int nbReceived = rankBuffers.size(), i, ind, index, type_int, iIndex, jIndex; 
     
    24952524           jIndex = (jIndex < 0) ? 0 : jIndex; 
    24962525           nbIndLoc = iIndex + ni * jIndex; 
    2497            if (nbIndLoc < nbIndexGlobMax) 
    2498            { 
    2499              i_index(nbIndLoc) = index % ni_glo; 
    2500              j_index(nbIndLoc) = index / ni_glo; 
    2501              globalLocalIndexMap_[index] = nbIndLoc;   
    2502              ++nbIndGlob; 
    2503            } 
    2504            // i_index(nbIndGlob) = index % ni_glo; 
    2505            // j_index(nbIndGlob) = index / ni_glo; 
    2506            // globalLocalIndexMap_[index] = nbIndGlob;   
    2507            // ++nbIndGlob; 
     2526           i_index(nbIndGlob) = index % ni_glo; 
     2527           j_index(nbIndGlob) = index / ni_glo; 
     2528           globalLocalIndexMap_[index] = nbIndGlob; 
     2529           ++nbIndGlob; 
    25082530         }  
    25092531      }  
     
    25202542      j_index.resizeAndPreserve(nbIndGlob); 
    25212543    } 
     2544 
     2545    domainMask.resize(0); // Mask is not defined anymore on servers 
    25222546  } 
     2547  CATCH 
    25232548 
    25242549  /*! 
     
    25272552  */ 
    25282553  void CDomain::recvDistributionAttributes(CEventServer& event) 
     2554  TRY 
    25292555  { 
    25302556    CBufferIn* buffer=event.subEvents.begin()->buffer; 
     
    25332559    get(domainId)->recvDistributionAttributes(*buffer); 
    25342560  } 
     2561  CATCH 
    25352562 
    25362563  /*! 
    2537     Receive attributes from client(s): zoom info and begin and n of each server 
     2564    Receive attributes from client(s) 
    25382565    \param[in] rank rank of client source 
    25392566    \param[in] buffer message containing attributes info 
    25402567  */ 
    25412568  void CDomain::recvDistributionAttributes(CBufferIn& buffer) 
     2569  TRY 
    25422570  { 
    25432571    int ni_tmp, ibegin_tmp, nj_tmp, jbegin_tmp; 
    2544     int global_zoom_ni_tmp, global_zoom_ibegin_tmp, global_zoom_nj_tmp, global_zoom_jbegin_tmp; 
     2572    int ni_glo_tmp, nj_glo_tmp; 
    25452573    buffer >> isUnstructed_ >> ni_tmp >> ibegin_tmp >> nj_tmp >> jbegin_tmp 
    2546            >> global_zoom_ni_tmp >> global_zoom_ibegin_tmp >> global_zoom_nj_tmp >> global_zoom_jbegin_tmp            
     2574           >> ni_glo_tmp >> nj_glo_tmp 
    25472575           >> isCompressible_; 
     2576 
    25482577    ni.setValue(ni_tmp); 
    25492578    ibegin.setValue(ibegin_tmp); 
    25502579    nj.setValue(nj_tmp); 
    25512580    jbegin.setValue(jbegin_tmp); 
    2552  
    2553     global_zoom_ni.setValue(global_zoom_ni_tmp); 
    2554     global_zoom_ibegin.setValue(global_zoom_ibegin_tmp); 
    2555     global_zoom_nj.setValue(global_zoom_nj_tmp); 
    2556     global_zoom_jbegin.setValue(global_zoom_jbegin_tmp); 
    2557  
    2558     int iend = ibegin + ni  - 1; 
    2559     int jend = jbegin + nj  - 1; 
    2560     int zoom_iend_glob = global_zoom_ibegin + global_zoom_ni - 1; 
    2561     int zoom_jend_glob = global_zoom_jbegin + global_zoom_nj - 1; 
    2562  
    2563     zoom_ibegin.setValue(global_zoom_ibegin > ibegin ? global_zoom_ibegin.getValue() : ibegin); 
    2564     int zoom_iend = zoom_iend_glob < iend ? zoom_iend_glob : iend ; 
    2565     zoom_ni.setValue(zoom_iend-zoom_ibegin+1); 
    2566  
    2567     zoom_jbegin.setValue(global_zoom_jbegin > jbegin ? global_zoom_jbegin.getValue() : jbegin); 
    2568     int zoom_jend = zoom_jend_glob < jend ? zoom_jend_glob : jend ; 
    2569     zoom_nj.setValue(zoom_jend-zoom_jbegin+1); 
    2570  
    2571     if (zoom_ni<=0 || zoom_nj<=0) 
    2572     { 
    2573       zoom_ni=0 ; zoom_ibegin=global_zoom_ibegin ; //=0; zoom_iend=0 ;  
    2574       zoom_nj=0 ; zoom_jbegin=global_zoom_jbegin ; //=0; zoom_jend=0 ; 
    2575     } 
     2581    ni_glo.setValue(ni_glo_tmp); 
     2582    nj_glo.setValue(nj_glo_tmp); 
    25762583 
    25772584  } 
    2578  
    2579   /*! 
    2580     Receive area event from clients(s) 
    2581     \param[in] event event contain info about rank and associated area 
    2582   */ 
    2583   void CDomain::recvMask(CEventServer& event) 
    2584   { 
    2585     string domainId; 
    2586     std::map<int, CBufferIn*> rankBuffers; 
    2587  
    2588     list<CEventServer::SSubEvent>::iterator it; 
    2589     for (it = event.subEvents.begin(); it != event.subEvents.end(); ++it) 
    2590     {       
    2591       CBufferIn* buffer = it->buffer; 
    2592       *buffer >> domainId; 
    2593       rankBuffers[it->rank] = buffer;      
    2594     } 
    2595     get(domainId)->recvMask(rankBuffers); 
    2596   } 
    2597  
    2598  
    2599   /*! 
    2600     Receive mask information from client(s) 
    2601     \param[in] rankBuffers rank of sending client and the corresponding receive buffer   
    2602   */ 
    2603   void CDomain::recvMask(std::map<int, CBufferIn*>& rankBuffers) 
    2604   { 
    2605     int nbReceived = rankBuffers.size(), i, ind, index, lInd; 
    2606     if (nbReceived != recvClientRanks_.size()) 
    2607       ERROR("void CDomain::recvMask(std::map<int, CBufferIn*>& rankBuffers)", 
    2608            << "The number of sending clients is not correct." 
    2609            << "Expected number: " << recvClientRanks_.size() << " but received " << nbReceived); 
    2610  
    2611     vector<CArray<bool,1> > recvMaskValue(nbReceived);       
    2612     for (i = 0; i < recvClientRanks_.size(); ++i) 
    2613     { 
    2614       int rank = recvClientRanks_[i]; 
    2615       CBufferIn& buffer = *(rankBuffers[rank]);       
    2616       buffer >> recvMaskValue[i]; 
    2617     } 
    2618  
    2619     int nbMaskInd = 0; 
    2620     for (i = 0; i < nbReceived; ++i) 
    2621     { 
    2622       nbMaskInd += recvMaskValue[i].numElements(); 
    2623     } 
    2624    
    2625     if (nbMaskInd != globalLocalIndexMap_.size()) 
    2626       info (0) << "If domain " << this->getDomainOutputName() <<" does not have overlapped regions between processes " 
    2627                << "something must be wrong with mask index "<< std::endl; 
    2628  
    2629     nbMaskInd = globalLocalIndexMap_.size(); 
    2630     mask_1d.resize(nbMaskInd); 
    2631     domainMask.resize(nbMaskInd); 
    2632     mask_1d = false; 
    2633      
    2634     for (i = 0; i < nbReceived; ++i) 
    2635     { 
    2636       CArray<int,1>& tmpInd = indGlob_[recvClientRanks_[i]]; 
    2637       CArray<bool,1>& tmp = recvMaskValue[i]; 
    2638       for (ind = 0; ind < tmp.numElements(); ++ind) 
    2639       { 
    2640         lInd = globalLocalIndexMap_[size_t(tmpInd(ind))]; 
    2641         if (!mask_1d(lInd)) // Only rewrite mask_1d if it's not true 
    2642           mask_1d(lInd) = tmp(ind); 
    2643       } 
    2644     } 
    2645     domainMask=mask_1d ; 
    2646   } 
    2647  
     2585 CATCH_DUMP_ATTR 
    26482586  /*! 
    26492587    Receive longitude event from clients(s) 
     
    26512589  */ 
    26522590  void CDomain::recvLon(CEventServer& event) 
     2591  TRY 
    26532592  { 
    26542593    string domainId; 
     
    26642603    get(domainId)->recvLon(rankBuffers); 
    26652604  } 
     2605  CATCH 
    26662606 
    26672607  /*! 
     
    26702610  */ 
    26712611  void CDomain::recvLon(std::map<int, CBufferIn*>& rankBuffers) 
     2612  TRY 
    26722613  { 
    26732614    int nbReceived = rankBuffers.size(), i, ind, index, iindex, jindex, lInd; 
     
    27292670    } 
    27302671  } 
     2672  CATCH_DUMP_ATTR 
    27312673 
    27322674  /*! 
     
    27352677  */ 
    27362678  void CDomain::recvLat(CEventServer& event) 
     2679  TRY 
    27372680  { 
    27382681    string domainId; 
     
    27482691    get(domainId)->recvLat(rankBuffers); 
    27492692  } 
     2693  CATCH 
    27502694 
    27512695  /*! 
     
    27542698  */ 
    27552699  void CDomain::recvLat(std::map<int, CBufferIn*>& rankBuffers) 
     2700  TRY 
    27562701  { 
    27572702    int nbReceived = rankBuffers.size(), i, ind, index, iindex, jindex, lInd; 
     
    28152760    } 
    28162761  } 
     2762  CATCH_DUMP_ATTR 
    28172763 
    28182764  /*! 
     
    28212767  */ 
    28222768  void CDomain::recvArea(CEventServer& event) 
     2769  TRY 
    28232770  { 
    28242771    string domainId; 
     
    28342781    get(domainId)->recvArea(rankBuffers); 
    28352782  } 
     2783  CATCH 
    28362784 
    28372785  /*! 
     
    28402788  */ 
    28412789  void CDomain::recvArea(std::map<int, CBufferIn*>& rankBuffers) 
     2790  TRY 
    28422791  { 
    28432792    int nbReceived = rankBuffers.size(), i, ind, index, lInd; 
     
    28852834    } 
    28862835  } 
     2836  CATCH_DUMP_ATTR 
    28872837 
    28882838  /*! 
     
    28942844  */ 
    28952845  bool CDomain::isEqual(CDomain* obj) 
     2846  TRY 
    28962847  { 
    28972848    vector<StdString> excludedAttr; 
     
    29162867    return objEqual; 
    29172868  } 
     2869  CATCH_DUMP_ATTR 
    29182870 
    29192871  /*! 
     
    29222874  */ 
    29232875  void CDomain::recvDataIndex(CEventServer& event) 
     2876  TRY 
    29242877  { 
    29252878    string domainId; 
     
    29352888    get(domainId)->recvDataIndex(rankBuffers); 
    29362889  } 
     2890  CATCH 
    29372891 
    29382892  /*! 
     
    29462900  */ 
    29472901  void CDomain::recvDataIndex(std::map<int, CBufferIn*>& rankBuffers) 
     2902  TRY 
    29482903  { 
    29492904    int nbReceived = rankBuffers.size(), i, ind, index, indexI, indexJ, type_int, lInd;     
     
    29822937         dataIIndex(lInd) = (-1 == dataIIndex(lInd)) ? tmpI(ind) : dataIIndex(lInd); // Only fill in dataIndex if there is no data 
    29832938         dataJIndex(lInd) = (-1 == dataJIndex(lInd)) ? tmpJ(ind) : dataJIndex(lInd);   
    2984  
    2985          if (!domainMask(lInd))   // Include mask info into data index on the RECEIVE getServerDimensionSizes     
    2986          { 
    2987            dataIIndex(lInd) = dataJIndex(lInd) = -1; 
    2988          } 
    29892939      }  
    29902940    } 
     
    30172967    data_jbegin.setValue(0); 
    30182968  } 
     2969  CATCH_DUMP_ATTR 
    30192970 
    30202971  CTransformation<CDomain>* CDomain::addTransformation(ETranformationType transType, const StdString& id) 
     2972  TRY 
    30212973  { 
    30222974    transformationMap_.push_back(std::make_pair(transType, CTransformation<CDomain>::createTransformation(transType,id))); 
    30232975    return transformationMap_.back().second; 
    30242976  } 
     2977  CATCH_DUMP_ATTR 
    30252978 
    30262979  /*! 
     
    30292982  */ 
    30302983  bool CDomain::hasTransformation() 
     2984  TRY 
    30312985  { 
    30322986    return (!transformationMap_.empty()); 
    30332987  } 
     2988  CATCH_DUMP_ATTR 
    30342989 
    30352990  /*! 
     
    30382993  */ 
    30392994  void CDomain::setTransformations(const TransMapTypes& domTrans) 
     2995  TRY 
    30402996  { 
    30412997    transformationMap_ = domTrans; 
    30422998  } 
     2999  CATCH_DUMP_ATTR 
    30433000 
    30443001  /*! 
     
    30473004  */ 
    30483005  CDomain::TransMapTypes CDomain::getAllTransformations(void) 
     3006  TRY 
    30493007  { 
    30503008    return transformationMap_; 
    30513009  } 
     3010  CATCH_DUMP_ATTR 
    30523011 
    30533012  void CDomain::duplicateTransformation(CDomain* src) 
     3013  TRY 
    30543014  { 
    30553015    if (src->hasTransformation()) 
     
    30583018    } 
    30593019  } 
     3020  CATCH_DUMP_ATTR 
    30603021 
    30613022  /*! 
     
    30633024   */ 
    30643025  void CDomain::solveInheritanceTransformation() 
     3026  TRY 
    30653027  { 
    30663028    if (hasTransformation() || !hasDirectDomainReference()) 
     
    30793041        refDomains[i]->setTransformations(domain->getAllTransformations()); 
    30803042  } 
     3043  CATCH_DUMP_ATTR 
    30813044 
    30823045  void CDomain::setContextClient(CContextClient* contextClient) 
     3046  TRY 
    30833047  { 
    30843048    if (clientsSet.find(contextClient)==clientsSet.end()) 
     
    30883052    } 
    30893053  } 
     3054  CATCH_DUMP_ATTR 
    30903055 
    30913056  /*! 
     
    30953060  */ 
    30963061  void CDomain::parse(xml::CXMLNode & node) 
     3062  TRY 
    30973063  { 
    30983064    SuperClass::parse(node); 
     
    31083074 
    31093075        nodeElementName = node.getElementName(); 
    3110         if(transformationMapList_ptr == 0) initializeTransformationMap(); 
    3111  
    3112         std::map<StdString, ETranformationType>::const_iterator ite = transformationMapList_ptr->end(), it; 
    3113  
    3114         it = transformationMapList_ptr->find(nodeElementName); 
     3076        std::map<StdString, ETranformationType>::const_iterator ite = transformationMapList_.end(), it; 
     3077        it = transformationMapList_.find(nodeElementName); 
    31153078        if (ite != it) 
    31163079        { 
     
    31283091    } 
    31293092  } 
     3093  CATCH_DUMP_ATTR 
    31303094   //---------------------------------------------------------------- 
    31313095 
Note: See TracChangeset for help on using the changeset viewer.