Ignore:
Timestamp:
01/22/21 12:00:29 (3 years ago)
Author:
yushan
Message:

Graph intermedia commit to a tmp branch

Location:
XIOS/dev/dev_trunk_graph/src/io
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/dev_trunk_graph/src/io/nc4_data_input.cpp

    r1612 r2019  
    4343  CATCH 
    4444 
    45   void CNc4DataInput::readFieldData_(CField* field) 
     45  void CNc4DataInput::readFieldData_(CField* field, int record, CArray<double,1>& dataOut) 
    4646  TRY 
    4747  { 
    4848    CContext* context = CContext::getCurrent(); 
    49     CContextServer* server = context->server; 
    50  
    51     CGrid* grid = field->grid; 
    52  
    53     if (!grid->doGridHaveDataToWrite()) 
    54       if (SuperClass::type==MULTI_FILE || !isCollective) return; 
     49 
     50    CGrid* grid = field->getGrid(); 
     51 
     52    if (!grid->doGridHaveDataToWrite())  if (SuperClass::type==MULTI_FILE || !isCollective) return; 
    5553 
    5654    StdString fieldId = field->getFieldOutputName(); 
    5755 
    58     CArray<double,1> fieldData(grid->getWrittenDataSize()); 
    59     if (!field->default_value.isEmpty()) fieldData = field->default_value; 
    60  
    6156    switch (SuperClass::type) 
    6257    { 
    6358      case MULTI_FILE: 
    64         SuperClassWriter::getData(fieldData, fieldId, isCollective, (field->getNStep() - 1)%field->nstepMax ); 
     59        SuperClassWriter::getData(dataOut, fieldId, isCollective, record ); 
    6560        break; 
    6661      case ONE_FILE: 
     
    109104        } 
    110105 
    111         SuperClassWriter::getData(fieldData, fieldId, isCollective, (field->getNStep() - 1)%field->nstepMax, &start, &count); 
     106        SuperClassWriter::getData(dataOut, fieldId, isCollective, record, &start, &count); 
    112107        break; 
    113108      } 
    114109    } 
    115  
    116     field->inputField(fieldData); 
    117  
    118     if (!field->scale_factor.isEmpty() || !field->add_offset.isEmpty()) 
    119     { 
    120       double scaleFactor = 1.0, addOffset = 0.0; 
    121       if (!field->scale_factor.isEmpty()) scaleFactor = field->scale_factor; 
    122       if (!field->add_offset.isEmpty()) addOffset = field->add_offset; 
    123       field->invertScaleFactorAddOffset(scaleFactor, addOffset); 
    124     } 
    125110  } 
    126111  CATCH 
     
    131116    StdString fieldId = field->getFieldOutputName(); 
    132117 
    133     CGrid* grid = field->grid; 
     118    CGrid* grid = field->getGrid(); 
    134119 
    135120    std::vector<CDomain*> domainP = grid->getDomains(); 
  • XIOS/dev/dev_trunk_graph/src/io/nc4_data_input.hpp

    r1486 r2019  
    3737    // Read methods 
    3838    virtual StdSize getFieldNbRecords_(CField* field); 
    39     virtual void readFieldData_(CField* field); 
     39    virtual void readFieldData_(CField* field, int record, CArray<double,1>& data); 
    4040    virtual void readFieldAttributes_(CField* field, bool readAttributeValues); 
    4141    virtual void closeFile_(void); 
  • XIOS/dev/dev_trunk_graph/src/io/nc4_data_output.cpp

    r1653 r2019  
    5757      { 
    5858        StdString lonName,latName ; 
    59           
    60         domain->computeWrittenIndex(); 
    61         domain->computeWrittenCompressedIndex(comm_file); 
    6259 
    6360        if (domain->type == CDomain::type_attr::unstructured) 
     
    7168 
    7269         CContext* context = CContext::getCurrent() ; 
    73          CContextServer* server=context->server ; 
    7470 
    7571         if (domain->IsWritten(this->filename)) return; 
     
    146142         string lonid,latid,bounds_lonid,bounds_latid ; 
    147143         string areaId = "area" + appendDomid; 
    148 /* 
    149          StdString lonid_loc = (server->intraCommSize > 1) 
    150                              ? StdString("lon").append(appendDomid).append("_local") 
    151                              : lonid; 
    152          StdString latid_loc = (server->intraCommSize > 1) 
    153                              ? StdString("lat").append(appendDomid).append("_local") 
    154                              : latid; 
    155 */ 
    156  
    157          CArray<int, 1>& indexToWrite = domain->localIndexToWriteOnServer; 
    158          int nbWritten = indexToWrite.numElements(); 
    159          CArray<double,1> writtenLat, writtenLon; 
    160          CArray<double,2> writtenBndsLat, writtenBndsLon; 
    161          CArray<double,1> writtenArea; 
    162  
    163          if (domain->hasLonLat) 
    164          { 
    165            writtenLat.resize(nbWritten); 
    166            writtenLon.resize(nbWritten); 
    167            for (int idx = 0; idx < nbWritten; ++idx) 
    168            { 
    169              if (indexToWrite(idx) < 0) 
    170              { 
    171                writtenLat(idx) = -1.;   // hole 
    172                writtenLon(idx) = -1.; 
    173              } 
    174              else 
    175              { 
    176                writtenLat(idx) = domain->latvalue(indexToWrite(idx)); 
    177                writtenLon(idx) = domain->lonvalue(indexToWrite(idx)); 
    178              } 
    179            } 
    180  
    181            if (domain->hasBounds) 
    182            {          
    183              int nvertex = domain->nvertex, idx; 
    184              writtenBndsLat.resize(nvertex, nbWritten); 
    185              writtenBndsLon.resize(nvertex, nbWritten); 
    186              CArray<double,2>& boundslat = domain->bounds_latvalue; 
    187              CArray<double,2>& boundslon = domain->bounds_lonvalue;    
    188              for (idx = 0; idx < nbWritten; ++idx) 
    189                for (int nv = 0; nv < nvertex; ++nv) 
    190                { 
    191                  if (indexToWrite(idx) < 0) 
    192                  { 
    193                    writtenBndsLat(nv, idx) = -1.;  // hole 
    194                    writtenBndsLon(nv, idx) = -1.; 
    195                  } 
    196                  else 
    197                  { 
    198                    writtenBndsLat(nv, idx) = boundslat(nv, int(indexToWrite(idx))); 
    199                    writtenBndsLon(nv, idx) = boundslon(nv, int(indexToWrite(idx))); 
    200                  } 
    201                } 
    202            } 
    203          } 
    204  
    205          if (domain->hasArea) 
    206          { 
    207            writtenArea.resize(nbWritten);            
    208            for (int idx = 0; idx < nbWritten; ++idx) 
    209            { 
    210                   if (indexToWrite(idx) < 0) 
    211               writtenArea(idx) = -1.; 
    212                   else 
    213               writtenArea(idx) = domain->areavalue(indexToWrite(idx)); 
    214            } 
    215          } 
    216144 
    217145         try 
     
    246174                   SuperClassWriter::addDimension(dimVertId, domain->nvertex); 
    247175 
    248                  if (server->intraCommSize > 1) 
     176                 if (context->intraCommSize_ > 1) 
    249177                 { 
    250178                   this->writeLocalAttributes(domain->ibegin, 
     
    261189                                                      domain->nj, 
    262190                                                      domain->ni_glo,domain->nj_glo, 
    263                                                       server->intraCommRank,server->intraCommSize); 
     191                                                      context->intraCommRank_,context->intraCommSize_); 
    264192                 } 
    265193 
     
    299227                 dim0.push_back(dimXid); 
    300228 
    301  
    302   // supress mask               if (server->intraCommSize > 1) 
    303   // supress mask               { 
    304   // supress mask                  SuperClassWriter::addVariable(maskid, NC_INT, dim0); 
    305   // supress mask 
    306   // supress mask                  this->writeMaskAttributes(maskid, 
    307   // supress mask                     domain->data_dim.getValue()/*, 
    308   // supress mask                     domain->data_ni.getValue(), 
    309   // supress mask                     domain->data_nj.getValue(), 
    310   // supress mask                     domain->data_ibegin.getValue(), 
    311   // supress mask                     domain->data_jbegin.getValue()*/); 
    312   // supress mask               } 
    313  
    314                  //SuperClassWriter::setDefaultValue(maskid, &dvm); 
    315  
    316229                 if (domain->hasArea) 
    317230                 { 
     
    328241                   { 
    329242                     case CDomain::type_attr::curvilinear :                        
    330                        SuperClassWriter::writeData(writtenLat, latid, isCollective, 0); 
    331                        SuperClassWriter::writeData(writtenLon, lonid, isCollective, 0); 
     243                       SuperClassWriter::writeData(domain->latvalue, latid, isCollective, 0); 
     244                       SuperClassWriter::writeData(domain->lonvalue, lonid, isCollective, 0); 
    332245                       break; 
    333246                     case CDomain::type_attr::rectilinear : 
    334                        CArray<double,1> lat = writtenLat(Range(fromStart,toEnd,domain->ni)) ; 
     247                       CArray<double,1> lat = domain->latvalue(Range(fromStart,toEnd,domain->ni)) ; 
    335248                       SuperClassWriter::writeData(CArray<double,1>(lat.copy()), latid, isCollective, 0); 
    336                        CArray<double,1> lon = writtenLon(Range(0,domain->ni-1)) ; 
     249                       CArray<double,1> lon = domain->lonvalue(Range(0,domain->ni-1)) ; 
    337250                       SuperClassWriter::writeData(CArray<double,1>(lon.copy()), lonid, isCollective, 0); 
    338251                       break; 
     
    341254                   if (domain->hasBounds) 
    342255                   { 
    343                      SuperClassWriter::writeData(writtenBndsLon, bounds_lonid, isCollective, 0); 
    344                      SuperClassWriter::writeData(writtenBndsLat, bounds_latid, isCollective, 0); 
     256                     SuperClassWriter::writeData(domain->bounds_lonvalue, bounds_lonid, isCollective, 0); 
     257                     SuperClassWriter::writeData(domain->bounds_latvalue, bounds_latid, isCollective, 0); 
    345258                   } 
    346259                 } 
     
    348261                 if (domain->hasArea) 
    349262                 { 
    350                    SuperClassWriter::writeData(writtenArea, areaId, isCollective, 0);                    
     263                   SuperClassWriter::writeData(domain->areavalue, areaId, isCollective, 0);                    
    351264                 } 
    352265 
     
    426339                     std::vector<StdSize> start(2) ; 
    427340                     std::vector<StdSize> count(2) ; 
    428 // Comment out: it is not working for a hole 
    429 //                     if (domain->isEmpty()) 
    430 //                     { 
    431 //                       start[0]=0 ; start[1]=0 ; 
    432 //                       count[0]=0 ; count[1]=0 ; 
    433 //                     } 
    434 //                     else 
    435                      { 
    436                        start[1]=domain->ibegin; 
    437                        start[0]=domain->jbegin; 
    438                        count[1]=domain->ni ; count[0]=domain->nj ; 
    439                      } 
     341                     start[1]=domain->ibegin; 
     342                     start[0]=domain->jbegin; 
     343                     count[1]=domain->ni ; count[0]=domain->nj ; 
    440344 
    441345                     if (domain->hasLonLat) 
    442346                     { 
    443                        SuperClassWriter::writeData(writtenLat, latid, isCollective, 0,&start,&count); 
    444                        SuperClassWriter::writeData(writtenLon, lonid, isCollective, 0,&start,&count); 
     347                       SuperClassWriter::writeData(domain->latvalue, latid, isCollective, 0,&start,&count); 
     348                       SuperClassWriter::writeData(domain->lonvalue, lonid, isCollective, 0,&start,&count); 
    445349                     } 
    446350                     break; 
     
    452356                       std::vector<StdSize> start(1) ; 
    453357                       std::vector<StdSize> count(1) ; 
    454                        if (domain->isEmpty()) 
    455                        { 
    456                          start[0]=0 ; 
    457                          count[0]=0 ; 
    458                          SuperClassWriter::writeData(writtenLat, latid, isCollective, 0,&start,&count); 
    459                          SuperClassWriter::writeData(writtenLon, lonid, isCollective, 0,&start,&count); 
    460                        } 
    461                        else 
    462                        {  
    463                          start[0]=domain->jbegin; 
    464                          count[0]=domain->nj; 
    465                          CArray<double,1> lat = writtenLat(Range(fromStart,toEnd,domain->ni)); 
    466                          SuperClassWriter::writeData(CArray<double,1>(lat.copy()), latid, isCollective, 0,&start,&count); 
    467  
    468                          start[0]=domain->ibegin; 
    469                          count[0]=domain->ni; 
    470                          CArray<double,1> lon = writtenLon(Range(0,domain->ni-1)); 
    471                          SuperClassWriter::writeData(CArray<double,1>(lon.copy()), lonid, isCollective, 0,&start,&count); 
    472                        } 
     358                        
     359                       start[0]=domain->jbegin; 
     360                       count[0]=domain->nj; 
     361                       CArray<double,1> lat = domain->latvalue(Range(fromStart,toEnd,domain->ni)); 
     362                       SuperClassWriter::writeData(CArray<double,1>(lat.copy()), latid, isCollective, 0,&start,&count); 
     363 
     364                       start[0]=domain->ibegin; 
     365                       count[0]=domain->ni; 
     366                       CArray<double,1> lon = domain->lonvalue(Range(0,domain->ni-1)); 
     367                       SuperClassWriter::writeData(CArray<double,1>(lon.copy()), lonid, isCollective, 0,&start,&count); 
    473368                     } 
    474369                     break; 
     
    495390                   } 
    496391                  
    497                    SuperClassWriter::writeData(writtenBndsLon, bounds_lonid, isCollective, 0, &start, &count); 
    498                    SuperClassWriter::writeData(writtenBndsLat, bounds_latid, isCollective, 0, &start, &count); 
     392                   SuperClassWriter::writeData(domain->bounds_lonvalue, bounds_lonid, isCollective, 0, &start, &count); // will probably not working for rectilinear 
     393                   SuperClassWriter::writeData(domain->bounds_latvalue, bounds_latid, isCollective, 0, &start, &count); 
    499394                 } 
    500395 
     
    504399                   std::vector<StdSize> count(2); 
    505400 
    506                    if (domain->isEmpty()) 
    507                    { 
    508                      start[0] = 0; start[1] = 0; 
    509                      count[0] = 0; count[1] = 0; 
    510                    } 
    511                    else 
    512                    { 
    513                      start[1] = domain->ibegin; 
    514                      start[0] = domain->jbegin; 
    515                      count[1] = domain->ni; 
    516                      count[0] = domain->nj; 
    517                    } 
     401                   start[1] = domain->ibegin; 
     402                   start[0] = domain->jbegin; 
     403                   count[1] = domain->ni; 
     404                   count[0] = domain->nj; 
    518405                    
    519                    SuperClassWriter::writeData(writtenArea, areaId, isCollective, 0, &start, &count); 
     406                   SuperClassWriter::writeData(domain->areavalue, areaId, isCollective, 0, &start, &count); 
    520407                 } 
    521408 
     
    548435    { 
    549436      CContext* context = CContext::getCurrent() ; 
    550       CContextServer* server=context->server ; 
    551437 
    552438      if (domain->IsWritten(this->filename)) return; 
     
    571457      StdString domainName = domain->name; 
    572458      domain->assignMesh(domainName, domain->nvertex); 
    573       domain->mesh->createMeshEpsilon(server->intraComm, domain->lonvalue, domain->latvalue, domain->bounds_lonvalue, domain->bounds_latvalue); 
     459      domain->mesh->createMeshEpsilon(context->intraComm_, domain->lonvalue, domain->latvalue, domain->bounds_lonvalue, domain->bounds_latvalue); 
    574460 
    575461      StdString node_x = domainName + "_node_x"; 
     
    908794      { 
    909795         CContext* context = CContext::getCurrent() ; 
    910          CContextServer* server=context->server ; 
    911796 
    912797         if (domain->IsWritten(this->filename)) return; 
     
    944829 
    945830         int nvertex = (domain->nvertex.isEmpty()) ? 0 : domain->nvertex; 
    946  
    947          CArray<int, 1>& indexToWrite = domain->localIndexToWriteOnServer; 
    948          int nbWritten = indexToWrite.numElements(); 
    949          CArray<double,1> writtenLat, writtenLon; 
    950          CArray<double,2> writtenBndsLat, writtenBndsLon; 
    951          CArray<double,1> writtenArea; 
    952  
    953          if (domain->hasLonLat) 
    954          { 
    955            writtenLat.resize(nbWritten); 
    956            writtenLon.resize(nbWritten); 
    957            for (int idx = 0; idx < nbWritten; ++idx) 
    958            { 
    959              if (indexToWrite(idx) < 0) 
    960              { 
    961                writtenLat(idx) = -1.; 
    962                writtenLon(idx) = -1.; 
    963              } 
    964              else 
    965              { 
    966                writtenLat(idx) = domain->latvalue(indexToWrite(idx)); 
    967                writtenLon(idx) = domain->lonvalue(indexToWrite(idx)); 
    968              } 
    969            } 
    970          } 
    971           
    972          if (domain->hasBounds) 
    973          { 
    974            int nvertex = domain->nvertex, idx; 
    975            writtenBndsLat.resize(nvertex, nbWritten); 
    976            writtenBndsLon.resize(nvertex, nbWritten); 
    977            CArray<double,2>& boundslat = domain->bounds_latvalue; 
    978            CArray<double,2>& boundslon = domain->bounds_lonvalue; 
    979            for (idx = 0; idx < nbWritten; ++idx) 
    980            { 
    981              for (int nv = 0; nv < nvertex; ++nv) 
    982              { 
    983                if (indexToWrite(idx) < 0) 
    984                { 
    985                  writtenBndsLat(nv, idx) = -1.; 
    986                  writtenBndsLon(nv, idx) = -1.; 
    987                } 
    988                else 
    989                { 
    990                  writtenBndsLat(nv, idx) = boundslat(nv, int(indexToWrite(idx))); 
    991                  writtenBndsLon(nv, idx) = boundslon(nv, int(indexToWrite(idx))); 
    992                 } 
    993              } 
    994            } 
    995          } 
    996  
    997          if (domain->hasArea) 
    998          { 
    999            writtenArea.resize(nbWritten);            
    1000            for (int idx = 0; idx < nbWritten; ++idx) 
    1001            { 
    1002              if (indexToWrite(idx) < 0) 
    1003                writtenArea(idx) = -1.; 
    1004              else 
    1005                writtenArea(idx) = domain->areavalue(indexToWrite(idx)); 
    1006            } 
    1007          } 
    1008831 
    1009832         try 
     
    1055878                 if (domain->hasLonLat) 
    1056879                 { 
    1057                    SuperClassWriter::writeData(writtenLat, latid, isCollective, 0); 
    1058                    SuperClassWriter::writeData(writtenLon, lonid, isCollective, 0); 
     880                   SuperClassWriter::writeData(domain->latvalue, latid, isCollective, 0); 
     881                   SuperClassWriter::writeData(domain->lonvalue, lonid, isCollective, 0); 
    1059882                   if (domain->hasBounds) 
    1060883                   { 
    1061                      SuperClassWriter::writeData(writtenBndsLon, bounds_lonid, isCollective, 0); 
    1062                      SuperClassWriter::writeData(writtenBndsLat, bounds_latid, isCollective, 0); 
     884                     SuperClassWriter::writeData(domain->bounds_lonvalue, bounds_lonid, isCollective, 0); 
     885                     SuperClassWriter::writeData(domain->bounds_latvalue, bounds_latid, isCollective, 0); 
    1063886                   } 
    1064887                 } 
    1065888 
    1066889                 if (domain->hasArea) 
    1067                    SuperClassWriter::writeData(writtenArea, areaId, isCollective, 0); 
     890                   SuperClassWriter::writeData(domain->areavalue, areaId, isCollective, 0); 
    1068891 
    1069892                 SuperClassWriter::definition_start(); 
     
    1137960                 if (domain->hasLonLat) 
    1138961                 { 
    1139                    SuperClassWriter::writeData(writtenLat, latid, isCollective, 0,&start,&count); 
    1140                    SuperClassWriter::writeData(writtenLon, lonid, isCollective, 0,&start,&count); 
     962                   SuperClassWriter::writeData(domain->latvalue, latid, isCollective, 0,&start,&count); 
     963                   SuperClassWriter::writeData(domain->lonvalue, lonid, isCollective, 0,&start,&count); 
    1141964                   if (domain->hasBounds) 
    1142965                   { 
    1143                      SuperClassWriter::writeData(writtenBndsLon, bounds_lonid, isCollective, 0,&startBounds,&countBounds); 
    1144                      SuperClassWriter::writeData(writtenBndsLat, bounds_latid, isCollective, 0,&startBounds,&countBounds); 
     966                     SuperClassWriter::writeData(domain->bounds_lonvalue, bounds_lonid, isCollective, 0,&startBounds,&countBounds); 
     967                     SuperClassWriter::writeData(domain->bounds_latvalue, bounds_latid, isCollective, 0,&startBounds,&countBounds); 
    1145968                   } 
    1146969                 } 
    1147970 
    1148971                 if (domain->hasArea) 
    1149                    SuperClassWriter::writeData(writtenArea, areaId, isCollective, 0, &start, &count); 
     972                   SuperClassWriter::writeData(domain->areavalue, areaId, isCollective, 0, &start, &count); 
    1150973 
    1151974                 SuperClassWriter::definition_start(); 
     
    11771000        axis->checkAttributes(); 
    11781001 
    1179         axis->computeWrittenIndex(); 
    1180         axis->computeWrittenCompressedIndex(comm_file); 
    1181         
    11821002        int size  = (MULTI_FILE == SuperClass::type) ? axis->n.getValue() 
    11831003                                                          : axis->n_glo.getValue(); 
     
    12791099 
    12801100          SuperClassWriter::definition_end(); 
    1281  
    1282           CArray<int, 1>& indexToWrite = axis->localIndexToWriteOnServer; 
    1283           int nbWritten = indexToWrite.numElements(); 
    1284           CArray<double,1> axis_value(indexToWrite.numElements()); 
    1285           if (!axis->value.isEmpty()) 
    1286           { 
    1287             for (int i = 0; i < nbWritten; i++) 
    1288             { 
    1289               if (indexToWrite(i) < 0) 
    1290                 axis_value(i) = -1;   // Some value in case of a hole 
    1291               else 
    1292                 axis_value(i) = axis->value(indexToWrite(i)); 
    1293             } 
    1294           } 
    1295           CArray<double,2> axis_bounds; 
    1296           CArray<string,1> axis_label; 
    1297           if (!axis->label.isEmpty()) 
    1298           { 
    1299             axis_label.resize(indexToWrite.numElements()); 
    1300             for (int i = 0; i < nbWritten; i++) 
    1301             { 
    1302               if (indexToWrite(i) < 0) 
    1303                 axis_label(i) = boost::lexical_cast<string>(-1);  // Some value in case of a hole 
    1304               else 
    1305                 axis_label(i) = axis->label(indexToWrite(i)); 
    1306             } 
    1307           } 
    1308  
     1101           
    13091102          switch (SuperClass::type) 
    13101103          { 
     
    13141107              { 
    13151108                if (!axis->value.isEmpty()) 
    1316                   SuperClassWriter::writeData(axis_value, axisid, isCollective, 0); 
     1109                  SuperClassWriter::writeData(axis->value, axisid, isCollective, 0); 
    13171110 
    13181111                if (!axis->bounds.isEmpty()) 
    1319                 { 
    1320                   axis_bounds.resize(2, indexToWrite.numElements()); 
    1321                   for (int i = 0; i < nbWritten; ++i) 
    1322                   { 
    1323                     if (indexToWrite(i) < 0) 
    1324                     { 
    1325                       axis_bounds(0, i) = -1.; // Some value in case of a hole 
    1326                       axis_bounds(1, i) = -1.; 
    1327                     } 
    1328                     else 
    1329                     { 
    1330                       axis_bounds(0, i) = axis->bounds(0, int(indexToWrite(i))); 
    1331                       axis_bounds(1, i) = axis->bounds(1, int(indexToWrite(i))); 
    1332                     } 
    1333                   } 
    1334                   SuperClassWriter::writeData(axis_bounds, axisBoundsId, isCollective, 0); 
    1335                 } 
     1112                  SuperClassWriter::writeData(axis->bounds, axisBoundsId, isCollective, 0); 
    13361113              } 
    13371114              else 
    1338                 SuperClassWriter::writeData(axis_label, axisid, isCollective, 0); 
     1115                SuperClassWriter::writeData(axis->label, axisid, isCollective, 0); 
    13391116 
    13401117              SuperClassWriter::definition_start(); 
     
    13531130              { 
    13541131                if (!axis->value.isEmpty()) 
    1355                   SuperClassWriter::writeData(axis_value, axisid, isCollective, 0, &start, &count); 
     1132                  SuperClassWriter::writeData(axis->value, axisid, isCollective, 0, &start, &count); 
    13561133 
    13571134                if (!axis->bounds.isEmpty()) 
    1358                 { 
    1359                   axis_bounds.resize(2, indexToWrite.numElements()); 
    1360                   for (int i = 0; i < nbWritten; ++i) 
    1361                   { 
    1362                     if (indexToWrite(i) < 0) 
    1363                     { 
    1364                       axis_bounds(0, i) = -1.; 
    1365                       axis_bounds(1, i) = -1.; 
    1366                     } 
    1367                     else 
    1368                     { 
    1369                       axis_bounds(0, i) = axis->bounds(0, int(indexToWrite(i))); 
    1370                       axis_bounds(1, i) = axis->bounds(1, int(indexToWrite(i))); 
    1371                     } 
    1372                   } 
    1373                   SuperClassWriter::writeData(axis_bounds, axisBoundsId, isCollective, 0, &startBounds, &countBounds); 
    1374                 } 
     1135                  SuperClassWriter::writeData(axis->bounds, axisBoundsId, isCollective, 0, &startBounds, &countBounds); 
    13751136              } 
    13761137              else 
     
    13791140                startLabel[0] = start[0]; startLabel[1] = 0; 
    13801141                countLabel[0] = count[0]; countLabel[1] = stringArrayLen; 
    1381                 SuperClassWriter::writeData(axis_label, axisid, isCollective, 0, &startLabel, &countLabel); 
     1142                SuperClassWriter::writeData(axis->label, axisid, isCollective, 0, &startLabel, &countLabel); 
    13821143              } 
    13831144 
     
    15741335     void CNc4DataOutput::writeGridCompressed_(CGrid* grid) 
    15751336     { 
    1576        if (grid->isScalarGrid() || grid->isWrittenCompressed(this->filename)) return; 
    1577  
    1578        try 
    1579        { 
    1580          CArray<int,1> axisDomainOrder = grid->axis_domain_order; 
    1581          std::vector<StdString> domainList = grid->getDomainList(); 
    1582          std::vector<StdString> axisList   = grid->getAxisList(); 
    1583          std::vector<StdString> scalarList = grid->getScalarList(); 
    1584          int numElement = axisDomainOrder.numElements(), idxDomain = 0, idxAxis = 0, idxScalar = 0; 
    1585  
    1586          std::vector<StdString> dims; 
    1587  
    1588          if (grid->isCompressible()) 
    1589          { 
    1590            StdString varId = grid->getId() + "_points"; 
    1591  
    1592            int nbIndexes = (SuperClass::type == MULTI_FILE) ? grid->getNumberWrittenIndexes() : grid->getTotalNumberWrittenIndexes(); 
    1593            SuperClassWriter::addDimension(varId, nbIndexes); 
    1594  
    1595            dims.push_back(varId); 
    1596            SuperClassWriter::addVariable(varId, NC_INT, dims); 
    1597  
    1598            StdOStringStream compress; 
    1599            for (int i = numElement - 1; i >= 0; --i) 
    1600            { 
    1601              if (2 == axisDomainOrder(i)) 
    1602              { 
    1603                CDomain* domain = CDomain::get(domainList[domainList.size() - idxDomain - 1]); 
    1604                StdString domId = domain->getDomainOutputName(); 
    1605                StdString appendDomId  = singleDomain ? "" : "_" + domId; 
    1606  
    1607                switch (domain->type) 
    1608                { 
    1609                  case CDomain::type_attr::curvilinear: 
    1610                    compress << "y" << appendDomId << " x" << appendDomId; 
    1611                    break; 
    1612                  case CDomain::type_attr::rectilinear: 
    1613                    compress << "lat" << appendDomId << " lon" << appendDomId; 
    1614                    break; 
    1615                  case CDomain::type_attr::unstructured: 
    1616                    StdString cellName = (!domain->dim_i_name.isEmpty()) ? cellName=domain->dim_i_name : "cell"; 
    1617                    compress << cellName << appendDomId; 
    1618 //                   compress << "cell" << appendDomId; 
    1619                    break; 
    1620                } 
    1621                ++idxDomain; 
    1622              } 
    1623              else if (1 == axisDomainOrder(i)) 
    1624              { 
    1625                CAxis* axis = CAxis::get(axisList[axisList.size() - idxAxis - 1]); 
    1626                compress << axis->getAxisOutputName(); 
    1627                ++idxAxis; 
    1628              } 
    1629              else 
    1630              { 
    1631                CScalar* scalar = CScalar::get(scalarList[scalarList.size() - idxScalar - 1]); 
    1632                compress << scalar->getScalarOutputName(); 
    1633                ++idxScalar; 
    1634              } 
    1635  
    1636              if (i != 0) compress << ' '; 
    1637            } 
    1638            SuperClassWriter::addAttribute("compress", compress.str(), &varId);          
    1639  
    1640            CArray<int, 1> indexes(grid->getNumberWrittenIndexes()); 
    1641            indexes = grid->localIndexToWriteOnServer; 
    1642  
    1643            switch (SuperClass::type) 
    1644            { 
    1645              case (MULTI_FILE): 
    1646              { 
    1647                SuperClassWriter::writeData(indexes, varId, isCollective, 0); 
    1648                break; 
    1649              } 
    1650              case (ONE_FILE): 
    1651              { 
    1652                if (grid->doGridHaveDataDistributed()) 
    1653                  grid->getDistributionServer()->computeGlobalIndex(indexes); 
    1654  
    1655                std::vector<StdSize> start, count; 
    1656                start.push_back(grid->getOffsetWrittenIndexes()); 
    1657                count.push_back(grid->getNumberWrittenIndexes()); 
    1658  
    1659                SuperClassWriter::writeData(indexes, varId, isCollective, 0, &start, &count); 
    1660                break; 
    1661              } 
    1662            } 
    1663          } 
    1664          else 
    1665          { 
    1666            for (int i = 0; i < numElement; ++i) 
    1667            { 
    1668              StdString varId, compress; 
    1669              CArray<int, 1> indexes; 
    1670              bool isDistributed; 
    1671              StdSize nbIndexes, totalNbIndexes, offset; 
    1672              int firstGlobalIndex; 
    1673  
    1674              if (2 == axisDomainOrder(i)) 
    1675              { 
    1676                CDomain* domain = CDomain::get(domainList[idxDomain]); 
    1677                StdString domId = domain->getDomainOutputName(); 
    1678  
    1679                if (!domain->isCompressible() 
    1680                     || domain->type == CDomain::type_attr::unstructured 
    1681                     || domain->isWrittenCompressed(this->filename) 
    1682                     || isWrittenCompressedDomain(domId)) 
    1683                  continue; 
    1684  
    1685                StdString appendDomId  = singleDomain ? "" : "_" + domId; 
    1686  
    1687                varId = domId + "_points"; 
    1688                switch (domain->type) 
    1689                { 
    1690                  case CDomain::type_attr::curvilinear: 
    1691                    compress = "y" + appendDomId + " x" + appendDomId; 
    1692                    break; 
    1693                  case CDomain::type_attr::rectilinear: 
    1694                    compress = "lat" + appendDomId + " lon" + appendDomId; 
    1695                    break; 
    1696                } 
    1697  
    1698                // indexes.resize(domain->compressedIndexToWriteOnServer[comm_file].numElements()); 
    1699                // indexes = domain->compressedIndexToWriteOnServer[com_file]; 
    1700                indexes.resize(domain->getCompressedIndexToWriteOnServer(comm_file).numElements()); 
    1701                indexes = domain->getCompressedIndexToWriteOnServer(comm_file); 
    1702  
    1703                isDistributed = domain->isDistributed(); 
    1704                nbIndexes = domain->getNumberWrittenIndexes(comm_file); 
    1705                totalNbIndexes = domain->getTotalNumberWrittenIndexes(comm_file); 
    1706                offset = domain->getOffsetWrittenIndexes(comm_file); 
    1707                firstGlobalIndex = domain->ibegin + domain->jbegin * domain->ni_glo; 
    1708  
    1709                domain->addRelFileCompressed(this->filename); 
    1710                setWrittenCompressedDomain(domId); 
    1711                ++idxDomain; 
    1712              } 
    1713              else if (1 == axisDomainOrder(i)) 
    1714              { 
    1715                CAxis* axis = CAxis::get(axisList[idxAxis]); 
    1716                StdString axisId = axis->getAxisOutputName(); 
    1717  
    1718                if (!axis->isCompressible() 
    1719                     || axis->isWrittenCompressed(this->filename) 
    1720                     || isWrittenCompressedAxis(axisId)) 
    1721                  continue; 
    1722  
    1723                varId = axisId + "_points"; 
    1724                compress = axisId; 
    1725  
    1726                // indexes.resize(axis->compressedIndexToWriteOnServer.numElements()); 
    1727                // indexes = axis->compressedIndexToWriteOnServer; 
    1728  
    1729                indexes.resize(axis->getCompressedIndexToWriteOnServer(comm_file).numElements()); 
    1730                indexes = axis->getCompressedIndexToWriteOnServer(comm_file); 
    1731  
    1732                isDistributed = axis->isDistributed(); 
    1733                nbIndexes = axis->getNumberWrittenIndexes(comm_file); 
    1734                totalNbIndexes = axis->getTotalNumberWrittenIndexes(comm_file); 
    1735                offset = axis->getOffsetWrittenIndexes(comm_file); 
    1736                firstGlobalIndex = axis->begin; 
    1737  
    1738                axis->addRelFileCompressed(this->filename); 
    1739                setWrittenCompressedAxis(axisId); 
    1740                ++idxAxis; 
    1741              } 
    1742              else 
    1743              { 
    1744              } 
    1745  
    1746              if (!varId.empty()) 
    1747              { 
    1748                SuperClassWriter::addDimension(varId, (SuperClass::type == MULTI_FILE) ? nbIndexes : totalNbIndexes); 
    1749  
    1750                dims.clear(); 
    1751                dims.push_back(varId); 
    1752                SuperClassWriter::addVariable(varId, NC_INT, dims); 
    1753  
    1754                SuperClassWriter::addAttribute("compress", compress, &varId); 
    1755  
    1756                switch (SuperClass::type) 
    1757                { 
    1758                  case (MULTI_FILE): 
    1759                  { 
    1760                    indexes -= firstGlobalIndex; 
    1761                    SuperClassWriter::writeData(indexes, varId, isCollective, 0); 
    1762                    break; 
    1763                  } 
    1764                  case (ONE_FILE): 
    1765                  { 
    1766                    std::vector<StdSize> start, count; 
    1767                    start.push_back(offset); 
    1768                    count.push_back(nbIndexes); 
    1769  
    1770                    SuperClassWriter::writeData(indexes, varId, isCollective, 0, &start, &count); 
    1771                    break; 
    1772                  } 
    1773                } 
    1774              } 
     1337        if (grid->isScalarGrid() || grid->isWrittenCompressed(this->filename)) return; 
     1338         
     1339        // NOTA : The cuurent algorithm to write compress elements of the grid 
     1340        //        will work pretting well when on server side you dont't get 
     1341        //        partial overlap on elements between differents participating process 
     1342        //        So the element must be totally distributed or non distributed 
     1343        //        If an element is partially overlaping betwwen process then the 
     1344        //        total compressed part will apear artificially greater than expected 
     1345        //        For the current implementation of writer which is decomposed only on 
     1346        //        one element, it will work as expected, but for future, it must be  
     1347        //        reconsidered again.  
     1348        try 
     1349        { 
     1350          CArray<int,1> axisDomainOrder = grid->axis_domain_order; 
     1351          std::vector<StdString> domainList = grid->getDomainList(); 
     1352          std::vector<StdString> axisList   = grid->getAxisList(); 
     1353          std::vector<StdString> scalarList = grid->getScalarList(); 
     1354          int numElement = axisDomainOrder.numElements(), idxDomain = 0, idxAxis = 0, idxScalar = 0; 
     1355          int commRank ; 
     1356          MPI_Comm_rank(comm_file,&commRank) ; 
     1357 
     1358          std::vector<StdString> dims; 
     1359 
     1360          for (int i = 0; i < numElement; ++i) 
     1361          { 
     1362            StdString varId, compress; 
     1363            CArray<size_t, 1> indexes; 
     1364            bool isDistributed; 
     1365            size_t nbIndexes, totalNbIndexes, offset; 
     1366            size_t firstGlobalIndex; 
     1367             
     1368            if (2 == axisDomainOrder(i)) 
     1369            { 
     1370              CDomain* domain = CDomain::get(domainList[idxDomain]); 
     1371              StdString domId = domain->getDomainOutputName(); 
     1372 
     1373              if (!domain->isCompressible() 
     1374                  || domain->type == CDomain::type_attr::unstructured 
     1375                  || domain->isWrittenCompressed(this->filename) 
     1376                  || isWrittenCompressedDomain(domId)) 
     1377                continue; 
     1378             
     1379              // unstructured grid seems not be taken into account why ? 
     1380 
     1381              string lonName,latName ; 
     1382 
     1383              if (domain->lon_name.isEmpty()) 
     1384              {  
     1385                if (domain->type==CDomain::type_attr::curvilinear) lonName = "nav_lon"; 
     1386                else lonName = "lon"; 
     1387              } 
     1388              else lonName = domain->lon_name; 
     1389 
     1390              if (domain->lat_name.isEmpty()) 
     1391              { 
     1392                if (domain->type==CDomain::type_attr::curvilinear) latName = "nav_lat"; 
     1393                else latName = "lat"; 
     1394              } 
     1395              else latName = domain->lat_name; 
     1396              
     1397              StdString appendDomId  = singleDomain ? "" : "_" + domId; 
     1398 
     1399              varId = domId + "_points"; 
     1400              compress = latName + appendDomId + " " + lonName + appendDomId; 
     1401      
     1402              CLocalView* workflowView = domain->getLocalView(CElementView::WORKFLOW) ; 
     1403              workflowView->getGlobalIndexView(indexes) ; 
     1404              nbIndexes = workflowView->getSize() ; 
     1405              isDistributed = domain->isDistributed(); 
     1406              if (isDistributed) 
     1407              { 
     1408                MPI_Exscan(&nbIndexes, &offset, 1, MPI_SIZE_T, MPI_SUM, comm_file) ; 
     1409                if (commRank==0) offset=0 ; 
     1410                MPI_Allreduce(&nbIndexes,&totalNbIndexes,1 , MPI_SIZE_T, MPI_SUM, comm_file) ; 
     1411              } 
     1412              else 
     1413              { 
     1414                offset=0 ; 
     1415                totalNbIndexes = nbIndexes ; 
     1416              } 
     1417 
     1418              firstGlobalIndex = domain->ibegin + domain->jbegin * domain->ni_glo; 
     1419 
     1420              domain->addRelFileCompressed(this->filename); 
     1421              setWrittenCompressedDomain(domId); 
     1422              ++idxDomain; 
    17751423            } 
    1776          } 
    1777  
    1778          grid->addRelFileCompressed(this->filename); 
    1779        } 
    1780        catch (CNetCdfException& e) 
    1781        { 
    1782          StdString msg("On writing compressed grid : "); 
    1783          msg.append(grid->getId()); msg.append("\n"); 
    1784          msg.append("In the context : "); 
    1785          CContext* context = CContext::getCurrent(); 
    1786          msg.append(context->getId()); msg.append("\n"); 
    1787          msg.append(e.what()); 
    1788          ERROR("CNc4DataOutput::writeGridCompressed_(CGrid* grid)", << msg); 
    1789        } 
    1790      } 
     1424            else if (1 == axisDomainOrder(i)) 
     1425            { 
     1426              CAxis* axis = CAxis::get(axisList[idxAxis]); 
     1427              StdString axisId = axis->getAxisOutputName(); 
     1428 
     1429              if (!axis->isCompressible() 
     1430                  || axis->isWrittenCompressed(this->filename) 
     1431                  || isWrittenCompressedAxis(axisId)) 
     1432                continue; 
     1433 
     1434              varId = axisId + "_points"; 
     1435              compress = axisId; 
     1436 
     1437              CLocalView* workflowView = axis->getLocalView(CElementView::WORKFLOW) ; 
     1438              workflowView->getGlobalIndexView(indexes) ; 
     1439              nbIndexes = workflowView->getSize() ; 
     1440              isDistributed = axis->isDistributed(); 
     1441              if (isDistributed) 
     1442              { 
     1443                MPI_Exscan(&nbIndexes, &offset, 1, MPI_SIZE_T, MPI_SUM, comm_file) ; 
     1444                if (commRank==0) offset=0 ; 
     1445                MPI_Allreduce(&nbIndexes,&totalNbIndexes,1 , MPI_SIZE_T, MPI_SUM, comm_file) ; 
     1446              } 
     1447              else 
     1448              { 
     1449                offset=0 ; 
     1450                totalNbIndexes = nbIndexes ; 
     1451              } 
     1452              firstGlobalIndex = axis->begin; 
     1453               
     1454              axis->addRelFileCompressed(this->filename); 
     1455              setWrittenCompressedAxis(axisId); 
     1456              ++idxAxis; 
     1457            } 
     1458            else 
     1459            { 
     1460              //for scalar  
     1461            } 
     1462 
     1463            if (!varId.empty()) 
     1464            { 
     1465              SuperClassWriter::addDimension(varId, (SuperClass::type == MULTI_FILE) ? nbIndexes : totalNbIndexes); 
     1466 
     1467              dims.clear(); 
     1468              dims.push_back(varId); 
     1469              SuperClassWriter::addVariable(varId, NC_UINT64, dims); 
     1470 
     1471              SuperClassWriter::addAttribute("compress", compress, &varId); 
     1472 
     1473              switch (SuperClass::type) 
     1474              { 
     1475                case (MULTI_FILE): 
     1476                { 
     1477                  indexes -= firstGlobalIndex; 
     1478                  SuperClassWriter::writeData(indexes, varId, isCollective, 0); 
     1479                  break; 
     1480                } 
     1481                case (ONE_FILE): 
     1482                { 
     1483                  std::vector<StdSize> start, count; 
     1484                  start.push_back(offset); 
     1485                  count.push_back(nbIndexes); 
     1486 
     1487                  SuperClassWriter::writeData(indexes, varId, isCollective, 0, &start, &count); 
     1488                  break; 
     1489                } 
     1490              } 
     1491            } 
     1492          } 
     1493 
     1494          grid->addRelFileCompressed(this->filename); 
     1495        } 
     1496        catch (CNetCdfException& e) 
     1497        { 
     1498          StdString msg("On writing compressed grid : "); 
     1499          msg.append(grid->getId()); msg.append("\n"); 
     1500          msg.append("In the context : "); 
     1501          CContext* context = CContext::getCurrent(); 
     1502          msg.append(context->getId()); msg.append("\n"); 
     1503          msg.append(e.what()); 
     1504          ERROR("CNc4DataOutput::writeGridCompressed_(CGrid* grid)", << msg); 
     1505        } 
     1506      } 
    17911507 
    17921508     //-------------------------------------------------------------- 
     
    18141530      { 
    18151531        CContext* context = CContext::getCurrent() ; 
    1816         CContextServer* server=context->server ; 
    18171532 
    18181533        std::vector<StdString> dims, coodinates; 
    1819         CGrid* grid = field->grid; 
     1534        CGrid* grid = field->getGrid(); 
    18201535        if (!grid->doGridHaveDataToWrite()) 
    18211536          if (SuperClass::type==MULTI_FILE) return ; 
     
    19981713        } 
    19991714 
    2000         if (compressedOutput && grid->isCompressible()) 
     1715        while (!dimIdList.empty()) 
    20011716        { 
    2002           dims.push_back(grid->getId() + "_points"); 
    2003           field->setUseCompressedOutput(); 
    2004         } 
    2005         else 
    2006         { 
    2007           while (!dimIdList.empty()) 
    2008           { 
    2009             dims.push_back(dimIdList.back()); 
    2010             dimIdList.pop_back(); 
    2011           } 
     1717          dims.push_back(dimIdList.back()); 
     1718          dimIdList.pop_back(); 
    20121719        } 
    20131720 
     
    21561863 
    21571864            if (field->compression_level.isEmpty()) 
    2158               field->compression_level = field->file->compression_level.isEmpty() ? 0 : field->file->compression_level; 
     1865              field->compression_level = field->getRelFile()->compression_level.isEmpty() ? 0 : field->getRelFile()->compression_level; 
    21591866            SuperClassWriter::setCompressionLevel(fieldid, field->compression_level); 
    21601867 
     
    23552062      //--------------------------------------------------------------- 
    23562063 
    2357       void CNc4DataOutput::writeFieldData_ (CField*  field) 
     2064      int CNc4DataOutput::writeFieldData_ (CField*  field, const CArray<double,1>& data, const CDate& lastWrite, 
     2065                                           const CDate& currentWrite, int nstep) 
    23582066      { 
    23592067        CContext* context = CContext::getCurrent(); 
    2360         CContextServer* server = context->server; 
    2361         CGrid* grid = field->grid; 
    2362  
    2363         if (field->getNStep()<1)  
     2068        CGrid* grid = field->getGrid(); 
     2069        
     2070        if (nstep<1)  
    23642071        { 
    2365           return; 
     2072          return nstep; 
    23662073        } 
    23672074         
     
    23692076          if (SuperClass::type == MULTI_FILE || !isCollective) 
    23702077          { 
    2371             return; 
     2078            return nstep; 
    23722079          } 
    23732080 
     
    23872094        if (!field->wasWritten()) 
    23882095        { 
    2389           if (appendMode && field->file->record_offset.isEmpty() &&  
     2096          if (appendMode && field->getRelFile()->record_offset.isEmpty() &&  
    23902097              field->getOperationTimeType() != func::CFunctor::once) 
    23912098          { 
    23922099            double factorUnit; 
    2393             if (!field->file->time_units.isEmpty() && field->file->time_units==CFile::time_units_attr::days) 
     2100            if (!field->getRelFile()->time_units.isEmpty() && field->getRelFile()->time_units==CFile::time_units_attr::days) 
    23942101            factorUnit=context->getCalendar()->getDayLengthInSeconds() ; 
    23952102            else factorUnit=1 ; 
    2396             field->resetNStep(getRecordFromTime(field->last_Write_srv,factorUnit) + 1); 
     2103            nstep = getRecordFromTime(currentWrite,factorUnit) + 1; 
    23972104          } 
    23982105 
     
    24132120        if (wtime) 
    24142121        { 
    2415           Time lastWrite = field->last_Write_srv; 
    2416           Time lastLastWrite = field->lastlast_Write_srv; 
    2417  
    24182122           
    24192123          if (field->hasTimeInstant) 
    24202124          { 
    2421             time_data(0) = time_data_bound(1) = lastWrite; 
    2422             time_data_bound(0) = time_data_bound(1) = lastWrite; 
     2125            time_data(0) = time_data_bound(1) = (Time) lastWrite; 
     2126            time_data_bound(0) = time_data_bound(1) = (Time) currentWrite; 
    24232127            if (timeCounterType==instant) 
    24242128            { 
     
    24322136          else if (field->hasTimeCentered) 
    24332137          { 
    2434             time_data(0) = (lastWrite + lastLastWrite) / 2; 
    2435             time_data_bound(0) = lastLastWrite; 
    2436             time_data_bound(1) = lastWrite; 
     2138            time_data(0) = ((Time)currentWrite + (Time)lastWrite) / 2; 
     2139            time_data_bound(0) = (Time)lastWrite; 
     2140            time_data_bound(1) = (Time)currentWrite; 
    24372141            if (timeCounterType==centered) 
    24382142            { 
     
    24472151          if (timeCounterType==record) 
    24482152          { 
    2449             time_counter(0) = field->getNStep() - 1; 
    2450             time_counter_bound(0) = time_counter_bound(1) = field->getNStep() - 1; 
     2153            time_counter(0) = nstep - 1; 
     2154            time_counter_bound(0) = time_counter_bound(1) = nstep - 1; 
    24512155            wtimeCounter=true ; 
    24522156          } 
    24532157 
    2454           if (!field->file->time_units.isEmpty() && field->file->time_units==CFile::time_units_attr::days) 
     2158          if (!field->getRelFile()->time_units.isEmpty() && field->getRelFile()->time_units==CFile::time_units_attr::days) 
    24552159          { 
    24562160            double secByDay=context->getCalendar()->getDayLengthInSeconds() ; 
     
    24622166        } 
    24632167 
    2464          bool isRoot = (server->intraCommRank == 0); 
    2465  
    2466          if (!field->scale_factor.isEmpty() || !field->add_offset.isEmpty()) 
    2467          { 
    2468            double scaleFactor = 1.0; 
    2469            double addOffset = 0.0; 
    2470            if (!field->scale_factor.isEmpty()) scaleFactor = field->scale_factor; 
    2471            if (!field->add_offset.isEmpty()) addOffset = field->add_offset; 
    2472            field->scaleFactorAddOffset(scaleFactor, addOffset); 
    2473          } 
     2168         bool isRoot = (context->intraCommRank_ == 0); 
    24742169 
    24752170         try 
    24762171         { 
    2477            size_t writtenSize; 
    2478            if (field->getUseCompressedOutput()) 
    2479              writtenSize = grid->getNumberWrittenIndexes(); 
    2480            else 
    2481              writtenSize = grid->getWrittenDataSize(); 
    2482  
    2483            CArray<double,1> fieldData(writtenSize); 
    2484            if (!field->default_value.isEmpty()) fieldData = field->default_value; 
    2485  
    2486            if (field->getUseCompressedOutput()) 
    2487              field->outputCompressedField(fieldData); 
    2488            else 
    2489              field->outputField(fieldData); 
    2490  
    2491            if (!field->prec.isEmpty() && field->prec == 2) fieldData = round(fieldData); 
    2492  
    24932172           switch (SuperClass::type) 
    24942173           { 
     
    24962175              { 
    24972176                 CTimer::get("Files : writing data").resume(); 
    2498                  SuperClassWriter::writeData(fieldData, fieldid, isCollective, field->getNStep() - 1); 
     2177                 SuperClassWriter::writeData(data, fieldid, isCollective, nstep - 1); 
    24992178                 CTimer::get("Files : writing data").suspend(); 
    25002179                 if (wtime) 
     
    25032182                   if ( wtimeData) 
    25042183                   { 
    2505                        SuperClassWriter::writeTimeAxisData(time_data, timeAxisId, isCollective, field->getNStep() - 1, isRoot); 
    2506                        SuperClassWriter::writeTimeAxisDataBounds(time_data_bound, timeAxisBoundId, isCollective, field->getNStep() - 1, isRoot); 
     2184                       SuperClassWriter::writeTimeAxisData(time_data, timeAxisId, isCollective, nstep - 1, isRoot); 
     2185                       SuperClassWriter::writeTimeAxisDataBounds(time_data_bound, timeAxisBoundId, isCollective, nstep - 1, isRoot); 
    25072186                  } 
    25082187                   if (wtimeCounter) 
    25092188                   { 
    2510                      SuperClassWriter::writeTimeAxisData(time_counter, getTimeCounterName(), isCollective, field->getNStep() - 1,isRoot); 
    2511                      if (timeCounterType!=record) SuperClassWriter::writeTimeAxisDataBounds(time_counter_bound, timeBoundId, isCollective, field->getNStep() - 1, isRoot); 
     2189                     SuperClassWriter::writeTimeAxisData(time_counter, getTimeCounterName(), isCollective, nstep - 1,isRoot); 
     2190                     if (timeCounterType!=record) SuperClassWriter::writeTimeAxisDataBounds(time_counter_bound, timeBoundId, isCollective, nstep - 1, isRoot); 
    25122191                   } 
    25132192                   CTimer::get("Files : writing time axis").suspend(); 
     
    25222201                if (field->getUseCompressedOutput()) 
    25232202                { 
    2524                   if (grid->isCompressible()) 
     2203                  CArray<int,1> axisDomainOrder = grid->axis_domain_order; 
     2204                  std::vector<StdString> domainList = grid->getDomainList(); 
     2205                  std::vector<StdString> axisList   = grid->getAxisList(); 
     2206                  int numElement = axisDomainOrder.numElements(); 
     2207                  int idxDomain = domainList.size() - 1, idxAxis = axisList.size() - 1; 
     2208                  int idx = domainList.size() * 2 + axisList.size() - 1; 
     2209                  int commRank ; 
     2210 
     2211                  MPI_Comm_rank(comm_file,&commRank) ; 
     2212 
     2213                  start.reserve(idx+1); 
     2214                  count.reserve(idx+1); 
     2215 
     2216                  for (int i = numElement - 1; i >= 0; --i) 
    25252217                  { 
    2526                     start.push_back(grid->getOffsetWrittenIndexes()); 
    2527                     count.push_back(grid->getNumberWrittenIndexes()); 
    2528                   } 
    2529                   else 
    2530                   { 
    2531                     CArray<int,1> axisDomainOrder = grid->axis_domain_order; 
    2532                     std::vector<StdString> domainList = grid->getDomainList(); 
    2533                     std::vector<StdString> axisList   = grid->getAxisList(); 
    2534                     int numElement = axisDomainOrder.numElements(); 
    2535                     int idxDomain = domainList.size() - 1, idxAxis = axisList.size() - 1; 
    2536                     int idx = domainList.size() * 2 + axisList.size() - 1; 
    2537  
    2538                     start.reserve(idx+1); 
    2539                     count.reserve(idx+1); 
    2540  
    2541                     for (int i = numElement - 1; i >= 0; --i) 
     2218                    if (2 == axisDomainOrder(i)) 
    25422219                    { 
    2543                       if (2 == axisDomainOrder(i)) 
     2220                      CDomain* domain = CDomain::get(domainList[idxDomain]); 
     2221 
     2222                      if (domain->isCompressible()) 
    25442223                      { 
    2545                         CDomain* domain = CDomain::get(domainList[idxDomain]); 
    2546  
    2547                         if (domain->isCompressible()) 
     2224                        size_t offset ; 
     2225                        size_t nbIndexes = domain->getLocalView(CElementView::WORKFLOW)->getSize() ; 
     2226                        if (domain->isDistributed()) 
    25482227                        { 
    2549                           start.push_back(domain->getOffsetWrittenIndexes(comm_file)); 
    2550                           count.push_back(domain->getNumberWrittenIndexes(comm_file)); 
    2551                           idx -= 2; 
     2228                          MPI_Exscan(&nbIndexes, &offset, 1, MPI_SIZE_T, MPI_SUM, comm_file) ; 
     2229                          if (commRank==0) offset=0 ; 
    25522230                        } 
    2553                         else 
     2231                        else offset=0 ; 
     2232 
     2233                        start.push_back(offset); 
     2234                        count.push_back(nbIndexes); 
     2235                        idx -= 2; 
     2236                      } 
     2237                      else 
     2238                      { 
     2239                        if ((domain->type) != CDomain::type_attr::unstructured) 
    25542240                        { 
    2555                           if ((domain->type) != CDomain::type_attr::unstructured) 
    2556                           { 
    2557                             start.push_back(domain->jbegin); 
    2558                             count.push_back(domain->nj); 
    2559                           } 
    2560                           --idx; 
    2561                           start.push_back(domain->ibegin); 
    2562                           count.push_back(domain->ni); 
    2563                           --idx; 
     2241                          start.push_back(domain->jbegin); 
     2242                          count.push_back(domain->nj); 
    25642243                        } 
    2565                         --idxDomain; 
    2566                       } 
    2567                       else if (1 == axisDomainOrder(i)) 
    2568                       { 
    2569                         CAxis* axis = CAxis::get(axisList[idxAxis]); 
    2570  
    2571                         if (axis->isCompressible()) 
    2572                         { 
    2573                           start.push_back(axis->getOffsetWrittenIndexes(comm_file)); 
    2574                           count.push_back(axis->getNumberWrittenIndexes(comm_file)); 
    2575                         } 
    2576                         else 
    2577                         { 
    2578                           start.push_back(axis->begin); 
    2579                           count.push_back(axis->n); 
    2580                         } 
    2581                         --idxAxis; 
     2244                        --idx; 
     2245                        start.push_back(domain->ibegin); 
     2246                        count.push_back(domain->ni); 
    25822247                        --idx; 
    25832248                      } 
     2249                      --idxDomain; 
     2250                    } 
     2251                    else if (1 == axisDomainOrder(i)) 
     2252                    { 
     2253                      CAxis* axis = CAxis::get(axisList[idxAxis]); 
     2254 
     2255                      if (axis->isCompressible()) 
     2256                      { 
     2257                        size_t offset ; 
     2258                        size_t nbIndexes = axis->getLocalView(CElementView::WORKFLOW)->getSize() ; 
     2259                        if (axis->isDistributed()) 
     2260                        { 
     2261                          MPI_Exscan(&nbIndexes, &offset, 1, MPI_SIZE_T, MPI_SUM, comm_file) ; 
     2262                          if (commRank==0) offset=0 ; 
     2263                        } 
     2264                        else offset=0 ; 
     2265 
     2266                        start.push_back(offset); 
     2267                        count.push_back(nbIndexes); 
     2268                      } 
     2269                      else 
     2270                      { 
     2271                        start.push_back(axis->begin); 
     2272                        count.push_back(axis->n); 
     2273                      } 
     2274                      --idxAxis; 
     2275                      --idx; 
    25842276                    } 
    25852277                  } 
     
    26362328 
    26372329                CTimer::get("Files : writing data").resume(); 
    2638                 SuperClassWriter::writeData(fieldData, fieldid, isCollective, field->getNStep() - 1, &start, &count); 
     2330                SuperClassWriter::writeData(data, fieldid, isCollective, nstep - 1, &start, &count); 
    26392331                CTimer::get("Files : writing data").suspend(); 
    26402332 
     
    26442336                   if ( wtimeData) 
    26452337                   { 
    2646                      SuperClassWriter::writeTimeAxisData(time_data, timeAxisId, isCollective, field->getNStep() - 1, isRoot); 
    2647                      SuperClassWriter::writeTimeAxisDataBounds(time_data_bound, timeAxisBoundId, isCollective, field->getNStep() - 1, isRoot); 
     2338                     SuperClassWriter::writeTimeAxisData(time_data, timeAxisId, isCollective, nstep - 1, isRoot); 
     2339                     SuperClassWriter::writeTimeAxisDataBounds(time_data_bound, timeAxisBoundId, isCollective, nstep - 1, isRoot); 
    26482340                   } 
    26492341                   if (wtimeCounter) 
    26502342                   { 
    2651                      SuperClassWriter::writeTimeAxisData(time_counter, getTimeCounterName(), isCollective, field->getNStep() - 1,isRoot); 
    2652                      if (timeCounterType!=record) SuperClassWriter::writeTimeAxisDataBounds(time_counter_bound, timeBoundId, isCollective, field->getNStep() - 1, isRoot); 
     2343                     SuperClassWriter::writeTimeAxisData(time_counter, getTimeCounterName(), isCollective, nstep - 1,isRoot); 
     2344                     if (timeCounterType!=record) SuperClassWriter::writeTimeAxisDataBounds(time_counter_bound, timeBoundId, isCollective, nstep - 1, isRoot); 
    26532345 
    26542346                   } 
     
    26592351              } 
    26602352            } 
     2353            return nstep ; 
    26612354         } 
    26622355         catch (CNetCdfException& e) 
     
    26912384 
    26922385         StdString strTimeUnits ; 
    2693          if (!field->file->time_units.isEmpty() && field->file->time_units==CFile::time_units_attr::days) strTimeUnits="days since " ; 
     2386         if (!field->getRelFile()->time_units.isEmpty() && field->getRelFile()->time_units==CFile::time_units_attr::days) strTimeUnits="days since " ; 
    26942387         else  strTimeUnits="seconds since " ; 
    26952388  
     
    26982391 
    26992392 
    2700          if (field->file->time_counter.isEmpty()) 
     2393         if (field->getRelFile()->time_counter.isEmpty()) 
    27012394         { 
    27022395           if (timeCounterType==none) createTimeCounterAxis=true ; 
     
    27122405           } 
    27132406         } 
    2714          else if (field->file->time_counter==CFile::time_counter_attr::instant) 
     2407         else if (field->getRelFile()->time_counter==CFile::time_counter_attr::instant) 
    27152408         { 
    27162409           if (field->hasTimeCentered) 
     
    27252418           } 
    27262419         } 
    2727          else if (field->file->time_counter==CFile::time_counter_attr::centered) 
     2420         else if (field->getRelFile()->time_counter==CFile::time_counter_attr::centered) 
    27282421         { 
    27292422           if (field->hasTimeCentered) 
     
    27382431           } 
    27392432         } 
    2740          else if (field->file->time_counter==CFile::time_counter_attr::instant_exclusive) 
     2433         else if (field->getRelFile()->time_counter==CFile::time_counter_attr::instant_exclusive) 
    27412434         { 
    27422435           if (field->hasTimeCentered) 
     
    27502443           } 
    27512444         } 
    2752          else if (field->file->time_counter==CFile::time_counter_attr::centered_exclusive) 
     2445         else if (field->getRelFile()->time_counter==CFile::time_counter_attr::centered_exclusive) 
    27532446         { 
    27542447           if (field->hasTimeCentered) 
     
    27622455           } 
    27632456         } 
    2764          else if (field->file->time_counter==CFile::time_counter_attr::exclusive) 
     2457         else if (field->getRelFile()->time_counter==CFile::time_counter_attr::exclusive) 
    27652458         { 
    27662459           if (field->hasTimeCentered) 
     
    27832476           } 
    27842477         } 
    2785          else if (field->file->time_counter==CFile::time_counter_attr::none) 
     2478         else if (field->getRelFile()->time_counter==CFile::time_counter_attr::none) 
    27862479         { 
    27872480           if (field->hasTimeCentered) 
     
    27942487           } 
    27952488         } 
    2796          else if (field->file->time_counter==CFile::time_counter_attr::record) 
     2489         else if (field->getRelFile()->time_counter==CFile::time_counter_attr::record) 
    27972490         { 
    27982491           if (timeCounterType==none) createTimeCounterAxis=true ; 
     
    28652558                SuperClassWriter::addAttribute("axis", string("T"), &axisId); 
    28662559 
    2867                 if (field->file->time_counter.isEmpty() ||  
    2868                    (field->file->time_counter != CFile::time_counter_attr::record)) 
     2560                if (field->getRelFile()->time_counter.isEmpty() ||  
     2561                   (field->getRelFile()->time_counter != CFile::time_counter_attr::record)) 
    28692562                { 
    28702563                  CDate timeOrigin = cal->getTimeOrigin(); 
     
    28782571 
    28792572             // Adding time_counter_bound dimension 
    2880              if (field->file->time_counter.isEmpty() || (field->file->time_counter != CFile::time_counter_attr::record)) 
     2573             if (field->getRelFile()->time_counter.isEmpty() || (field->getRelFile()->time_counter != CFile::time_counter_attr::record)) 
    28812574             { 
    28822575                if (!SuperClassWriter::varExist(axisBoundId)) 
  • XIOS/dev/dev_trunk_graph/src/io/nc4_data_output.hpp

    r1542 r2019  
    5656            virtual void writeAttribute_(CVariable* var); 
    5757            virtual void writeAttribute_(CVariable* var, const string& fieldId); 
    58             virtual void writeFieldData_(CField* field); 
     58            virtual int  writeFieldData_(CField* field, const CArray<double,1>& data, const CDate& lastWrite, const CDate& currentWrite, int nstep); 
    5959            virtual void writeFile_     (CFile* file); 
    6060            virtual void closeFile_     (void); 
  • XIOS/dev/dev_trunk_graph/src/io/netCdfInterface.cpp

    r1454 r2019  
    894894 
    895895template<> 
     896int CNetCdfInterface::ncGetAttType(int ncid, int varid, const char* attrName, size_t* data) 
     897{ 
     898  return nc_get_att_ulonglong(ncid, varid, attrName, (unsigned long long*)data); 
     899} 
     900 
     901template<> 
    896902int CNetCdfInterface::ncGetAttType(int ncid, int varid, const char* attrName, short* data) 
    897903{ 
     
    936942template<> 
    937943int CNetCdfInterface::ncPutAttType(int ncid, int varid, const char* attrName, 
     944                                   StdSize numVal, const size_t* data) 
     945{ 
     946  return nc_put_att_ulonglong(ncid, varid, attrName, NC_UINT64, numVal, (unsigned long long*) data); 
     947} 
     948 
     949template<> 
     950int CNetCdfInterface::ncPutAttType(int ncid, int varid, const char* attrName, 
    938951                                   StdSize numVal, const short* data) 
    939952{ 
     
    968981 
    969982template<> 
     983int CNetCdfInterface::ncGetVaraType(int ncid, int varid, const StdSize* start, const StdSize* count, size_t* data) 
     984{ 
     985  return nc_get_vara_ulonglong(ncid, varid, start, count, (unsigned long long*) data); 
     986} 
     987 
     988template<> 
    970989int CNetCdfInterface::ncGetVaraType(int ncid, int varid, const StdSize* start, const StdSize* count, char* data) 
    971990{ 
     
    9901009{ 
    9911010  return nc_put_vara_int(ncid, varid, start, count, data); 
     1011} 
     1012 
     1013template<> 
     1014int CNetCdfInterface::ncPutVaraType(int ncid, int varid, const StdSize* start, const StdSize* count, const size_t* data) 
     1015{ 
     1016  return nc_put_vara_ulonglong(ncid, varid, start, count, (unsigned long long*)data); 
    9921017} 
    9931018 
  • XIOS/dev/dev_trunk_graph/src/io/netCdfInterface_decl.cpp

    r1158 r2019  
    2020  macroAtt(float) 
    2121  macroAtt(int) 
     22  macroAtt(size_t) 
    2223  macroAtt(long) 
    2324  macroAtt(short) 
     
    3334  macroPutVar(float) 
    3435  macroPutVar(int) 
     36  macroPutVar(size_t) 
    3537  macroPutVar(char) 
    3638   
     
    4143  macroType(float, NC_FLOAT) 
    4244  macroType(int, NC_INT) 
     45  macroType(size_t, NC_UINT64) 
    4346  macroType(long, NC_LONG) 
    4447  macroType(short, NC_SHORT) 
  • XIOS/dev/dev_trunk_graph/src/io/onetcdf4.cpp

    r1456 r2019  
    538538       
    539539      template <> 
    540  
    541540      void CONetCDF4::writeData_(int grpid, int varid, 
    542541                                 const std::vector<StdSize>& sstart, 
    543542                                 const std::vector<StdSize>& scount, const int* data) 
     543      { 
     544          CNetCdfInterface::putVaraType(grpid, varid, &sstart[0], &scount[0], data); 
     545      } 
     546      //--------------------------------------------------------------- 
     547 
     548      template <> 
     549      void CONetCDF4::writeData_(int grpid, int varid, 
     550                                 const std::vector<StdSize>& sstart, 
     551                                 const std::vector<StdSize>& scount, const size_t* data) 
    544552      { 
    545553          CNetCdfInterface::putVaraType(grpid, varid, &sstart[0], &scount[0], data); 
  • XIOS/dev/dev_trunk_graph/src/io/onetcdf4_decl.cpp

    r1392 r2019  
    1111  macro(int, 1) 
    1212  macro(int, 2) 
     13  macro(size_t, 1) 
     14  macro(size_t, 2) 
    1315  macro(double, 1) 
    1416  macro(double, 2) 
  • XIOS/dev/dev_trunk_graph/src/io/onetcdf4_impl.hpp

    r1686 r2019  
    7676    memset (PtrArrayStr,' ',stringArrayLen*data.numElements()); 
    7777    size_t offset=0 ; 
    78  
     78     
    7979// pb with iterator with blitz++ string array  with recent compiler 
    8080/* 
     
    9090       data(i).copy(PtrArrayStr+offset,data(i).size()) ; 
    9191       PtrArrayStr[offset+data(i).size()]='\0' ; 
    92      }  
     92     } 
    9393     CTimer::get("CONetCDF4::writeData writeData_").resume(); 
    9494     this->writeData_(grpid, varid, sstart, scount, PtrArrayStr); 
Note: See TracChangeset for help on using the changeset viewer.