source: XIOS/dev/XIOS_DEV_CMIP6/src/io/nc4_data_output.cpp @ 1435

Last change on this file since 1435 was 1435, checked in by oabramkina, 6 years ago

Few more grid attributes introduced in addition to r1430.

  • Property copyright set to
    Software name : XIOS (Xml I/O Server)
    http://forge.ipsl.jussieu.fr/ioserver
    Creation date : January 2009
    Licence : CeCCIL version2
    see license file in root directory : Licence_CeCILL_V2-en.txt
    or http://www.cecill.info/licences/Licence_CeCILL_V2-en.html
    Holder : CEA/LSCE (Laboratoire des Sciences du CLimat et de l'Environnement)
    CNRS/IPSL (Institut Pierre Simon Laplace)
    Project Manager : Yann Meurdesoif
    yann.meurdesoif@cea.fr
  • Property svn:executable set to *
File size: 136.4 KB
RevLine 
[219]1#include "nc4_data_output.hpp"
2
3#include <boost/lexical_cast.hpp>
[352]4#include "attribute_template.hpp"
5#include "group_template.hpp"
[219]6
7#include "file.hpp"
8#include "calendar.hpp"
[278]9#include "context.hpp"
[300]10#include "context_server.hpp"
[498]11#include "netCdfException.hpp"
12#include "exception.hpp"
[1158]13#include "timer.hpp"
14#include "uuid.hpp"
[335]15namespace xios
[219]16{
[878]17      /// ////////////////////// Dfinitions ////////////////////// ///
[219]18      CNc4DataOutput::CNc4DataOutput
[1158]19         (CFile* file, const StdString & filename, bool exist)
[219]20            : SuperClass()
21            , SuperClassWriter(filename, exist)
22            , filename(filename)
[1158]23            , file(file),hasTimeInstant(false),hasTimeCentered(false), timeCounterType(none)
[219]24      {
[1158]25        SuperClass::type = MULTI_FILE;
[219]26      }
27
28      CNc4DataOutput::CNc4DataOutput
[1158]29         (CFile* file, const StdString & filename, bool exist, bool useClassicFormat, bool useCFConvention,
[924]30          MPI_Comm comm_file, bool multifile, bool isCollective, const StdString& timeCounterName)
[219]31            : SuperClass()
[878]32            , SuperClassWriter(filename, exist, useClassicFormat, useCFConvention, &comm_file, multifile, timeCounterName)
[379]33            , comm_file(comm_file)
[219]34            , filename(filename)
[335]35            , isCollective(isCollective)
[1158]36            , file(file),hasTimeInstant(false),hasTimeCentered(false), timeCounterType(none)
[219]37      {
[1158]38        SuperClass::type = (multifile) ? MULTI_FILE : ONE_FILE;
[219]39      }
40
41      CNc4DataOutput::~CNc4DataOutput(void)
[879]42    { /* Ne rien faire de plus */ }
[219]43
44      ///--------------------------------------------------------------
45
46      const StdString & CNc4DataOutput::getFileName(void) const
47      {
48         return (this->filename);
49      }
50
51      //---------------------------------------------------------------
52
[347]53      void CNc4DataOutput::writeDomain_(CDomain* domain)
[219]54      {
[1391]55        StdString lonName,latName ;
56         
[1129]57        domain->computeWrittenIndex();
[1249]58        domain->computeWrittenCompressedIndex(comm_file);
59
[881]60        if (domain->type == CDomain::type_attr::unstructured)
61        {
62          if (SuperClassWriter::useCFConvention)
63            writeUnstructuredDomain(domain) ;
64          else
65            writeUnstructuredDomainUgrid(domain) ;
66          return ;
67        }
[488]68
[347]69         CContext* context = CContext::getCurrent() ;
[300]70         CContextServer* server=context->server ;
[488]71
[219]72         if (domain->IsWritten(this->filename)) return;
73         domain->checkAttributes();
[488]74
75         if (domain->isEmpty())
[881]76           if (SuperClass::type==MULTI_FILE) return;
[219]77
78         std::vector<StdString> dim0, dim1;
[772]79         StdString domid = domain->getDomainOutputName();
[318]80         StdString appendDomid  = (singleDomain) ? "" : "_"+domid ;
[706]81         if (isWrittenDomain(domid)) return ;
[774]82         else setWrittenDomain(domid);
[1132]83       
84         int nvertex = (domain->nvertex.isEmpty()) ? 0 : domain->nvertex;
[449]85
[488]86
[1158]87        StdString dimXid, dimYid ;
88
89        nc_type typePrec ;
90        if (domain->prec.isEmpty()) typePrec =  NC_FLOAT ;
91        else if (domain->prec==4)  typePrec =  NC_FLOAT ;
92        else if (domain->prec==8)   typePrec =  NC_DOUBLE ;
93         
[664]94         bool isRegularDomain = (domain->type == CDomain::type_attr::rectilinear);
[449]95         switch (domain->type)
[433]96         {
[449]97           case CDomain::type_attr::curvilinear :
[1391]98
99             if (domain->lon_name.isEmpty()) lonName = "nav_lon";
100             else lonName = domain->lon_name;
101
102             if (domain->lat_name.isEmpty()) latName = "nav_lat";
103             else latName = domain->lat_name;
104
[1430]105             if (domain->dim_i_name.isEmpty()) dimXid=StdString("x").append(appendDomid);
106             else dimXid=domain->dim_i_name.getValue() + appendDomid;
107
108             if (domain->dim_j_name.isEmpty()) dimYid=StdString("y").append(appendDomid);
109             else dimYid=domain->dim_j_name.getValue() + appendDomid;
110
[449]111             break ;
[1391]112
[664]113           case CDomain::type_attr::rectilinear :
[1391]114
[1430]115             if (domain->lon_name.isEmpty())
116             {
117               if (domain->dim_i_name.isEmpty())
118                   lonName = "lon";
119               else
120                 lonName = domain->dim_i_name.getValue();
121             }
[1391]122             else lonName = domain->lon_name;
123
[1430]124             if (domain->lat_name.isEmpty())
125             {
126               if (domain->dim_j_name.isEmpty())
127                 latName = "lat";
128               else
129                 latName = domain->dim_j_name.getValue();
130             }
[1391]131             else latName = domain->lat_name;
132             
[1430]133             if (domain->dim_i_name.isEmpty()) dimXid = lonName+appendDomid;
134             else dimXid = domain->dim_i_name.getValue()+appendDomid;
135
136             if (domain->dim_j_name.isEmpty()) dimYid = latName+appendDomid;
137             else dimYid = domain->dim_j_name.getValue()+appendDomid;
[449]138             break;
[488]139         }
140
[617]141         StdString dimVertId = StdString("nvertex").append(appendDomid);
142
[449]143         string lonid,latid,bounds_lonid,bounds_latid ;
[611]144         string areaId = "area" + appendDomid;
[391]145/*
[300]146         StdString lonid_loc = (server->intraCommSize > 1)
[318]147                             ? StdString("lon").append(appendDomid).append("_local")
[278]148                             : lonid;
[300]149         StdString latid_loc = (server->intraCommSize > 1)
[318]150                             ? StdString("lat").append(appendDomid).append("_local")
[278]151                             : latid;
[391]152*/
[219]153
[1129]154         CArray<size_t, 1>& indexToWrite = domain->localIndexToWriteOnServer;
155         int nbWritten = indexToWrite.numElements();
156         CArray<double,1> writtenLat, writtenLon;
157         CArray<double,2> writtenBndsLat, writtenBndsLon;
158         CArray<double,1> writtenArea;
159
160         if (domain->hasLonLat)
161         {
162           writtenLat.resize(nbWritten);
163           writtenLon.resize(nbWritten);
164           for (int idx = 0; idx < nbWritten; ++idx)
165           {
[1390]166                  if (idx < domain->latvalue.numElements())
167                  {
168                writtenLat(idx) = domain->latvalue(indexToWrite(idx));
169                writtenLon(idx) = domain->lonvalue(indexToWrite(idx));
170                  }
171                  else
172                  {
173                writtenLat(idx) = 0.;
174                writtenLon(idx) = 0.;
175                  }
[1129]176           }
177         
178
179           if (domain->hasBounds)
180           {         
181             int nvertex = domain->nvertex, idx;
182             writtenBndsLat.resize(nvertex, nbWritten);
183             writtenBndsLon.resize(nvertex, nbWritten);
184             CArray<double,2>& boundslat = domain->bounds_latvalue;
185             CArray<double,2>& boundslon = domain->bounds_lonvalue;   
186             for (idx = 0; idx < nbWritten; ++idx)
187               for (int nv = 0; nv < nvertex; ++nv)
188               {
[1390]189                 if (idx < boundslat.columns())
190                 {
191                   writtenBndsLat(nv, idx) = boundslat(nv, int(indexToWrite(idx)));
192                   writtenBndsLon(nv, idx) = boundslon(nv, int(indexToWrite(idx)));
193                 }
194                 else
195                 {
196                   writtenBndsLat(nv, idx) = 0.;
197                   writtenBndsLon(nv, idx) = 0.;
198                 }
[1129]199               }
200           }
201         }
202
203         if (domain->hasArea)
204         {
205           writtenArea.resize(nbWritten);           
206           for (int idx = 0; idx < nbWritten; ++idx)
207           {
[1390]208                  if (idx < domain->areavalue.numElements())
209                writtenArea(idx) = domain->areavalue(indexToWrite(idx));
210                  else
211                writtenArea(idx) = 0.;
[1129]212           }
213         }
214
[498]215         try
[219]216         {
[498]217           switch (SuperClass::type)
218           {
219              case (MULTI_FILE) :
220              {
221  //               if (domain->isEmpty()) return;
[488]222
[498]223                 if (server->intraCommSize > 1)
224                 {
225  //                 SuperClassWriter::addDimension(lonid, domain->zoom_ni.getValue());
226  //                 SuperClassWriter::addDimension(latid, domain->zoom_nj.getValue());
227                 }
[286]228
[498]229                 switch (domain->type)
230                 {
231                   case CDomain::type_attr::curvilinear :
232                     dim0.push_back(dimYid); dim0.push_back(dimXid);
[1415]233                     lonid = lonName+appendDomid;
234                     latid = latName+appendDomid;
[498]235                     break ;
[664]236                   case CDomain::type_attr::rectilinear :
[1415]237                     lonid = lonName+appendDomid;
238                     latid = latName+appendDomid;
[498]239                     dim0.push_back(dimYid);
240                     dim1.push_back(dimXid);
241                     break;
242                 }
[1430]243                 if (!domain->bounds_lon_name.isEmpty()) bounds_lonid = domain->bounds_lon_name;
244                 else bounds_lonid = "bounds_"+lonName+appendDomid;
245                 if (!domain->bounds_lat_name.isEmpty()) bounds_latid = domain->bounds_lat_name;
246                 else bounds_latid = "bounds_"+latName+appendDomid;
[488]247
[1099]248                 SuperClassWriter::addDimension(dimXid, domain->zoom_ni);
249                 SuperClassWriter::addDimension(dimYid, domain->zoom_nj);
[488]250
[617]251                 if (domain->hasBounds)
252                   SuperClassWriter::addDimension(dimVertId, domain->nvertex);
253
[498]254                 if (server->intraCommSize > 1)
255                 {
[1099]256                   this->writeLocalAttributes(domain->zoom_ibegin,
257                                              domain->zoom_ni,
258                                              domain->zoom_jbegin,
259                                              domain->zoom_nj,
[616]260                                              appendDomid);
[488]261
[628]262                   if (singleDomain)
263                    this->writeLocalAttributes_IOIPSL(dimXid, dimYid,
[1099]264                                                      domain->zoom_ibegin,
265                                                      domain->zoom_ni,
266                                                      domain->zoom_jbegin,
267                                                      domain->zoom_nj,
[628]268                                                      domain->ni_glo,domain->nj_glo,
269                                                      server->intraCommRank,server->intraCommSize);
[449]270                 }
[488]271
[665]272                 if (domain->hasLonLat)
[498]273                 {
[665]274                   switch (domain->type)
275                   {
276                     case CDomain::type_attr::curvilinear :
[1158]277                       SuperClassWriter::addVariable(latid, typePrec, dim0);
278                       SuperClassWriter::addVariable(lonid, typePrec, dim0);
[665]279                       break ;
280                      case CDomain::type_attr::rectilinear :
[1158]281                        SuperClassWriter::addVariable(latid, typePrec, dim0);
282                        SuperClassWriter::addVariable(lonid, typePrec, dim1);
[665]283                        break ;
284                   }
[488]285
[665]286                   this->writeAxisAttributes(lonid, isRegularDomain ? "X" : "", "longitude", "Longitude", "degrees_east", domid);
287                   this->writeAxisAttributes(latid, isRegularDomain ? "Y" : "", "latitude", "Latitude", "degrees_north", domid);
[219]288
[665]289                   if (domain->hasBounds)
290                   {
291                     SuperClassWriter::addAttribute("bounds", bounds_lonid, &lonid);
292                     SuperClassWriter::addAttribute("bounds", bounds_latid, &latid);
[617]293
[665]294                     dim0.clear();
295                     dim0.push_back(dimYid);
296                     dim0.push_back(dimXid);
297                     dim0.push_back(dimVertId);
[1158]298                     SuperClassWriter::addVariable(bounds_lonid, typePrec, dim0);
299                     SuperClassWriter::addVariable(bounds_latid, typePrec, dim0);
[665]300                   }
[617]301                 }
302
[498]303                 dim0.clear();
[616]304                 dim0.push_back(dimYid);
[498]305                 dim0.push_back(dimXid);
[219]306
307
[498]308  // supress mask               if (server->intraCommSize > 1)
309  // supress mask               {
310  // supress mask                  SuperClassWriter::addVariable(maskid, NC_INT, dim0);
311  // supress mask
312  // supress mask                  this->writeMaskAttributes(maskid,
313  // supress mask                     domain->data_dim.getValue()/*,
314  // supress mask                     domain->data_ni.getValue(),
315  // supress mask                     domain->data_nj.getValue(),
316  // supress mask                     domain->data_ibegin.getValue(),
317  // supress mask                     domain->data_jbegin.getValue()*/);
318  // supress mask               }
[488]319
[498]320                 //SuperClassWriter::setDefaultValue(maskid, &dvm);
[219]321
[611]322                 if (domain->hasArea)
323                 {
[1158]324                   SuperClassWriter::addVariable(areaId, typePrec, dim0);
[614]325                   SuperClassWriter::addAttribute("standard_name", StdString("cell_area"), &areaId);
[611]326                   SuperClassWriter::addAttribute("units", StdString("m2"), &areaId);
327                 }
328
[498]329                 SuperClassWriter::definition_end();
[449]330
[665]331                 if (domain->hasLonLat)
[498]332                 {
[665]333                   switch (domain->type)
334                   {
[1129]335                     case CDomain::type_attr::curvilinear :                       
336                       SuperClassWriter::writeData(writtenLat, latid, isCollective, 0);
337                       SuperClassWriter::writeData(writtenLon, lonid, isCollective, 0);
[665]338                       break;
339                     case CDomain::type_attr::rectilinear :
[1129]340                       CArray<double,1> lat = writtenLat(Range(fromStart,toEnd,domain->zoom_ni)) ;
[665]341                       SuperClassWriter::writeData(CArray<double,1>(lat.copy()), latid, isCollective, 0);
[1129]342                       CArray<double,1> lon = writtenLon(Range(0,domain->zoom_ni-1)) ;
[665]343                       SuperClassWriter::writeData(CArray<double,1>(lon.copy()), lonid, isCollective, 0);
344                       break;
345                   }
[611]346
[665]347                   if (domain->hasBounds)
348                   {
[1129]349                     SuperClassWriter::writeData(writtenBndsLon, bounds_lonid, isCollective, 0);
350                     SuperClassWriter::writeData(writtenBndsLat, bounds_latid, isCollective, 0);
[665]351                   }
[617]352                 }
353
[611]354                 if (domain->hasArea)
[1129]355                 {
[1132]356                   SuperClassWriter::writeData(writtenArea, areaId, isCollective, 0);                   
[1129]357                 }
358
[498]359                 SuperClassWriter::definition_start();
[219]360
[498]361                 break;
362              }
363              case (ONE_FILE) :
364              {
[1099]365                 SuperClassWriter::addDimension(dimXid, domain->global_zoom_ni);
366                 SuperClassWriter::addDimension(dimYid, domain->global_zoom_nj);
[286]367
[617]368                 if (domain->hasBounds)
369                   SuperClassWriter::addDimension(dimVertId, domain->nvertex);
370
[665]371                 if (domain->hasLonLat)
[498]372                 {
[665]373                   switch (domain->type)
374                   {
375                     case CDomain::type_attr::curvilinear :
376                       dim0.push_back(dimYid); dim0.push_back(dimXid);
[1415]377                       lonid = lonName+appendDomid;
378                       latid = latName+appendDomid;
[1158]379                       SuperClassWriter::addVariable(latid, typePrec, dim0);
380                       SuperClassWriter::addVariable(lonid, typePrec, dim0);
[665]381                       break;
[449]382
[665]383                     case CDomain::type_attr::rectilinear :
384                       dim0.push_back(dimYid);
385                       dim1.push_back(dimXid);
[1415]386                       lonid = lonName+appendDomid;
387                       latid = latName+appendDomid;
[1158]388                       SuperClassWriter::addVariable(latid, typePrec, dim0);
389                       SuperClassWriter::addVariable(lonid, typePrec, dim1);
[665]390                       break;
391                   }
[1430]392                   if (!domain->bounds_lon_name.isEmpty()) bounds_lonid = domain->bounds_lon_name;
393                   else bounds_lonid = "bounds_"+lonName+appendDomid;
394                   if (!domain->bounds_lat_name.isEmpty()) bounds_latid = domain->bounds_lat_name;
395                   else bounds_latid = "bounds_"+latName+appendDomid;
[665]396
397                   this->writeAxisAttributes
398                      (lonid, isRegularDomain ? "X" : "", "longitude", "Longitude", "degrees_east", domid);
399                   this->writeAxisAttributes
400                      (latid, isRegularDomain ? "Y" : "", "latitude", "Latitude", "degrees_north", domid);
401
402                   if (domain->hasBounds)
403                   {
404                     SuperClassWriter::addAttribute("bounds", bounds_lonid, &lonid);
405                     SuperClassWriter::addAttribute("bounds", bounds_latid, &latid);
406
407                     dim0.clear();
[498]408                     dim0.push_back(dimYid);
[665]409                     dim0.push_back(dimXid);
410                     dim0.push_back(dimVertId);
[1158]411                     SuperClassWriter::addVariable(bounds_lonid, typePrec, dim0);
412                     SuperClassWriter::addVariable(bounds_latid, typePrec, dim0);
[665]413                   }
[498]414                 }
[611]415
416                 if (domain->hasArea)
417                 {
418                   dim0.clear();
419                   dim0.push_back(dimYid); dim0.push_back(dimXid);
[1158]420                   SuperClassWriter::addVariable(areaId, typePrec, dim0);
[614]421                   SuperClassWriter::addAttribute("standard_name", StdString("cell_area"), &areaId);
[611]422                   SuperClassWriter::addAttribute("units", StdString("m2"), &areaId);
423                   dim0.clear();
424                 }
425
426                 SuperClassWriter::definition_end();
[286]427
[498]428                 switch (domain->type)
[384]429                 {
[498]430                   case CDomain::type_attr::curvilinear :
[449]431                   {
[498]432                     std::vector<StdSize> start(2) ;
433                     std::vector<StdSize> count(2) ;
434                     if (domain->isEmpty())
435                     {
[611]436                       start[0]=0 ; start[1]=0 ;
[498]437                       count[0]=0 ; count[1]=0 ;
438                     }
439                     else
440                     {
[1099]441                       start[1]=domain->zoom_ibegin-domain->global_zoom_ibegin;
442                       start[0]=domain->zoom_jbegin-domain->global_zoom_jbegin;
443                       count[1]=domain->zoom_ni ; count[0]=domain->zoom_nj ;
[498]444                     }
[488]445
[665]446                     if (domain->hasLonLat)
447                     {
[1129]448                       SuperClassWriter::writeData(writtenLat, latid, isCollective, 0,&start,&count);
449                       SuperClassWriter::writeData(writtenLon, lonid, isCollective, 0,&start,&count);
[665]450                     }
[498]451                     break;
452                   }
[664]453                   case CDomain::type_attr::rectilinear :
[449]454                   {
[665]455                     if (domain->hasLonLat)
[498]456                     {
[665]457                       std::vector<StdSize> start(1) ;
458                       std::vector<StdSize> count(1) ;
459                       if (domain->isEmpty())
460                       {
461                         start[0]=0 ;
462                         count[0]=0 ;
[1129]463                         SuperClassWriter::writeData(writtenLat, latid, isCollective, 0,&start,&count);
464                         SuperClassWriter::writeData(writtenLon, lonid, isCollective, 0,&start,&count);
[665]465                       }
466                       else
[1129]467                       { 
[1099]468                         start[0]=domain->zoom_jbegin-domain->global_zoom_jbegin;
[1143]469                         count[0]=domain->zoom_nj;                         
[1129]470                         CArray<double,1> lat = writtenLat(Range(fromStart,toEnd,domain->zoom_ni));
[665]471                         SuperClassWriter::writeData(CArray<double,1>(lat.copy()), latid, isCollective, 0,&start,&count);
472
[1099]473                         start[0]=domain->zoom_ibegin-domain->global_zoom_ibegin;
[1143]474                         count[0]=domain->zoom_ni;                         
[1129]475                         CArray<double,1> lon = writtenLon(Range(0,domain->zoom_ni-1));
[665]476                         SuperClassWriter::writeData(CArray<double,1>(lon.copy()), lonid, isCollective, 0,&start,&count);
477                       }
[498]478                     }
479                     break;
[449]480                   }
[384]481                 }
[611]482
[617]483                 if (domain->hasBounds)
484                 {
485                   std::vector<StdSize> start(3);
486                   std::vector<StdSize> count(3);
487                   if (domain->isEmpty())
488                   {
489                     start[2] = start[1] = start[0] = 0;
490                     count[2] = count[1] = count[0] = 0;
491                   }
492                   else
493                   {
494                     start[2] = 0;
[1099]495                     start[1] = domain->zoom_ibegin - domain->global_zoom_ibegin;
496                     start[0] = domain->zoom_jbegin - domain->global_zoom_jbegin;
497                     count[2] = domain->nvertex;
498                     count[1] = domain->zoom_ni;
499                     count[0] = domain->zoom_nj;
[617]500                   }
[1143]501                 
[1129]502                   SuperClassWriter::writeData(writtenBndsLon, bounds_lonid, isCollective, 0, &start, &count);
503                   SuperClassWriter::writeData(writtenBndsLat, bounds_latid, isCollective, 0, &start, &count);
[617]504                 }
505
[611]506                 if (domain->hasArea)
507                 {
508                   std::vector<StdSize> start(2);
509                   std::vector<StdSize> count(2);
510
511                   if (domain->isEmpty())
512                   {
513                     start[0] = 0; start[1] = 0;
514                     count[0] = 0; count[1] = 0;
515                   }
516                   else
517                   {
[1099]518                     start[1] = domain->zoom_ibegin - domain->global_zoom_ibegin;
519                     start[0] = domain->zoom_jbegin - domain->global_zoom_jbegin;
520                     count[1] = domain->zoom_ni;
521                     count[0] = domain->zoom_nj;
[611]522                   }
[1143]523                   
[1129]524                   SuperClassWriter::writeData(writtenArea, areaId, isCollective, 0, &start, &count);
[611]525                 }
526
[498]527                 SuperClassWriter::definition_start();
528                 break;
529              }
530              default :
531                 ERROR("CNc4DataOutput::writeDomain(domain)",
532                       << "[ type = " << SuperClass::type << "]"
533                       << " not implemented yet !");
534           }
[449]535         }
[498]536         catch (CNetCdfException& e)
537         {
538           StdString msg("On writing the domain : ");
539           msg.append(domid); msg.append("\n");
540           msg.append("In the context : ");
541           msg.append(context->getId()); msg.append("\n");
542           msg.append(e.what());
543           ERROR("CNc4DataOutput::writeDomain_(CDomain* domain)", << msg);
544         }
545
[449]546         domain->addRelFile(this->filename);
547      }
548
[879]549    //--------------------------------------------------------------
[878]550
[879]551    void CNc4DataOutput::writeUnstructuredDomainUgrid(CDomain* domain)
552    {
553      CContext* context = CContext::getCurrent() ;
554      CContextServer* server=context->server ;
[878]555
[879]556      if (domain->IsWritten(this->filename)) return;
557      domain->checkAttributes();
558      if (domain->isEmpty())
559        if (SuperClass::type==MULTI_FILE) return ;
[878]560
[1158]561     nc_type typePrec ;
562     if (domain->prec.isEmpty()) typePrec =  NC_FLOAT ;
563     else if (domain->prec==4)  typePrec =  NC_FLOAT ;
564     else if (domain->prec==8)   typePrec =  NC_DOUBLE ;
565
[879]566      std::vector<StdString> dim0;
567      StdString domid = domain->getDomainOutputName();
568      StdString domainName = domain->name;
[924]569      domain->assignMesh(domainName, domain->nvertex);
[1025]570      domain->mesh->createMeshEpsilon(server->intraComm, domain->lonvalue, domain->latvalue, domain->bounds_lonvalue, domain->bounds_latvalue);
[878]571
[879]572      StdString node_x = domainName + "_node_x";
573      StdString node_y = domainName + "_node_y";
[878]574
[879]575      StdString edge_x = domainName + "_edge_x";
576      StdString edge_y = domainName + "_edge_y";
577      StdString edge_nodes = domainName + "_edge_nodes";
[878]578
[879]579      StdString face_x = domainName + "_face_x";
580      StdString face_y = domainName + "_face_y";
581      StdString face_nodes = domainName + "_face_nodes";
[902]582      StdString face_edges = domainName + "_face_edges";
583      StdString edge_faces = domainName + "_edge_face_links";
584      StdString face_faces = domainName + "_face_links";
[878]585
[879]586      StdString dimNode = "n" + domainName + "_node";
587      StdString dimEdge = "n" + domainName + "_edge";
588      StdString dimFace = "n" + domainName + "_face";
589      StdString dimVertex = "n" + domainName + "_vertex";
590      StdString dimTwo = "Two";
[878]591
[879]592      if (!SuperClassWriter::dimExist(dimTwo)) SuperClassWriter::addDimension(dimTwo, 2);
593      if (!isWrittenDomain(domid))
594      {
595        dim0.clear();
596        SuperClassWriter::addVariable(domainName, NC_INT, dim0);
597        SuperClassWriter::addAttribute("cf_role", StdString("mesh_topology"), &domainName);
[924]598        SuperClassWriter::addAttribute("long_name", StdString("Topology data of 2D unstructured mesh"), &domainName);
599        SuperClassWriter::addAttribute("topology_dimension", 2, &domainName);
[879]600        SuperClassWriter::addAttribute("node_coordinates", node_x + " " + node_y, &domainName);
601      }
[878]602
[879]603      try
604      {
605        switch (SuperClass::type)
606        {
607          case (ONE_FILE) :
608          {
609            // Adding nodes
610            if (domain->nvertex == 1)
611            {
612              if (!SuperClassWriter::varExist(node_x) || !SuperClassWriter::varExist(node_y))
613              {
[902]614                SuperClassWriter::addDimension(dimNode, domain->ni_glo);
[879]615                dim0.clear();
616                dim0.push_back(dimNode);
[1158]617                SuperClassWriter::addVariable(node_x, typePrec, dim0);
[879]618                SuperClassWriter::addAttribute("standard_name", StdString("longitude"), &node_x);
[924]619                SuperClassWriter::addAttribute("long_name", StdString("Longitude of mesh nodes."), &node_x);
[879]620                SuperClassWriter::addAttribute("units", StdString("degrees_east"), &node_x);
[1158]621                SuperClassWriter::addVariable(node_y, typePrec, dim0);
[879]622                SuperClassWriter::addAttribute("standard_name", StdString("latitude"), &node_y);
[924]623                SuperClassWriter::addAttribute("long_name", StdString("Latitude of mesh nodes."), &node_y);
[879]624                SuperClassWriter::addAttribute("units", StdString("degrees_north"), &node_y);
625              }
626            } // domain->nvertex == 1
[878]627
[879]628            // Adding edges and nodes, if nodes have not been defined previously
629            if (domain->nvertex == 2)
630            {
631              if (!SuperClassWriter::varExist(node_x) || !SuperClassWriter::varExist(node_y))
632              {
[924]633                SuperClassWriter::addDimension(dimNode, domain->mesh->nbNodesGlo);
[879]634                dim0.clear();
635                dim0.push_back(dimNode);
[1158]636                SuperClassWriter::addVariable(node_x, typePrec, dim0);
[879]637                SuperClassWriter::addAttribute("standard_name", StdString("longitude"), &node_x);
[924]638                SuperClassWriter::addAttribute("long_name", StdString("Longitude of mesh nodes."), &node_x);
[879]639                SuperClassWriter::addAttribute("units", StdString("degrees_east"), &node_x);
[1158]640                SuperClassWriter::addVariable(node_y, typePrec, dim0);
[879]641                SuperClassWriter::addAttribute("standard_name", StdString("latitude"), &node_y);
[924]642                SuperClassWriter::addAttribute("long_name", StdString("Latitude of mesh nodes."), &node_y);
[879]643                SuperClassWriter::addAttribute("units", StdString("degrees_north"), &node_y);
644              }
[924]645              SuperClassWriter::addAttribute("edge_node_connectivity", edge_nodes, &domainName);
646              SuperClassWriter::addAttribute("edge_coordinates", edge_x + " " + edge_y, &domainName);
647              SuperClassWriter::addDimension(dimEdge, domain->ni_glo);
648              dim0.clear();
649              dim0.push_back(dimEdge);
[1158]650              SuperClassWriter::addVariable(edge_x, typePrec, dim0);
[924]651              SuperClassWriter::addAttribute("standard_name", StdString("longitude"), &edge_x);
652              SuperClassWriter::addAttribute("long_name", StdString("Characteristic longitude of mesh edges."), &edge_x);
653              SuperClassWriter::addAttribute("units", StdString("degrees_east"), &edge_x);
[1158]654              SuperClassWriter::addVariable(edge_y, typePrec, dim0);
[924]655              SuperClassWriter::addAttribute("standard_name", StdString("latitude"), &edge_y);
656              SuperClassWriter::addAttribute("long_name", StdString("Characteristic latitude of mesh edges."), &edge_y);
657              SuperClassWriter::addAttribute("units", StdString("degrees_north"), &edge_y);
658              dim0.clear();
659              dim0.push_back(dimEdge);
660              dim0.push_back(dimTwo);
661              SuperClassWriter::addVariable(edge_nodes, NC_INT, dim0);
662              SuperClassWriter::addAttribute("cf_role", StdString("edge_node_connectivity"), &edge_nodes);
663              SuperClassWriter::addAttribute("long_name", StdString("Maps every edge/link to two nodes that it connects."), &edge_nodes);
664              SuperClassWriter::addAttribute("start_index", 0, &edge_nodes);
[879]665            } // domain->nvertex == 2
[878]666
[879]667            // Adding faces, edges, and nodes, if edges and nodes have not been defined previously
668            if (domain->nvertex > 2)
669            {
670              // Nodes
671              if (!SuperClassWriter::varExist(node_x) || !SuperClassWriter::varExist(node_y))
672              {
[924]673                SuperClassWriter::addDimension(dimNode, domain->mesh->nbNodesGlo);
[879]674                dim0.clear();
675                dim0.push_back(dimNode);
[1158]676                SuperClassWriter::addVariable(node_x, typePrec, dim0);
[879]677                SuperClassWriter::addAttribute("standard_name", StdString("longitude"), &node_x);
[924]678                SuperClassWriter::addAttribute("long_name", StdString("Longitude of mesh nodes."), &node_x);
[879]679                SuperClassWriter::addAttribute("units", StdString("degrees_east"), &node_x);
[1158]680                SuperClassWriter::addVariable(node_y, typePrec, dim0);
[879]681                SuperClassWriter::addAttribute("standard_name", StdString("latitude"), &node_y);
[924]682                SuperClassWriter::addAttribute("long_name", StdString("Latitude of mesh nodes."), &node_y);
[879]683                SuperClassWriter::addAttribute("units", StdString("degrees_north"), &node_y);
684              }
685              if (!SuperClassWriter::varExist(edge_x) || !SuperClassWriter::varExist(edge_y))
686              {
687                SuperClassWriter::addAttribute("edge_coordinates", edge_x + " " + edge_y, &domainName);
688                SuperClassWriter::addAttribute("edge_node_connectivity", edge_nodes, &domainName);
[924]689                SuperClassWriter::addDimension(dimEdge, domain->mesh->nbEdgesGlo);
[879]690                dim0.clear();
691                dim0.push_back(dimEdge);
[1158]692                SuperClassWriter::addVariable(edge_x, typePrec, dim0);
[879]693                SuperClassWriter::addAttribute("standard_name", StdString("longitude"), &edge_x);
[924]694                SuperClassWriter::addAttribute("long_name", StdString("Characteristic longitude of mesh edges."), &edge_x);
[879]695                SuperClassWriter::addAttribute("units", StdString("degrees_east"), &edge_x);
[1158]696                SuperClassWriter::addVariable(edge_y, typePrec, dim0);
[879]697                SuperClassWriter::addAttribute("standard_name", StdString("latitude"), &edge_y);
[924]698                SuperClassWriter::addAttribute("long_name", StdString("Characteristic latitude of mesh edges."), &edge_y);
[879]699                SuperClassWriter::addAttribute("units", StdString("degrees_north"), &edge_y);
700                dim0.clear();
701                dim0.push_back(dimEdge);
702                dim0.push_back(dimTwo);
703                SuperClassWriter::addVariable(edge_nodes, NC_INT, dim0);
704                SuperClassWriter::addAttribute("cf_role", StdString("edge_node_connectivity"), &edge_nodes);
705                SuperClassWriter::addAttribute("long_name", StdString("Maps every edge/link to two nodes that it connects."), &edge_nodes);
706                SuperClassWriter::addAttribute("start_index", 0, &edge_nodes);
707              }
[924]708              SuperClassWriter::addAttribute("face_coordinates", face_x + " " + face_y, &domainName);
709              SuperClassWriter::addAttribute("face_node_connectivity", face_nodes, &domainName);
710              SuperClassWriter::addDimension(dimFace, domain->ni_glo);
711              SuperClassWriter::addDimension(dimVertex, domain->nvertex);
712              dim0.clear();
713              dim0.push_back(dimFace);
[1158]714              SuperClassWriter::addVariable(face_x, typePrec, dim0);
[924]715              SuperClassWriter::addAttribute("standard_name", StdString("longitude"), &face_x);
716              SuperClassWriter::addAttribute("long_name", StdString("Characteristic longitude of mesh faces."), &face_x);
717              SuperClassWriter::addAttribute("units", StdString("degrees_east"), &face_x);
[1158]718              SuperClassWriter::addVariable(face_y, typePrec, dim0);
[924]719              SuperClassWriter::addAttribute("standard_name", StdString("latitude"), &face_y);
720              SuperClassWriter::addAttribute("long_name", StdString("Characteristic latitude of mesh faces."), &face_y);
721              SuperClassWriter::addAttribute("units", StdString("degrees_north"), &face_y);
722              dim0.clear();
723              dim0.push_back(dimFace);
724              dim0.push_back(dimVertex);
725              SuperClassWriter::addVariable(face_nodes, NC_INT, dim0);
726              SuperClassWriter::addAttribute("cf_role", StdString("face_node_connectivity"), &face_nodes);
727              SuperClassWriter::addAttribute("long_name", StdString("Maps every face to its corner nodes."), &face_nodes);
728              SuperClassWriter::addAttribute("start_index", 0, &face_nodes);
729              dim0.clear();
730              dim0.push_back(dimFace);
731              dim0.push_back(dimVertex);
732              SuperClassWriter::addVariable(face_edges, NC_INT, dim0);
733              SuperClassWriter::addAttribute("cf_role", StdString("face_edge_connectivity"), &face_edges);
734              SuperClassWriter::addAttribute("long_name", StdString("Maps every face to its edges."), &face_edges);
735              SuperClassWriter::addAttribute("start_index", 0, &face_edges);
[929]736              SuperClassWriter::addAttribute("_FillValue", 999999, &face_edges);
[924]737              dim0.clear();
738              dim0.push_back(dimEdge);
739              dim0.push_back(dimTwo);
740              SuperClassWriter::addVariable(edge_faces, NC_INT, dim0);
741              SuperClassWriter::addAttribute("cf_role", StdString("edge_face connectivity"), &edge_faces);
742              SuperClassWriter::addAttribute("long_name", StdString("neighbor faces for edges"), &edge_faces);
743              SuperClassWriter::addAttribute("start_index", 0, &edge_faces);
744              SuperClassWriter::addAttribute("_FillValue", -999, &edge_faces);
745              SuperClassWriter::addAttribute("comment", StdString("missing neighbor faces are indicated using _FillValue"), &edge_faces);
746              dim0.clear();
747              dim0.push_back(dimFace);
748              dim0.push_back(dimVertex);
749              SuperClassWriter::addVariable(face_faces, NC_INT, dim0);
750              SuperClassWriter::addAttribute("cf_role", StdString("face_face connectivity"), &face_faces);
751              SuperClassWriter::addAttribute("long_name", StdString("Indicates which other faces neighbor each face"), &face_faces);
752              SuperClassWriter::addAttribute("start_index", 0, &face_faces);
[929]753              SuperClassWriter::addAttribute("_FillValue", 999999, &face_faces);
[924]754              SuperClassWriter::addAttribute("flag_values", -1, &face_faces);
755              SuperClassWriter::addAttribute("flag_meanings", StdString("out_of_mesh"), &face_faces);
[879]756            } // domain->nvertex > 2
[878]757
[879]758            SuperClassWriter::definition_end();
[878]759
[924]760            std::vector<StdSize> startEdges(1) ;
761            std::vector<StdSize> countEdges(1) ;
762            std::vector<StdSize> startNodes(1) ;
763            std::vector<StdSize> countNodes(1) ;
764            std::vector<StdSize> startFaces(1) ;
765            std::vector<StdSize> countFaces(1) ;
766            std::vector<StdSize> startEdgeNodes(2) ;
767            std::vector<StdSize> countEdgeNodes(2) ;
768            std::vector<StdSize> startEdgeFaces(2) ;
769            std::vector<StdSize> countEdgeFaces(2) ;
770            std::vector<StdSize> startFaceConctv(2) ;
771            std::vector<StdSize> countFaceConctv(2) ;
[902]772
[879]773            if (!isWrittenDomain(domid))
774            {
775              if (domain->nvertex == 1)
776              {
[924]777                if (domain->isEmpty())
778                 {
779                   startNodes[0]=0 ;
780                   countNodes[0]=0 ;
781                 }
782                 else
783                 {
[1132]784                   startNodes[0] = domain->zoom_ibegin-domain->global_zoom_ibegin;
785                   countNodes[0] = domain->zoom_ni ;
[924]786                 }
787
788                SuperClassWriter::writeData(domain->mesh->node_lat, node_y, isCollective, 0, &startNodes, &countNodes);
789                SuperClassWriter::writeData(domain->mesh->node_lon, node_x, isCollective, 0, &startNodes, &countNodes);
[879]790              }
791              else if (domain->nvertex == 2)
[924]792              {
793                if (domain->isEmpty())
794                 {
795                  startEdges[0]=0 ;
796                  countEdges[0]=0 ;
797                  startNodes[0]=0 ;
798                  countNodes[0]=0 ;
799                  startEdgeNodes[0]=0;
800                  startEdgeNodes[1]=0;
801                  countEdgeNodes[0]=0;
802                  countEdgeNodes[1]=0;
803
804                 }
805                 else
806                 {
[1132]807                   startEdges[0] = domain->zoom_ibegin-domain->global_zoom_ibegin;
808                   countEdges[0] = domain->zoom_ni;
[924]809                   startNodes[0] = domain->mesh->node_start;
810                   countNodes[0] = domain->mesh->node_count;
[1132]811                   startEdgeNodes[0] = domain->zoom_ibegin-domain->global_zoom_ibegin;
[924]812                   startEdgeNodes[1] = 0;
[1132]813                   countEdgeNodes[0] = domain->zoom_ni;
814                   countEdgeNodes[1] = 2;
[924]815                 }
816                SuperClassWriter::writeData(domain->mesh->node_lat, node_y, isCollective, 0, &startNodes, &countNodes);
817                SuperClassWriter::writeData(domain->mesh->node_lon, node_x, isCollective, 0, &startNodes, &countNodes);
818                SuperClassWriter::writeData(domain->mesh->edge_lat, edge_y, isCollective, 0, &startEdges, &countEdges);
819                SuperClassWriter::writeData(domain->mesh->edge_lon, edge_x, isCollective, 0, &startEdges, &countEdges);
820                SuperClassWriter::writeData(domain->mesh->edge_nodes, edge_nodes, isCollective, 0, &startEdgeNodes, &countEdgeNodes);
821              }
[879]822              else
823              {
[924]824                if (domain->isEmpty())
825                 {
826                   startFaces[0] = 0 ;
827                   countFaces[0] = 0 ;
828                   startNodes[0] = 0;
829                   countNodes[0] = 0;
830                   startEdges[0] = 0;
831                   countEdges[0] = 0;
832                   startEdgeFaces[0] = 0;
833                   startEdgeFaces[1] = 0;
834                   countEdgeFaces[0] = 0;
835                   countEdgeFaces[1] = 0;
836                   startFaceConctv[0] = 0;
837                   startFaceConctv[1] = 0;
838                   countFaceConctv[0] = 0;
839                   countFaceConctv[1] = 0;
840                 }
841                 else
842                 {
[1132]843                   startFaces[0] = domain->zoom_ibegin-domain->global_zoom_ibegin;
844                   countFaces[0] = domain->zoom_ni ;
[924]845                   startNodes[0] = domain->mesh->node_start;
846                   countNodes[0] = domain->mesh->node_count;
847                   startEdges[0] = domain->mesh->edge_start;
848                   countEdges[0] = domain->mesh->edge_count;
849                   startEdgeNodes[0] = domain->mesh->edge_start;
850                   startEdgeNodes[1] = 0;
851                   countEdgeNodes[0] = domain->mesh->edge_count;
852                   countEdgeNodes[1]= 2;
853                   startEdgeFaces[0] = domain->mesh->edge_start;
854                   startEdgeFaces[1]= 0;
855                   countEdgeFaces[0] = domain->mesh->edge_count;
856                   countEdgeFaces[1]= 2;
[1132]857                   startFaceConctv[0] = domain->zoom_ibegin-domain->global_zoom_ibegin;
858                   startFaceConctv[1] = 0; 
859                   countFaceConctv[0] = domain->zoom_ni;
[924]860                   countFaceConctv[1] = domain->nvertex;
861                 }
862                SuperClassWriter::writeData(domain->mesh->node_lat, node_y, isCollective, 0, &startNodes, &countNodes);
863                SuperClassWriter::writeData(domain->mesh->node_lon, node_x, isCollective, 0, &startNodes, &countNodes);
864                SuperClassWriter::writeData(domain->mesh->edge_lat, edge_y, isCollective, 0, &startEdges, &countEdges);
865                SuperClassWriter::writeData(domain->mesh->edge_lon, edge_x, isCollective, 0, &startEdges, &countEdges);
866                SuperClassWriter::writeData(domain->mesh->edge_nodes, edge_nodes, isCollective, 0, &startEdgeNodes, &countEdgeNodes);
867                SuperClassWriter::writeData(domain->mesh->face_lat, face_y, isCollective, 0, &startFaces, &countFaces);
868                SuperClassWriter::writeData(domain->mesh->face_lon, face_x, isCollective, 0, &startFaces, &countFaces);
869                SuperClassWriter::writeData(domain->mesh->face_nodes, face_nodes, isCollective, 0, &startFaceConctv, &countFaceConctv);
870                SuperClassWriter::writeData(domain->mesh->face_edges, face_edges, isCollective, 0, &startFaceConctv, &countFaceConctv);
871                SuperClassWriter::writeData(domain->mesh->edge_faces, edge_faces, isCollective, 0, &startEdgeFaces, &countEdgeFaces);
872                SuperClassWriter::writeData(domain->mesh->face_faces, face_faces, isCollective, 0, &startFaceConctv, &countFaceConctv);
[879]873              }
874              setWrittenDomain(domid);
875            } // !isWrittenDomain
876            else
877            {
878              if (domain->nvertex == 2)
879              {
[1132]880                startEdges[0] = domain->zoom_ibegin-domain->global_zoom_ibegin;
881                countEdges[0] = domain->zoom_ni;
882                startEdgeNodes[0] = domain->zoom_ibegin-domain->global_zoom_ibegin;
883                startEdgeNodes[1] = 0;
884                countEdgeNodes[0] = domain->zoom_ni;
[924]885                countEdgeNodes[1]= 2;
886                SuperClassWriter::writeData(domain->mesh->edge_lat, edge_y, isCollective, 0, &startEdges, &countEdges);
887                SuperClassWriter::writeData(domain->mesh->edge_lon, edge_x, isCollective, 0, &startEdges, &countEdges);
888                SuperClassWriter::writeData(domain->mesh->edge_nodes, edge_nodes, isCollective, 0, &startEdgeNodes, &countEdgeNodes);
[879]889              } 
890              if (domain->nvertex > 2)
891              {
[924]892
[879]893                if (!domain->mesh->edgesAreWritten)
894                {
[924]895                  startEdges[0] = domain->mesh->edge_start;
896                  countEdges[0] = domain->mesh->edge_count;
897                  startEdgeNodes[0] = domain->mesh->edge_start;
898                  startEdgeNodes[1] = 0;
899                  countEdgeNodes[0] = domain->mesh->edge_count;
900                  countEdgeNodes[1]= 2;
901                  SuperClassWriter::writeData(domain->mesh->edge_lat, edge_y, isCollective, 0, &startEdges, &countEdges);
902                  SuperClassWriter::writeData(domain->mesh->edge_lon, edge_x, isCollective, 0, &startEdges, &countEdges);
903                  SuperClassWriter::writeData(domain->mesh->edge_nodes, edge_nodes, isCollective, 0, &startEdgeNodes, &countEdgeNodes);
[879]904                }
[1132]905                startFaces[0] = domain->zoom_ibegin-domain->global_zoom_ibegin;
906                countFaces[0] = domain->zoom_ni;
[924]907                startEdgeFaces[0] = domain->mesh->edge_start;
908                startEdgeFaces[1]= 0;
909                countEdgeFaces[0] = domain->mesh->edge_count;
910                countEdgeFaces[1]= 2;
[1132]911                startFaceConctv[0] = domain->zoom_ibegin-domain->global_zoom_ibegin;
912                startFaceConctv[1] = 0;
913                countFaceConctv[0] = domain->zoom_ni;
914                countFaceConctv[1] = domain->nvertex;
[924]915                SuperClassWriter::writeData(domain->mesh->face_lat, face_y, isCollective, 0, &startFaces, &countFaces);
916                SuperClassWriter::writeData(domain->mesh->face_lon, face_x, isCollective, 0, &startFaces, &countFaces);
917                SuperClassWriter::writeData(domain->mesh->face_nodes, face_nodes, isCollective, 0, &startFaceConctv, &countFaceConctv);
918                SuperClassWriter::writeData(domain->mesh->face_edges, face_edges, isCollective, 0, &startFaceConctv, &countFaceConctv);
919                SuperClassWriter::writeData(domain->mesh->edge_faces, edge_faces, isCollective, 0, &startEdgeFaces, &countEdgeFaces);
920                SuperClassWriter::writeData(domain->mesh->face_faces, face_faces, isCollective, 0, &startFaceConctv, &countFaceConctv);
[879]921              }
922            }// isWrittenDomain
[878]923
[879]924            SuperClassWriter::definition_start();
[878]925
[879]926            break;
927          } // ONE_FILE
[878]928
[879]929          case (MULTI_FILE) :
930          {
931            break;
932          }
[878]933
[879]934          default :
935          ERROR("CNc4DataOutput::writeDomain(domain)",
936          << "[ type = " << SuperClass::type << "]"
937          << " not implemented yet !");
938          } // switch
939        } // try
[878]940
[879]941        catch (CNetCdfException& e)
942        {
943          StdString msg("On writing the domain : ");
944          msg.append(domid); msg.append("\n");
945          msg.append("In the context : ");
946          msg.append(context->getId()); msg.append("\n");
947          msg.append(e.what());
[924]948          ERROR("CNc4DataOutput::writeUnstructuredDomainUgrid(CDomain* domain)", << msg);
[879]949        }
[878]950
[879]951  domain->addRelFile(this->filename);
952  }
[878]953
[879]954    //--------------------------------------------------------------
[878]955
[879]956    void CNc4DataOutput::writeUnstructuredDomain(CDomain* domain)
[449]957      {
958         CContext* context = CContext::getCurrent() ;
959         CContextServer* server=context->server ;
[488]960
[449]961         if (domain->IsWritten(this->filename)) return;
962         domain->checkAttributes();
[488]963
964         if (domain->isEmpty())
[449]965           if (SuperClass::type==MULTI_FILE) return ;
966
967         std::vector<StdString> dim0, dim1;
[772]968         StdString domid = domain->getDomainOutputName();
[705]969         if (isWrittenDomain(domid)) return ;
[774]970         else setWrittenDomain(domid);
[705]971
[449]972         StdString appendDomid  = (singleDomain) ? "" : "_"+domid ;
973
[1430]974         StdString lonName,latName, cellName ;
[1391]975         if (domain->lon_name.isEmpty()) lonName = "lon";
976         else lonName = domain->lon_name;
977
978         if (domain->lat_name.isEmpty()) latName = "lat";
979         else latName = domain->lat_name;
980
[1430]981         if (!domain->dim_i_name.isEmpty()) cellName=domain->dim_i_name;
982         else cellName="cell";
983         StdString dimXid = cellName+appendDomid;
[449]984         StdString dimVertId = StdString("nvertex").append(appendDomid);
[488]985
[449]986         string lonid,latid,bounds_lonid,bounds_latid ;
[611]987         string areaId = "area" + appendDomid;
[449]988
[1158]989         nc_type typePrec ;
990         if (domain->prec.isEmpty()) typePrec =  NC_FLOAT ;
991         else if (domain->prec==4)  typePrec =  NC_FLOAT ;
992         else if (domain->prec==8)   typePrec =  NC_DOUBLE ;
993
[1132]994         int nvertex = (domain->nvertex.isEmpty()) ? 0 : domain->nvertex;
[1025]995
[1132]996         CArray<size_t, 1>& indexToWrite = domain->localIndexToWriteOnServer;
997         int nbWritten = indexToWrite.numElements();
998         CArray<double,1> writtenLat, writtenLon;
999         CArray<double,2> writtenBndsLat, writtenBndsLon;
1000         CArray<double,1> writtenArea;
1001
1002         if (domain->hasLonLat)
1003         {
1004           writtenLat.resize(nbWritten);
1005           writtenLon.resize(nbWritten);
1006           for (int idx = 0; idx < nbWritten; ++idx)
1007           {
[1390]1008             if (idx < domain->latvalue.numElements())
1009             {
1010               writtenLat(idx) = domain->latvalue(indexToWrite(idx));
1011               writtenLon(idx) = domain->lonvalue(indexToWrite(idx));
1012             }
1013             else
1014             {
1015               writtenLat(idx) = 0.;
1016               writtenLon(idx) = 0.;
1017             }
[1132]1018           }
[1390]1019         }
[1132]1020         
[1390]1021         if (domain->hasBounds)
1022         {
1023           int nvertex = domain->nvertex, idx;
1024           writtenBndsLat.resize(nvertex, nbWritten);
1025           writtenBndsLon.resize(nvertex, nbWritten);
1026           CArray<double,2>& boundslat = domain->bounds_latvalue;
1027           CArray<double,2>& boundslon = domain->bounds_lonvalue;
1028           for (idx = 0; idx < nbWritten; ++idx)
1029           {
1030             for (int nv = 0; nv < nvertex; ++nv)
1031             {
1032               if (idx < boundslat.columns())
[1132]1033               {
1034                 writtenBndsLat(nv, idx) = boundslat(nv, int(indexToWrite(idx)));
1035                 writtenBndsLon(nv, idx) = boundslon(nv, int(indexToWrite(idx)));
1036               }
[1390]1037               else
1038               {
1039                 writtenBndsLat(nv, idx) = 0.;
1040                 writtenBndsLon(nv, idx) = 0.;
1041                }
1042             }
[1132]1043           }
1044         }
1045
1046         if (domain->hasArea)
1047         {
1048           writtenArea.resize(nbWritten);           
1049           for (int idx = 0; idx < nbWritten; ++idx)
1050           {
[1390]1051                  if (idx < domain->areavalue.numElements())
1052                writtenArea(idx) = domain->areavalue(indexToWrite(idx));
1053                  else
1054                writtenArea(idx) = 0.;
[1132]1055           }
1056         }
1057
[498]1058         try
[449]1059         {
[498]1060           switch (SuperClass::type)
1061           {
1062              case (MULTI_FILE) :
1063              {
1064                 dim0.push_back(dimXid);
[1132]1065                 SuperClassWriter::addDimension(dimXid, domain->zoom_ni);
[488]1066
[1415]1067                 lonid = lonName+appendDomid;
1068                 latid = latName+appendDomid;
[1430]1069                 if (!domain->bounds_lon_name.isEmpty()) bounds_lonid = domain->bounds_lon_name;
1070                 else bounds_lonid = "bounds_"+lonName+appendDomid;
1071                 if (!domain->bounds_lat_name.isEmpty()) bounds_latid = domain->bounds_lat_name;
1072                 else bounds_latid = "bounds_"+latName+appendDomid;
1073
[665]1074                 if (domain->hasLonLat)
1075                 {
[1158]1076                   SuperClassWriter::addVariable(latid, typePrec, dim0);
1077                   SuperClassWriter::addVariable(lonid, typePrec, dim0);
[665]1078                   this->writeAxisAttributes(lonid, "", "longitude", "Longitude", "degrees_east", domid);
1079                   if (domain->hasBounds) SuperClassWriter::addAttribute("bounds",bounds_lonid, &lonid);
1080                   this->writeAxisAttributes(latid, "", "latitude", "Latitude", "degrees_north", domid);
1081                   if (domain->hasBounds) SuperClassWriter::addAttribute("bounds",bounds_latid, &latid);
1082                   if (domain->hasBounds) SuperClassWriter::addDimension(dimVertId, domain->nvertex);
1083                 }
[498]1084                 dim0.clear();
1085                 if (domain->hasBounds)
1086                 {
1087                   dim0.push_back(dimXid);
1088                   dim0.push_back(dimVertId);
[1158]1089                   SuperClassWriter::addVariable(bounds_lonid, typePrec, dim0);
1090                   SuperClassWriter::addVariable(bounds_latid, typePrec, dim0);
[498]1091                 }
1092
1093                 dim0.clear();
[449]1094                 dim0.push_back(dimXid);
[611]1095                 if (domain->hasArea)
1096                 {
[1158]1097                   SuperClassWriter::addVariable(areaId, typePrec, dim0);
[614]1098                   SuperClassWriter::addAttribute("standard_name", StdString("cell_area"), &areaId);
[611]1099                   SuperClassWriter::addAttribute("units", StdString("m2"), &areaId);
1100                 }
1101
[498]1102                 SuperClassWriter::definition_end();
[449]1103
[665]1104                 if (domain->hasLonLat)
[498]1105                 {
[1132]1106                   SuperClassWriter::writeData(writtenLat, latid, isCollective, 0);
1107                   SuperClassWriter::writeData(writtenLon, lonid, isCollective, 0);
[665]1108                   if (domain->hasBounds)
1109                   {
[1132]1110                     SuperClassWriter::writeData(writtenBndsLon, bounds_lonid, isCollective, 0);
1111                     SuperClassWriter::writeData(writtenBndsLat, bounds_latid, isCollective, 0);
[665]1112                   }
[498]1113                 }
[611]1114
1115                 if (domain->hasArea)
[1132]1116                   SuperClassWriter::writeData(writtenArea, areaId, isCollective, 0);
[611]1117
[498]1118                 SuperClassWriter::definition_start();
1119                 break ;
1120              }
[488]1121
[498]1122              case (ONE_FILE) :
1123              {
[1415]1124                 lonid = lonName+appendDomid;
1125                 latid = latName+appendDomid;
[1430]1126                 if (!domain->bounds_lon_name.isEmpty()) bounds_lonid = domain->bounds_lon_name;
1127                 else bounds_lonid = "bounds_"+lonName+appendDomid;
1128                 if (!domain->bounds_lat_name.isEmpty()) bounds_latid = domain->bounds_lat_name;
1129                 else bounds_latid = "bounds_"+latName+appendDomid;
[1391]1130
[498]1131                 dim0.push_back(dimXid);
[1132]1132                 SuperClassWriter::addDimension(dimXid, domain->ni_glo);
[665]1133                 if (domain->hasLonLat)
1134                 {
[1158]1135                   SuperClassWriter::addVariable(latid, typePrec, dim0);
1136                   SuperClassWriter::addVariable(lonid, typePrec, dim0);
[665]1137
1138                   this->writeAxisAttributes(lonid, "", "longitude", "Longitude", "degrees_east", domid);
1139                   if (domain->hasBounds) SuperClassWriter::addAttribute("bounds",bounds_lonid, &lonid);
1140                   this->writeAxisAttributes(latid, "", "latitude", "Latitude", "degrees_north", domid);
1141                   if (domain->hasBounds) SuperClassWriter::addAttribute("bounds",bounds_latid, &latid);
[1025]1142                   if (domain->hasBounds) SuperClassWriter::addDimension(dimVertId, nvertex);
[665]1143                 }
[498]1144                 dim0.clear();
[449]1145
[498]1146                 if (domain->hasBounds)
1147                 {
1148                   dim0.push_back(dimXid);
1149                   dim0.push_back(dimVertId);
[1158]1150                   SuperClassWriter::addVariable(bounds_lonid, typePrec, dim0);
1151                   SuperClassWriter::addVariable(bounds_latid, typePrec, dim0);
[498]1152                 }
[488]1153
[611]1154                 if (domain->hasArea)
1155                 {
1156                   dim0.clear();
1157                   dim0.push_back(dimXid);
[1158]1158                   SuperClassWriter::addVariable(areaId, typePrec, dim0);
[614]1159                   SuperClassWriter::addAttribute("standard_name", StdString("cell_area"), &areaId);
[611]1160                   SuperClassWriter::addAttribute("units", StdString("m2"), &areaId);
1161                 }
1162
[498]1163                 SuperClassWriter::definition_end();
[488]1164
[498]1165                 std::vector<StdSize> start(1), startBounds(2) ;
1166                 std::vector<StdSize> count(1), countBounds(2) ;
1167                 if (domain->isEmpty())
1168                 {
1169                   start[0]=0 ;
1170                   count[0]=0 ;
1171                   startBounds[1]=0 ;
[1025]1172                   countBounds[1]=nvertex ;
[498]1173                   startBounds[0]=0 ;
1174                   countBounds[0]=0 ;
1175                 }
1176                 else
1177                 {
[1132]1178                   start[0]=domain->zoom_ibegin - domain->global_zoom_ibegin;
1179                   count[0]=domain->zoom_ni;
1180                   startBounds[0]=domain->zoom_ibegin-domain->global_zoom_ibegin;
[498]1181                   startBounds[1]=0 ;
[1132]1182                   countBounds[0]=domain->zoom_ni;
[1025]1183                   countBounds[1]=nvertex ;
[498]1184                 }
[665]1185
1186                 if (domain->hasLonLat)
[498]1187                 {
[1132]1188                   SuperClassWriter::writeData(writtenLat, latid, isCollective, 0,&start,&count);
1189                   SuperClassWriter::writeData(writtenLon, lonid, isCollective, 0,&start,&count);
[665]1190                   if (domain->hasBounds)
1191                   {
[1132]1192                     SuperClassWriter::writeData(writtenBndsLon, bounds_lonid, isCollective, 0,&startBounds,&countBounds);
1193                     SuperClassWriter::writeData(writtenBndsLat, bounds_latid, isCollective, 0,&startBounds,&countBounds);
[665]1194                   }
[498]1195                 }
[488]1196
[611]1197                 if (domain->hasArea)
[1132]1198                   SuperClassWriter::writeData(writtenArea, areaId, isCollective, 0, &start, &count);
[488]1199
[498]1200                 SuperClassWriter::definition_start();
[488]1201
[498]1202                 break;
1203              }
1204              default :
1205                 ERROR("CNc4DataOutput::writeDomain(domain)",
1206                       << "[ type = " << SuperClass::type << "]"
1207                       << " not implemented yet !");
1208           }
[219]1209         }
[498]1210         catch (CNetCdfException& e)
1211         {
1212           StdString msg("On writing the domain : ");
1213           msg.append(domid); msg.append("\n");
1214           msg.append("In the context : ");
1215           msg.append(context->getId()); msg.append("\n");
1216           msg.append(e.what());
1217           ERROR("CNc4DataOutput::writeUnstructuredDomain(CDomain* domain)", << msg);
1218         }
[219]1219         domain->addRelFile(this->filename);
1220      }
1221      //--------------------------------------------------------------
1222
[347]1223      void CNc4DataOutput::writeAxis_(CAxis* axis)
[219]1224      {
[1030]1225        if (axis->IsWritten(this->filename)) return;
1226        axis->checkAttributes();
[488]1227
[1129]1228        axis->computeWrittenIndex();
[1249]1229        axis->computeWrittenCompressedIndex(comm_file);
[1129]1230       
[1099]1231        int zoom_size  = (MULTI_FILE == SuperClass::type) ? axis->zoom_n
1232                                                          : axis->global_zoom_n;
1233
[1235]1234        int zoom_count = axis->zoom_n;                                                 
1235        int zoom_begin = axis->zoom_begin;
1236        // int zoom_begin = (MULTI_FILE == SuperClass::type) ? axis->global_zoom_begin
1237        //                                                   : axis->zoom_begin;
1238
[1099]1239        if ((0 == axis->zoom_n) && (MULTI_FILE == SuperClass::type)) return;
1240
[1030]1241        std::vector<StdString> dims;
1242        StdString axisid = axis->getAxisOutputName();
[1435]1243        StdString axisDim, axisBoundsId;
[1030]1244        if (isWrittenAxis(axisid)) return ;
1245        else setWrittenAxis(axisid);
[705]1246
[1158]1247        nc_type typePrec ;
1248        if (axis->prec.isEmpty()) typePrec =  NC_FLOAT ;
[1235]1249        else if (axis->prec==4)   typePrec =  NC_FLOAT ;
[1158]1250        else if (axis->prec==8)   typePrec =  NC_DOUBLE ;
1251         
1252        if (!axis->label.isEmpty()) typePrec = NC_CHAR ;
1253        string strId="str_len" ;
[1030]1254        try
1255        {
[1433]1256          if (axis->dim_name.isEmpty()) axisDim = axisid;
1257          else axisDim=axis->dim_name.getValue();
1258          SuperClassWriter::addDimension(axisDim, zoom_size);
1259          dims.push_back(axisDim);
1260
[1158]1261          if (!axis->label.isEmpty()) SuperClassWriter::addDimension(strId, stringArrayLen);
[1433]1262
[1435]1263          if (axis->hasValue || !axis->label.isEmpty())
[816]1264          {
[1158]1265            if (!axis->label.isEmpty()) dims.push_back(strId);
[1430]1266
[1158]1267            SuperClassWriter::addVariable(axisid, typePrec, dims);
[219]1268
[1030]1269            if (!axis->name.isEmpty())
1270              SuperClassWriter::addAttribute("name", axis->name.getValue(), &axisid);
[219]1271
[1030]1272            if (!axis->standard_name.isEmpty())
1273              SuperClassWriter::addAttribute("standard_name", axis->standard_name.getValue(), &axisid);
[540]1274
[1030]1275            if (!axis->long_name.isEmpty())
1276              SuperClassWriter::addAttribute("long_name", axis->long_name.getValue(), &axisid);
[219]1277
[1030]1278            if (!axis->unit.isEmpty())
1279              SuperClassWriter::addAttribute("units", axis->unit.getValue(), &axisid);
[219]1280
[1430]1281            if (!axis->axis_type.isEmpty())
1282            {
1283              switch(axis->axis_type)
1284              {
1285              case CAxis::axis_type_attr::X :
1286                SuperClassWriter::addAttribute("axis", string("X"), &axisid);
1287                break;
1288              case CAxis::axis_type_attr::Y :
1289                SuperClassWriter::addAttribute("axis", string("Y"), &axisid);
1290                break;
1291              case CAxis::axis_type_attr::Z :
1292                SuperClassWriter::addAttribute("axis", string("Z"), &axisid);
1293                break;
1294              case CAxis::axis_type_attr::T :
1295                SuperClassWriter::addAttribute("axis", string("T"), &axisid);
1296                break;
1297              }
1298            }
1299
[1030]1300            if (!axis->positive.isEmpty())
1301            {
1302              SuperClassWriter::addAttribute("positive",
1303                                             (axis->positive == CAxis::positive_attr::up) ? string("up") : string("down"),
1304                                             &axisid);
1305            }
[399]1306
[1266]1307            if (!axis->formula.isEmpty())
1308              SuperClassWriter::addAttribute("formula", axis->formula.getValue(), &axisid);
1309
1310            if (!axis->formula_term.isEmpty())
1311              SuperClassWriter::addAttribute("formula_term", axis->formula_term.getValue(), &axisid);
1312             
[1435]1313            axisBoundsId = (axis->bounds_name.isEmpty()) ? axisid + "_bounds" : axis->bounds_name;
[1249]1314            if (!axis->bounds.isEmpty() && axis->label.isEmpty())
[1030]1315            {
1316              dims.push_back("axis_nbounds");
[1158]1317              SuperClassWriter::addVariable(axisBoundsId, typePrec, dims);
[1030]1318              SuperClassWriter::addAttribute("bounds", axisBoundsId, &axisid);
[1288]1319
1320              if (!axis->standard_name.isEmpty())
1321                SuperClassWriter::addAttribute("standard_name", axis->standard_name.getValue(), &axisBoundsId);
1322
1323              if (!axis->unit.isEmpty())
1324                SuperClassWriter::addAttribute("units", axis->unit.getValue(), &axisBoundsId);
1325
[1266]1326              if (!axis->formula_bounds.isEmpty())
[1288]1327                SuperClassWriter::addAttribute("formula", axis->formula_bounds.getValue(), &axisBoundsId);
[1266]1328
1329              if (!axis->formula_term_bounds.isEmpty())
[1288]1330                SuperClassWriter::addAttribute("formula_term", axis->formula_term_bounds.getValue(), &axisBoundsId);
[1030]1331            }
[1435]1332          }
[816]1333
[1435]1334          SuperClassWriter::definition_end();
1335
1336          CArray<size_t, 1>& indexToWrite = axis->localIndexToWriteOnServer;
1337          int nbWritten = indexToWrite.numElements();
1338          CArray<double,1> axis_value(indexToWrite.numElements());
1339          if (!axis->value.isEmpty())
1340          {
[1421]1341            for (int i = 0; i < nbWritten; i++)
1342            {
1343              if (i < axis->value.numElements())
1344                axis_value(i) = axis->value(indexToWrite(i));
1345              else
1346                axis_value(i) = 0.;
1347            }
[1435]1348          }
1349          CArray<double,2> axis_bounds;
1350          CArray<string,1> axis_label;
1351          if (!axis->label.isEmpty())
1352          {
1353            axis_label.resize(indexToWrite.numElements());
1354            for (int i = 0; i < nbWritten; i++)
[1235]1355            {
[1435]1356              if (i < axis->label.numElements())
1357                axis_label(i) = axis->label(indexToWrite(i));
1358              else
1359                axis_label(i) = boost::lexical_cast<string>(0);  // Write 0 as a label
[1235]1360            }
[1435]1361          }
[1129]1362
[1435]1363          switch (SuperClass::type)
1364          {
1365            case MULTI_FILE:
[1030]1366            {
[1435]1367              if (axis->label.isEmpty())
1368                SuperClassWriter::writeData(axis_value, axisid, isCollective, 0);
[633]1369
[1435]1370              if (!axis->bounds.isEmpty() && axis->label.isEmpty())
[1030]1371              {
[1129]1372                  axis_bounds.resize(2, indexToWrite.numElements());
1373                  for (int i = 0; i < nbWritten; ++i)
1374                  {
[1421]1375                    if (i < axis->bounds.columns())
1376                    {
1377                      axis_bounds(0, i) = axis->bounds(0, int(indexToWrite(i)));
1378                      axis_bounds(1, i) = axis->bounds(1, int(indexToWrite(i)));
1379                    }
1380                    else
1381                    {
1382                      axis_bounds(0, i) = 0.;
1383                      axis_bounds(1, i) = 0.;
[1435]1384
[1421]1385                    }
[1129]1386                  }
[609]1387
[1435]1388                SuperClassWriter::writeData(axis_bounds, axisBoundsId, isCollective, 0);
1389              }
1390
1391              // Need to check after
1392              if (!axis->label.isEmpty())
1393                SuperClassWriter::writeData(axis_label, axisid, isCollective, 0);
1394
1395              SuperClassWriter::definition_start();
1396              break;
1397            }
1398            case ONE_FILE:
1399            {
1400              std::vector<StdSize> start(1), startBounds(2) ;
1401              std::vector<StdSize> count(1), countBounds(2) ;
1402              start[0] = startBounds[0] = zoom_begin - axis->global_zoom_begin;
1403              count[0] = countBounds[0] = zoom_count; // zoom_size
1404              startBounds[1] = 0;
1405              countBounds[1] = 2;
1406
1407              if (axis->label.isEmpty())
1408                SuperClassWriter::writeData(axis_value, axisid, isCollective, 0, &start, &count);
1409
1410              if (!axis->bounds.isEmpty() && axis->label.isEmpty())
1411              {
1412                axis_bounds.resize(2, indexToWrite.numElements());
1413                for (int i = 0; i < nbWritten; ++i)
[1235]1414                {
[1435]1415                  if (i < axis->bounds.columns())
1416                  {
1417                    axis_bounds(0, i) = axis->bounds(0, int(indexToWrite(i)));
1418                    axis_bounds(1, i) = axis->bounds(1, int(indexToWrite(i)));
1419                  }
1420                  else
1421                  {
1422                    axis_bounds(0, i) = 0.;
1423                    axis_bounds(1, i) = 0.;
1424                  }
[1235]1425                }
[1435]1426                SuperClassWriter::writeData(axis_bounds, axisBoundsId, isCollective, 0, &startBounds, &countBounds);
1427              }
[1158]1428
[1435]1429              // Need to check after
1430              if (!axis->label.isEmpty())
1431              {
1432                std::vector<StdSize> startLabel(2), countLabel(2);
1433                startLabel[0] = start[0]; startLabel[1] = 0;
1434                countLabel[0] = count[0]; countLabel[1] = stringArrayLen;
1435                SuperClassWriter::writeData(axis_label, axisid, isCollective, 0, &startLabel, &countLabel);
1436              }
[609]1437
[1435]1438              SuperClassWriter::definition_start();
1439
1440              break;
[609]1441            }
[1435]1442            default :
1443              ERROR("CNc4DataOutput::writeAxis_(CAxis* axis)",
1444                    << "[ type = " << SuperClass::type << "]"
1445                    << " not implemented yet !");
[609]1446          }
[1030]1447        }
1448        catch (CNetCdfException& e)
1449        {
1450          StdString msg("On writing the axis : ");
1451          msg.append(axisid); msg.append("\n");
1452          msg.append("In the context : ");
1453          CContext* context = CContext::getCurrent() ;
1454          msg.append(context->getId()); msg.append("\n");
1455          msg.append(e.what());
1456          ERROR("CNc4DataOutput::writeAxis_(CAxis* axis)", << msg);
1457        }
[1158]1458        axis->addRelFile(this->filename);
[391]1459     }
[488]1460
[887]1461      void CNc4DataOutput::writeScalar_(CScalar* scalar)
1462      {
1463        if (scalar->IsWritten(this->filename)) return;
1464        scalar->checkAttributes();
1465        int scalarSize = 1;
1466
1467        StdString scalaId = scalar->getScalarOutputName();
[1430]1468        StdString boundsId;
[887]1469        if (isWrittenAxis(scalaId)) return ;
1470        else setWrittenAxis(scalaId);
1471
[1158]1472        nc_type typePrec ;
1473        if (scalar->prec.isEmpty()) typePrec =  NC_FLOAT ;
1474        else if (scalar->prec==4)  typePrec =  NC_FLOAT ;
1475        else if (scalar->prec==8)   typePrec =  NC_DOUBLE ;
1476
[1435]1477        if (!scalar->label.isEmpty()) typePrec = NC_CHAR ;
1478        string strId="str_len" ;
1479
[887]1480        try
1481        {
[1435]1482          if (!scalar->label.isEmpty()) SuperClassWriter::addDimension(strId, stringArrayLen);
1483
1484          if (!scalar->value.isEmpty() || !scalar->label.isEmpty())
[887]1485          {
[1430]1486            std::vector<StdString> dims;
1487            StdString scalarDim = scalaId;
1488
[1435]1489            if (!scalar->label.isEmpty()) dims.push_back(strId);
1490
[1158]1491            SuperClassWriter::addVariable(scalaId, typePrec, dims);
[887]1492
1493            if (!scalar->name.isEmpty())
1494              SuperClassWriter::addAttribute("name", scalar->name.getValue(), &scalaId);
1495
1496            if (!scalar->standard_name.isEmpty())
1497              SuperClassWriter::addAttribute("standard_name", scalar->standard_name.getValue(), &scalaId);
1498
1499            if (!scalar->long_name.isEmpty())
1500              SuperClassWriter::addAttribute("long_name", scalar->long_name.getValue(), &scalaId);
1501
1502            if (!scalar->unit.isEmpty())
1503              SuperClassWriter::addAttribute("units", scalar->unit.getValue(), &scalaId);
1504
[1430]1505            if (!scalar->axis_type.isEmpty())
1506            {
1507              switch(scalar->axis_type)
1508              {
1509              case CScalar::axis_type_attr::X :
1510                SuperClassWriter::addAttribute("axis", string("X"), &scalaId);
1511                break;
1512              case CScalar::axis_type_attr::Y :
1513                SuperClassWriter::addAttribute("axis", string("Y"), &scalaId);
1514                break;
1515              case CScalar::axis_type_attr::Z :
1516                SuperClassWriter::addAttribute("axis", string("Z"), &scalaId);
1517                break;
1518              case CScalar::axis_type_attr::T :
1519                SuperClassWriter::addAttribute("axis", string("T"), &scalaId);
1520                break;
1521              }
1522            }
1523
[1435]1524            if (!scalar->positive.isEmpty())
[1430]1525            {
[1435]1526              SuperClassWriter::addAttribute("positive",
1527                                             (scalar->positive == CScalar::positive_attr::up) ? string("up") : string("down"),
1528                                             &scalaId);
1529            }
1530
1531            if (!scalar->bounds.isEmpty() && scalar->label.isEmpty())
1532            {
1533              boundsId = (scalar->bounds_name.isEmpty()) ? (scalaId + "_bounds") : scalar->bounds_name.getValue();
1534              SuperClassWriter::addAttribute("bounds_name", boundsId, &scalaId);
[1430]1535              SuperClassWriter::addDimension(boundsId, 1);
1536              SuperClassWriter::addVariable(boundsId, typePrec, dims);
1537            }
1538
[887]1539            SuperClassWriter::definition_end();
1540
1541            switch (SuperClass::type)
1542            {
1543              case MULTI_FILE:
1544              {
1545                CArray<double,1> scalarValue(scalarSize);
[1435]1546                CArray<string,1> scalarLabel(scalarSize);
1547
1548                if (!scalar->value.isEmpty() && scalar->label.isEmpty())
[1430]1549                {
[1435]1550                  scalarValue(0) = scalar->value;
1551                  SuperClassWriter::writeData(scalarValue, scalaId, isCollective, 0);
1552                }
1553
1554                if (!scalar->bounds.isEmpty() && scalar->label.isEmpty())
1555                {
1556                  scalarValue(0) = scalar->bounds;
[1430]1557                  SuperClassWriter::writeData(scalarValue, boundsId, isCollective, 0);
1558                }
[1435]1559
1560                if (!scalar->label.isEmpty())
1561                {
1562                  scalarLabel(0) = scalar->label;
1563                  SuperClassWriter::writeData(scalarLabel, scalaId, isCollective, 0);
1564                }
1565
[887]1566                SuperClassWriter::definition_start();
1567
1568                break;
1569              }
1570              case ONE_FILE:
1571              {
1572                CArray<double,1> scalarValue(scalarSize);
[1435]1573                CArray<string,1> scalarLabel(scalarSize);
[887]1574
1575                std::vector<StdSize> start(1);
1576                std::vector<StdSize> count(1);
1577                start[0] = 0;
1578                count[0] = 1;
[1435]1579                if (!scalar->value.isEmpty() && scalar->label.isEmpty())
[1430]1580                {
[1435]1581                  scalarValue(0) = scalar->value;
1582                  SuperClassWriter::writeData(scalarValue, scalaId, isCollective, 0, &start, &count);
1583                }
1584                if (!scalar->bounds.isEmpty() && scalar->label.isEmpty())
1585                {
1586                  scalarValue(0) = scalar->bounds;
[1430]1587                  SuperClassWriter::writeData(scalarValue, boundsId, isCollective, 0, &start, &count);
1588                }
[1435]1589                if (!scalar->label.isEmpty())
1590                {
1591                  scalarLabel(0) = scalar->label;
1592                  count[0] = stringArrayLen;
1593                  SuperClassWriter::writeData(scalarLabel, scalaId, isCollective, 0, &start, &count);
1594                }
1595
[887]1596                SuperClassWriter::definition_start();
1597
1598                break;
1599              }
1600              default :
1601                ERROR("CNc4DataOutput::writeAxis_(CAxis* scalar)",
1602                      << "[ type = " << SuperClass::type << "]"
1603                      << " not implemented yet !");
1604            }
1605          }
1606        }
1607        catch (CNetCdfException& e)
1608        {
1609          StdString msg("On writing the scalar : ");
1610          msg.append(scalaId); msg.append("\n");
1611          msg.append("In the context : ");
1612          CContext* context = CContext::getCurrent() ;
1613          msg.append(context->getId()); msg.append("\n");
1614          msg.append(e.what());
1615          ERROR("CNc4DataOutput::writeScalar_(CScalar* scalar)", << msg);
1616        }
1617        scalar->addRelFile(this->filename);
1618     }
1619
[676]1620     //--------------------------------------------------------------
1621
1622     void CNc4DataOutput::writeGridCompressed_(CGrid* grid)
1623     {
1624       if (grid->isScalarGrid() || grid->isWrittenCompressed(this->filename)) return;
1625
1626       try
1627       {
[887]1628         CArray<int,1> axisDomainOrder = grid->axis_domain_order;
[676]1629         std::vector<StdString> domainList = grid->getDomainList();
1630         std::vector<StdString> axisList   = grid->getAxisList();
[887]1631         std::vector<StdString> scalarList = grid->getScalarList();
1632         int numElement = axisDomainOrder.numElements(), idxDomain = 0, idxAxis = 0, idxScalar = 0;
[676]1633
1634         std::vector<StdString> dims;
1635
1636         if (grid->isCompressible())
1637         {
1638           StdString varId = grid->getId() + "_points";
1639
1640           int nbIndexes = (SuperClass::type == MULTI_FILE) ? grid->getNumberWrittenIndexes() : grid->getTotalNumberWrittenIndexes();
1641           SuperClassWriter::addDimension(varId, nbIndexes);
1642
1643           dims.push_back(varId);
1644           SuperClassWriter::addVariable(varId, NC_INT, dims);
1645
1646           StdOStringStream compress;
1647           for (int i = numElement - 1; i >= 0; --i)
1648           {
[887]1649             if (2 == axisDomainOrder(i))
[676]1650             {
1651               CDomain* domain = CDomain::get(domainList[domainList.size() - idxDomain - 1]);
[772]1652               StdString domId = domain->getDomainOutputName();
[676]1653               StdString appendDomId  = singleDomain ? "" : "_" + domId;
1654
1655               switch (domain->type)
1656               {
1657                 case CDomain::type_attr::curvilinear:
1658                   compress << "y" << appendDomId << " x" << appendDomId;
1659                   break;
1660                 case CDomain::type_attr::rectilinear:
1661                   compress << "lat" << appendDomId << " lon" << appendDomId;
1662                   break;
1663                 case CDomain::type_attr::unstructured:
[1430]1664                   StdString cellName = (!domain->dim_i_name.isEmpty()) ? cellName=domain->dim_i_name : "cell";
1665                   compress << cellName << appendDomId;
1666//                   compress << "cell" << appendDomId;
[676]1667                   break;
1668               }
1669               ++idxDomain;
1670             }
[887]1671             else if (1 == axisDomainOrder(i))
[676]1672             {
1673               CAxis* axis = CAxis::get(axisList[axisList.size() - idxAxis - 1]);
[772]1674               compress << axis->getAxisOutputName();
[676]1675               ++idxAxis;
1676             }
[887]1677             else
1678             {
1679               CScalar* scalar = CScalar::get(scalarList[scalarList.size() - idxScalar - 1]);
1680               compress << scalar->getScalarOutputName();
1681               ++idxScalar;
1682             }
[676]1683
1684             if (i != 0) compress << ' ';
1685           }
[1144]1686           SuperClassWriter::addAttribute("compress", compress.str(), &varId);         
[676]1687
1688           CArray<int, 1> indexes(grid->getNumberWrittenIndexes());
[1143]1689           indexes = grid->localIndexToWriteOnServer;
[676]1690
1691           switch (SuperClass::type)
1692           {
1693             case (MULTI_FILE):
1694             {
1695               SuperClassWriter::writeData(indexes, varId, isCollective, 0);
1696               break;
1697             }
1698             case (ONE_FILE):
1699             {
1700               if (grid->doGridHaveDataDistributed())
1701                 grid->getDistributionServer()->computeGlobalIndex(indexes);
1702
1703               std::vector<StdSize> start, count;
1704               start.push_back(grid->getOffsetWrittenIndexes());
1705               count.push_back(grid->getNumberWrittenIndexes());
1706
1707               SuperClassWriter::writeData(indexes, varId, isCollective, 0, &start, &count);
1708               break;
1709             }
1710           }
1711         }
1712         else
1713         {
1714           for (int i = 0; i < numElement; ++i)
1715           {
1716             StdString varId, compress;
1717             CArray<int, 1> indexes;
1718             bool isDistributed;
1719             StdSize nbIndexes, totalNbIndexes, offset;
1720             int firstGlobalIndex;
1721
[887]1722             if (2 == axisDomainOrder(i))
[676]1723             {
1724               CDomain* domain = CDomain::get(domainList[idxDomain]);
[774]1725               StdString domId = domain->getDomainOutputName();
1726
[676]1727               if (!domain->isCompressible()
1728                    || domain->type == CDomain::type_attr::unstructured
[774]1729                    || domain->isWrittenCompressed(this->filename)
1730                    || isWrittenCompressedDomain(domId))
[676]1731                 continue;
1732
1733               StdString appendDomId  = singleDomain ? "" : "_" + domId;
1734
1735               varId = domId + "_points";
1736               switch (domain->type)
1737               {
1738                 case CDomain::type_attr::curvilinear:
1739                   compress = "y" + appendDomId + " x" + appendDomId;
1740                   break;
1741                 case CDomain::type_attr::rectilinear:
1742                   compress = "lat" + appendDomId + " lon" + appendDomId;
1743                   break;
1744               }
1745
[1249]1746               // indexes.resize(domain->compressedIndexToWriteOnServer[comm_file].numElements());
1747               // indexes = domain->compressedIndexToWriteOnServer[com_file];
1748               indexes.resize(domain->getCompressedIndexToWriteOnServer(comm_file).numElements());
1749               indexes = domain->getCompressedIndexToWriteOnServer(comm_file);
[1143]1750
[676]1751               isDistributed = domain->isDistributed();
[1249]1752               nbIndexes = domain->getNumberWrittenIndexes(comm_file);
1753               totalNbIndexes = domain->getTotalNumberWrittenIndexes(comm_file);
1754               offset = domain->getOffsetWrittenIndexes(comm_file);
[676]1755               firstGlobalIndex = domain->ibegin + domain->jbegin * domain->ni_glo;
1756
1757               domain->addRelFileCompressed(this->filename);
[774]1758               setWrittenCompressedDomain(domId);
[676]1759               ++idxDomain;
1760             }
[887]1761             else if (1 == axisDomainOrder(i))
[676]1762             {
1763               CAxis* axis = CAxis::get(axisList[idxAxis]);
[774]1764               StdString axisId = axis->getAxisOutputName();
1765
1766               if (!axis->isCompressible()
1767                    || axis->isWrittenCompressed(this->filename)
1768                    || isWrittenCompressedAxis(axisId))
[676]1769                 continue;
1770
1771               varId = axisId + "_points";
1772               compress = axisId;
1773
[1249]1774               // indexes.resize(axis->compressedIndexToWriteOnServer.numElements());
1775               // indexes = axis->compressedIndexToWriteOnServer;
[1143]1776
[1249]1777               indexes.resize(axis->getCompressedIndexToWriteOnServer(comm_file).numElements());
1778               indexes = axis->getCompressedIndexToWriteOnServer(comm_file);
1779
[676]1780               isDistributed = axis->isDistributed();
[1249]1781               nbIndexes = axis->getNumberWrittenIndexes(comm_file);
1782               totalNbIndexes = axis->getTotalNumberWrittenIndexes(comm_file);
1783               offset = axis->getOffsetWrittenIndexes(comm_file);
[676]1784               firstGlobalIndex = axis->begin;
1785
1786               axis->addRelFileCompressed(this->filename);
[774]1787               setWrittenCompressedAxis(axisId);
[676]1788               ++idxAxis;
1789             }
[887]1790             else
1791             {
1792             }
[676]1793
1794             if (!varId.empty())
1795             {
1796               SuperClassWriter::addDimension(varId, (SuperClass::type == MULTI_FILE) ? nbIndexes : totalNbIndexes);
1797
1798               dims.clear();
1799               dims.push_back(varId);
1800               SuperClassWriter::addVariable(varId, NC_INT, dims);
1801
1802               SuperClassWriter::addAttribute("compress", compress, &varId);
1803
1804               switch (SuperClass::type)
1805               {
1806                 case (MULTI_FILE):
1807                 {
1808                   indexes -= firstGlobalIndex;
1809                   SuperClassWriter::writeData(indexes, varId, isCollective, 0);
1810                   break;
1811                 }
1812                 case (ONE_FILE):
1813                 {
1814                   std::vector<StdSize> start, count;
1815                   start.push_back(offset);
1816                   count.push_back(nbIndexes);
1817
1818                   SuperClassWriter::writeData(indexes, varId, isCollective, 0, &start, &count);
1819                   break;
1820                 }
1821               }
1822             }
[1144]1823            }
[676]1824         }
1825
1826         grid->addRelFileCompressed(this->filename);
1827       }
1828       catch (CNetCdfException& e)
1829       {
1830         StdString msg("On writing compressed grid : ");
1831         msg.append(grid->getId()); msg.append("\n");
1832         msg.append("In the context : ");
1833         CContext* context = CContext::getCurrent();
1834         msg.append(context->getId()); msg.append("\n");
1835         msg.append(e.what());
1836         ERROR("CNc4DataOutput::writeGridCompressed_(CGrid* grid)", << msg);
1837       }
1838     }
1839
1840     //--------------------------------------------------------------
1841
[391]1842     void CNc4DataOutput::writeTimeDimension_(void)
1843     {
[498]1844       try
1845       {
[802]1846        SuperClassWriter::addDimension(getTimeCounterName());
[498]1847       }
1848       catch (CNetCdfException& e)
1849       {
[614]1850         StdString msg("On writing time dimension : time_couter\n");
[498]1851         msg.append("In the context : ");
1852         CContext* context = CContext::getCurrent() ;
1853         msg.append(context->getId()); msg.append("\n");
1854         msg.append(e.what());
1855         ERROR("CNc4DataOutput::writeTimeDimension_(void)", << msg);
1856       }
[391]1857     }
[676]1858
[219]1859      //--------------------------------------------------------------
1860
[347]1861      void CNc4DataOutput::writeField_(CField* field)
[219]1862      {
[1158]1863        CContext* context = CContext::getCurrent() ;
1864        CContextServer* server=context->server ;
[300]1865
[1158]1866        std::vector<StdString> dims, coodinates;
1867        CGrid* grid = field->grid;
1868        if (!grid->doGridHaveDataToWrite())
[567]1869          if (SuperClass::type==MULTI_FILE) return ;
[488]1870
[1158]1871        CArray<int,1> axisDomainOrder = grid->axis_domain_order;
1872        int numElement = axisDomainOrder.numElements(), idxDomain = 0, idxAxis = 0, idxScalar = 0;
1873        std::vector<StdString> domainList = grid->getDomainList();
1874        std::vector<StdString> axisList   = grid->getAxisList();
1875        std::vector<StdString> scalarList = grid->getScalarList();       
[219]1876
[1158]1877        StdString timeid  = getTimeCounterName();
1878        StdString dimXid,dimYid;
1879        std::deque<StdString> dimIdList, dimCoordList;
1880        bool hasArea = false;
1881        StdString cellMeasures = "area:";
1882        bool compressedOutput = !field->indexed_output.isEmpty() && field->indexed_output;
[488]1883
[1158]1884        for (int i = 0; i < numElement; ++i)
1885        {
1886          if (2 == axisDomainOrder(i))
1887          {
1888            CDomain* domain = CDomain::get(domainList[idxDomain]);
1889            StdString domId = domain->getDomainOutputName();
1890            StdString appendDomId  = singleDomain ? "" : "_" + domId ;
[1391]1891            StdString lonName,latName ;
[1430]1892            StdString dimIname,dimJname ;
[676]1893
[1415]1894            if (domain->lon_name.isEmpty())
1895            { 
1896              if (domain->type==CDomain::type_attr::curvilinear) lonName = "nav_lon";
1897              else lonName = "lon";
1898            }
[1391]1899            else lonName = domain->lon_name;
1900
[1415]1901            if (domain->lat_name.isEmpty())
1902            {
1903              if (domain->type==CDomain::type_attr::curvilinear) latName = "nav_lat";
1904              else latName = "lat";
1905            }
[1391]1906            else latName = domain->lat_name;
[1430]1907
1908            if (domain->dim_i_name.isEmpty())
1909            {
1910              if (domain->type==CDomain::type_attr::curvilinear) dimIname = "x";
1911              else if (domain->type==CDomain::type_attr::unstructured) dimIname = "cell";
1912              else dimIname = lonName;
1913            }
1914            else dimIname = domain->dim_i_name;
1915
1916            if (domain->dim_j_name.isEmpty())
1917            {
1918              if (domain->type==CDomain::type_attr::curvilinear) dimJname = "y";
1919              else dimJname = latName;
1920            }
1921            else dimJname = domain->dim_j_name;
[1391]1922       
[1158]1923            if (compressedOutput && domain->isCompressible() && domain->type != CDomain::type_attr::unstructured)
1924            {
1925              dimIdList.push_back(domId + "_points");
1926              field->setUseCompressedOutput();
1927            }
[676]1928
[1158]1929            switch (domain->type)
[879]1930            {
[1158]1931              case CDomain::type_attr::curvilinear:
1932                if (!compressedOutput || !domain->isCompressible())
1933                {
[1430]1934                  dimXid=dimIname+appendDomId;
1935                  dimYid=dimJname+appendDomId;
[1158]1936                  dimIdList.push_back(dimXid);
1937                  dimIdList.push_back(dimYid);
1938                }
[1415]1939                dimCoordList.push_back(lonName+appendDomId);
1940                dimCoordList.push_back(latName+appendDomId);
[1158]1941              break ;
1942              case CDomain::type_attr::rectilinear:
1943                if (!compressedOutput || !domain->isCompressible())
1944                {
[1430]1945                  dimXid     = dimIname+appendDomId;
1946                  dimYid     = dimJname+appendDomId;
[1158]1947                  dimIdList.push_back(dimXid);
1948                  dimIdList.push_back(dimYid);
1949                }
[1430]1950                if (lonName != dimIname)  dimCoordList.push_back(lonName+appendDomId);
1951                if (latName != dimJname)  dimCoordList.push_back(latName+appendDomId);
1952
[1158]1953              break ;
1954              case CDomain::type_attr::unstructured:
1955              {
1956                if (SuperClassWriter::useCFConvention)
1957                {
[1430]1958                  dimXid     = dimIname + appendDomId;
[1158]1959                  dimIdList.push_back(dimXid);
[1415]1960                  dimCoordList.push_back(lonName+appendDomId);
1961                  dimCoordList.push_back(latName+appendDomId);
[1158]1962                }
1963                else
1964                {
1965                  StdString domainName = domain->name;
1966                  if (domain->nvertex == 1)
1967                  {
1968                    dimXid     = "n" + domainName + "_node";
1969                    dimIdList.push_back(dimXid);
1970                    dimCoordList.push_back(StdString(domainName + "_node_x"));
1971                    dimCoordList.push_back(StdString(domainName + "_node_y"));
1972                  }
1973                  else if (domain->nvertex == 2)
1974                  {
1975                    dimXid     = "n" + domainName + "_edge";
1976                    dimIdList.push_back(dimXid);
1977                    dimCoordList.push_back(StdString(domainName + "_edge_x"));
1978                    dimCoordList.push_back(StdString(domainName + "_edge_y"));
1979                  }
1980                  else
1981                  {
1982                    dimXid     = "n" + domainName + "_face";
1983                    dimIdList.push_back(dimXid);
1984                    dimCoordList.push_back(StdString(domainName + "_face_x"));
1985                    dimCoordList.push_back(StdString(domainName + "_face_y"));
1986                  }
1987                }  // ugrid convention
1988              }  // case unstructured domain
[879]1989            }
[1158]1990
1991            if (domain->hasArea)
[879]1992            {
[1158]1993              hasArea = true;
1994              cellMeasures += " area" + appendDomId;
[879]1995            }
[1158]1996            ++idxDomain;
1997          }
1998          else if (1 == axisDomainOrder(i))
1999          {
2000            CAxis* axis = CAxis::get(axisList[idxAxis]);
2001            StdString axisId = axis->getAxisOutputName();
[1430]2002            StdString axisDim;
[1158]2003
[1430]2004            if (axis->dim_name.isEmpty()) axisDim = axisId;
2005            else axisDim=axis->dim_name.getValue();
2006
[1158]2007            if (compressedOutput && axis->isCompressible())
[879]2008            {
[1430]2009              dimIdList.push_back(axisDim + "_points");
[1158]2010              field->setUseCompressedOutput();
[879]2011            }
[1158]2012            else
[1430]2013              dimIdList.push_back(axisDim);
[878]2014
[1430]2015            if (axisDim != axisId) dimCoordList.push_back(axisId);
[1158]2016            ++idxAxis;
2017          }
[1430]2018          else
[1158]2019          {
[1430]2020            CScalar* scalar = CScalar::get(scalarList[idxScalar]);
2021            StdString scalarId = scalar->getScalarOutputName();
2022            dimCoordList.push_back(scalarId);
2023            ++idxScalar;
[1158]2024          }
2025        }
[488]2026
[1158]2027        StdString fieldid = field->getFieldOutputName();
[219]2028
[1158]2029        nc_type type ;
2030        if (field->prec.isEmpty()) type =  NC_FLOAT ;
2031        else
2032        {
2033          if (field->prec==2) type = NC_SHORT ;
2034          else if (field->prec==4)  type =  NC_FLOAT ;
2035          else if (field->prec==8)   type =  NC_DOUBLE ;
2036        }
[488]2037
[1158]2038        bool wtime   = !(!field->operation.isEmpty() && field->getOperationTimeType() == func::CFunctor::once);
[488]2039
[1158]2040        if (wtime)
2041        {
2042          if (field->hasTimeInstant && hasTimeInstant) coodinates.push_back(string("time_instant"));
2043          else if (field->hasTimeCentered && hasTimeCentered)  coodinates.push_back(string("time_centered"));
2044          dims.push_back(timeid);
2045        }
[488]2046
[1158]2047        if (compressedOutput && grid->isCompressible())
2048        {
2049          dims.push_back(grid->getId() + "_points");
2050          field->setUseCompressedOutput();
2051        }
2052        else
2053        {
2054          while (!dimIdList.empty())
2055          {
2056            dims.push_back(dimIdList.back());
2057            dimIdList.pop_back();
2058          }
2059        }
[219]2060
[1158]2061        while (!dimCoordList.empty())
2062        {
2063          coodinates.push_back(dimCoordList.back());
2064          dimCoordList.pop_back();
2065        }
[219]2066
[1158]2067        try
2068        {
[498]2069           SuperClassWriter::addVariable(fieldid, type, dims);
[488]2070
[498]2071           if (!field->standard_name.isEmpty())
2072              SuperClassWriter::addAttribute
2073                 ("standard_name",  field->standard_name.getValue(), &fieldid);
[219]2074
[498]2075           if (!field->long_name.isEmpty())
2076              SuperClassWriter::addAttribute
2077                 ("long_name", field->long_name.getValue(), &fieldid);
[219]2078
[498]2079           if (!field->unit.isEmpty())
2080              SuperClassWriter::addAttribute
2081                 ("units", field->unit.getValue(), &fieldid);
[463]2082
[1158]2083           // Ugrid field attributes "mesh" and "location"
2084           if (!SuperClassWriter::useCFConvention)
2085           {
2086            if (!domainList.empty())
2087            {
2088              CDomain* domain = CDomain::get(domainList[0]); // Suppose that we have only domain
2089              StdString mesh = domain->name;
2090              SuperClassWriter::addAttribute("mesh", mesh, &fieldid);
2091              StdString location;
2092              if (domain->nvertex == 1)
2093                location = "node";
2094              else if (domain->nvertex == 2)
2095                location = "edge";
2096              else if (domain->nvertex > 2)
2097                location = "face";
2098              SuperClassWriter::addAttribute("location", location, &fieldid);
2099            }
2100
2101           }
2102
2103           if (!field->valid_min.isEmpty())
[498]2104              SuperClassWriter::addAttribute
2105                 ("valid_min", field->valid_min.getValue(), &fieldid);
[463]2106
[498]2107           if (!field->valid_max.isEmpty())
2108              SuperClassWriter::addAttribute
2109                 ("valid_max", field->valid_max.getValue(), &fieldid);
[464]2110
[498]2111            if (!field->scale_factor.isEmpty())
2112              SuperClassWriter::addAttribute
2113                 ("scale_factor", field->scale_factor.getValue(), &fieldid);
[464]2114
[498]2115             if (!field->add_offset.isEmpty())
2116              SuperClassWriter::addAttribute
2117                 ("add_offset", field->add_offset.getValue(), &fieldid);
[488]2118
[498]2119           SuperClassWriter::addAttribute
2120                 ("online_operation", field->operation.getValue(), &fieldid);
[472]2121
[498]2122          // write child variables as attributes
[488]2123
2124
[1021]2125           bool alreadyAddCellMethod = false;
2126           StdString cellMethodsPrefix(""), cellMethodsSuffix("");
2127           if (!field->cell_methods.isEmpty())
2128           {
[1158]2129              StdString cellMethodString = field->cell_methods;
2130              if (field->cell_methods_mode.isEmpty() ||
[1021]2131                 (CField::cell_methods_mode_attr::overwrite == field->cell_methods_mode))
[1158]2132              {
2133                SuperClassWriter::addAttribute("cell_methods", cellMethodString, &fieldid);
2134                alreadyAddCellMethod = true;
2135              }
2136              else
2137              {
2138                switch (field->cell_methods_mode)
2139                {
2140                  case (CField::cell_methods_mode_attr::prefix):
2141                    cellMethodsPrefix = cellMethodString;
2142                    cellMethodsPrefix += " ";
2143                    break;
2144                  case (CField::cell_methods_mode_attr::suffix):
2145                    cellMethodsSuffix = " ";
2146                    cellMethodsSuffix += cellMethodString;
2147                    break;
2148                  case (CField::cell_methods_mode_attr::none):
2149                    break;
2150                  default:
2151                    break;
2152                }
2153              }
[1021]2154           }
[488]2155
[1021]2156
[498]2157           if (wtime)
2158           {
[614]2159              CDuration freqOp = field->freq_op.getValue();
2160              freqOp.solveTimeStep(*context->calendar);
2161              StdString freqOpStr = freqOp.toStringUDUnits();
[612]2162              SuperClassWriter::addAttribute("interval_operation", freqOpStr, &fieldid);
[437]2163
[614]2164              CDuration freqOut = field->getRelFile()->output_freq.getValue();
2165              freqOut.solveTimeStep(*context->calendar);
2166              SuperClassWriter::addAttribute("interval_write", freqOut.toStringUDUnits(), &fieldid);
[612]2167
[1021]2168              StdString cellMethods(cellMethodsPrefix + "time: ");
[612]2169              if (field->operation.getValue() == "instant") cellMethods += "point";
2170              else if (field->operation.getValue() == "average") cellMethods += "mean";
2171              else if (field->operation.getValue() == "accumulate") cellMethods += "sum";
2172              else cellMethods += field->operation;
[614]2173              if (freqOp.resolve(*context->calendar) != freqOut.resolve(*context->calendar))
2174                cellMethods += " (interval: " + freqOpStr + ")";
[1021]2175              cellMethods += cellMethodsSuffix;
2176              if (!alreadyAddCellMethod)
2177                SuperClassWriter::addAttribute("cell_methods", cellMethods, &fieldid);
[498]2178           }
[488]2179
[611]2180           if (hasArea)
2181             SuperClassWriter::addAttribute("cell_measures", cellMeasures, &fieldid);
2182
[498]2183           if (!field->default_value.isEmpty())
2184           {
[1424]2185             double default_value = field->default_value.getValue();
2186             if (type == NC_DOUBLE)
2187             {
2188               SuperClassWriter::setDefaultValue(fieldid, &default_value);
2189             }
2190             else if (type == NC_SHORT)
2191             {
2192               short sdefault_value = (short)default_value;
2193               SuperClassWriter::setDefaultValue(fieldid, &sdefault_value);
2194             }
2195             else
2196             {
2197               float fdefault_value = (float)default_value;
2198               SuperClassWriter::setDefaultValue(fieldid, &fdefault_value);
2199             }
[498]2200           }
2201           else
[517]2202              SuperClassWriter::setDefaultValue(fieldid, (double*)NULL);
[219]2203
[606]2204            if (field->compression_level.isEmpty())
2205              field->compression_level = field->file->compression_level.isEmpty() ? 0 : field->file->compression_level;
2206            SuperClassWriter::setCompressionLevel(fieldid, field->compression_level);
2207
[878]2208           {  // Ecriture des coordonnes
[488]2209
[498]2210              StdString coordstr; //boost::algorithm::join(coodinates, " ")
2211              std::vector<StdString>::iterator
2212                 itc = coodinates.begin(), endc = coodinates.end();
[488]2213
[498]2214              for (; itc!= endc; itc++)
2215              {
2216                 StdString & coord = *itc;
2217                 if (itc+1 != endc)
2218                       coordstr.append(coord).append(" ");
2219                 else  coordstr.append(coord);
2220              }
[219]2221
[498]2222              SuperClassWriter::addAttribute("coordinates", coordstr, &fieldid);
[219]2223
[498]2224           }
[1222]2225
2226           vector<CVariable*> listVars = field->getAllVariables() ;
2227           for (vector<CVariable*>::iterator it = listVars.begin() ;it != listVars.end(); it++) writeAttribute_(*it, fieldid) ;
2228
[219]2229         }
[498]2230         catch (CNetCdfException& e)
2231         {
2232           StdString msg("On writing field : ");
2233           msg.append(fieldid); msg.append("\n");
2234           msg.append("In the context : ");
2235           msg.append(context->getId()); msg.append("\n");
2236           msg.append(e.what());
2237           ERROR("CNc4DataOutput::writeField_(CField* field)", << msg);
2238         }
[879]2239      } // writeField_()
[219]2240
2241      //--------------------------------------------------------------
2242
[347]2243      void CNc4DataOutput::writeFile_ (CFile* file)
[219]2244      {
[773]2245         StdString filename = file->getFileOutputName();
[219]2246         StdString description = (!file->description.isEmpty())
2247                               ? file->description.getValue()
[335]2248                               : StdString("Created by xios");
[609]2249
2250         singleDomain = (file->nbDomains == 1);
2251
[1158]2252         StdString conv_str ;
2253         if (file->convention_str.isEmpty())
2254         {
2255            if (SuperClassWriter::useCFConvention) conv_str="CF-1.6" ;
2256            else conv_str="UGRID" ;
2257         }
2258         else conv_str=file->convention_str ;
2259           
[498]2260         try
2261         {
[1309]2262           if (!appendMode) this->writeFileAttributes(filename, description,
2263                                                      conv_str,
2264                                                      StdString("An IPSL model"),
2265                                                      this->getTimeStamp());
[609]2266
[701]2267           if (!appendMode)
2268             SuperClassWriter::addDimension("axis_nbounds", 2);
[498]2269         }
2270         catch (CNetCdfException& e)
2271         {
2272           StdString msg("On writing file : ");
2273           msg.append(filename); msg.append("\n");
2274           msg.append("In the context : ");
2275           CContext* context = CContext::getCurrent() ;
2276           msg.append(context->getId()); msg.append("\n");
2277           msg.append(e.what());
2278           ERROR("CNc4DataOutput::writeFile_ (CFile* file)", << msg);
2279         }
[219]2280      }
[488]2281
[472]2282      void CNc4DataOutput::writeAttribute_ (CVariable* var, const string& fieldId)
2283      {
[773]2284        StdString name = var->getVariableOutputName();
[488]2285
[498]2286        try
2287        {
[527]2288          if (var->type.getValue() == CVariable::type_attr::t_int || var->type.getValue() == CVariable::type_attr::t_int32)
2289            addAttribute(name, var->getData<int>(), &fieldId);
2290          else if (var->type.getValue() == CVariable::type_attr::t_int16)
2291            addAttribute(name, var->getData<short int>(), &fieldId);
2292          else if (var->type.getValue() == CVariable::type_attr::t_float)
2293            addAttribute(name, var->getData<float>(), &fieldId);
2294          else if (var->type.getValue() == CVariable::type_attr::t_double)
2295            addAttribute(name, var->getData<double>(), &fieldId);
2296          else if (var->type.getValue() == CVariable::type_attr::t_string)
2297            addAttribute(name, var->getData<string>(), &fieldId);
2298          else
2299            ERROR("CNc4DataOutput::writeAttribute_ (CVariable* var, const string& fieldId)",
2300                  << "Unsupported variable of type " << var->type.getStringValue());
[498]2301        }
2302       catch (CNetCdfException& e)
2303       {
2304         StdString msg("On writing attributes of variable with name : ");
2305         msg.append(name); msg.append("in the field "); msg.append(fieldId); msg.append("\n");
2306         msg.append("In the context : ");
2307         CContext* context = CContext::getCurrent() ;
2308         msg.append(context->getId()); msg.append("\n");
2309         msg.append(e.what());
2310         ERROR("CNc4DataOutput::writeAttribute_ (CVariable* var, const string& fieldId)", << msg);
2311       }
[472]2312     }
[488]2313
[472]2314     void CNc4DataOutput::writeAttribute_ (CVariable* var)
2315     {
[773]2316        StdString name = var->getVariableOutputName();
2317
[498]2318        try
2319        {
[527]2320          if (var->type.getValue() == CVariable::type_attr::t_int || var->type.getValue() == CVariable::type_attr::t_int32)
2321            addAttribute(name, var->getData<int>());
2322          else if (var->type.getValue() == CVariable::type_attr::t_int16)
2323            addAttribute(name, var->getData<short int>());
2324          else if (var->type.getValue() == CVariable::type_attr::t_float)
2325            addAttribute(name, var->getData<float>());
2326          else if (var->type.getValue() == CVariable::type_attr::t_double)
2327            addAttribute(name, var->getData<double>());
2328          else if (var->type.getValue() == CVariable::type_attr::t_string)
2329            addAttribute(name, var->getData<string>());
2330          else
2331            ERROR("CNc4DataOutput::writeAttribute_ (CVariable* var)",
2332                  << "Unsupported variable of type " << var->type.getStringValue());
[498]2333        }
2334       catch (CNetCdfException& e)
2335       {
2336         StdString msg("On writing attributes of variable with name : ");
2337         msg.append(name); msg.append("\n");
2338         msg.append("In the context : ");
2339         CContext* context = CContext::getCurrent() ;
2340         msg.append(context->getId()); msg.append("\n");
2341         msg.append(e.what());
2342         ERROR("CNc4DataOutput::writeAttribute_ (CVariable* var)", << msg);
2343       }
[488]2344     }
2345
[321]2346      void CNc4DataOutput::syncFile_ (void)
2347      {
[498]2348        try
2349        {
2350          SuperClassWriter::sync() ;
2351        }
2352        catch (CNetCdfException& e)
2353        {
2354         StdString msg("On synchronizing the write among processes");
2355         msg.append("In the context : ");
2356         CContext* context = CContext::getCurrent() ;
2357         msg.append(context->getId()); msg.append("\n");
2358         msg.append(e.what());
2359         ERROR("CNc4DataOutput::syncFile_ (void)", << msg);
2360        }
[321]2361      }
[219]2362
[286]2363      void CNc4DataOutput::closeFile_ (void)
2364      {
[498]2365        try
2366        {
2367          SuperClassWriter::close() ;
2368        }
2369        catch (CNetCdfException& e)
2370        {
2371         StdString msg("On closing file");
2372         msg.append("In the context : ");
2373         CContext* context = CContext::getCurrent() ;
2374         msg.append(context->getId()); msg.append("\n");
2375         msg.append(e.what());
2376         ERROR("CNc4DataOutput::syncFile_ (void)", << msg);
2377        }
2378
[286]2379      }
2380
[219]2381      //---------------------------------------------------------------
2382
2383      StdString CNc4DataOutput::getTimeStamp(void) const
2384      {
2385         const int buffer_size = 100;
2386         time_t rawtime;
2387         struct tm * timeinfo = NULL;
2388         char buffer [buffer_size];
[1158]2389         StdString formatStr;
2390         if (file->time_stamp_format.isEmpty()) formatStr="%Y-%b-%d %H:%M:%S %Z" ;
2391         else formatStr=file->time_stamp_format;
[219]2392
[1158]2393//         time ( &rawtime );
2394//         timeinfo = localtime ( &rawtime );
[219]2395         time ( &rawtime );
[1158]2396         timeinfo = gmtime ( &rawtime );
2397         strftime (buffer, buffer_size, formatStr.c_str(), timeinfo);
[219]2398
2399         return (StdString(buffer));
2400      }
[488]2401
[219]2402      //---------------------------------------------------------------
[488]2403
[347]2404      void CNc4DataOutput::writeFieldData_ (CField*  field)
[219]2405      {
[707]2406        CContext* context = CContext::getCurrent();
2407        CContextServer* server = context->server;
2408        CGrid* grid = field->grid;
[300]2409
[1158]2410        if (field->getNStep()<1) 
2411        {
2412          return;
2413        }
[952]2414       
[707]2415        if (!grid->doGridHaveDataToWrite())
[1158]2416          if (SuperClass::type == MULTI_FILE || !isCollective)
2417          {
2418            return;
2419          }
[488]2420
[770]2421        StdString fieldid = field->getFieldOutputName();
[286]2422
[707]2423        StdOStringStream oss;
2424        string timeAxisId;
[1158]2425        if (field->hasTimeInstant) timeAxisId = "time_instant";
2426        else if (field->hasTimeCentered) timeAxisId = "time_centered";
[488]2427
[802]2428        StdString timeBoundId = getTimeCounterName() + "_bounds";
[449]2429
[707]2430        StdString timeAxisBoundId;
[1158]2431        if (field->hasTimeInstant) timeAxisBoundId = "time_instant_bounds";
2432        else if (field->hasTimeCentered) timeAxisBoundId = "time_centered_bounds";
[488]2433
[707]2434        if (!field->wasWritten())
2435        {
[1158]2436          if (appendMode && field->file->record_offset.isEmpty() && 
2437              field->getOperationTimeType() != func::CFunctor::once)
[707]2438          {
[1158]2439            double factorUnit;
2440            if (!field->file->time_units.isEmpty() && field->file->time_units==CFile::time_units_attr::days)
2441            factorUnit=context->getCalendar()->getDayLengthInSeconds() ;
2442            else factorUnit=1 ;
2443            field->resetNStep(getRecordFromTime(field->last_Write_srv,factorUnit) + 1);
[707]2444          }
[488]2445
[707]2446          field->setWritten();
2447        }
[488]2448
2449
[707]2450        CArray<double,1> time_data(1);
2451        CArray<double,1> time_data_bound(2);
2452        CArray<double,1> time_counter(1);
2453        CArray<double,1> time_counter_bound(2);
2454
2455        bool wtime = (field->getOperationTimeType() != func::CFunctor::once);
[1158]2456        bool wtimeCounter =false ;
2457        bool wtimeData =false ;
2458       
[707]2459
[444]2460        if (wtime)
2461        {
[692]2462          Time lastWrite = field->last_Write_srv;
2463          Time lastLastWrite = field->lastlast_Write_srv;
2464
[1158]2465         
2466          if (field->hasTimeInstant)
2467          {
2468            time_data(0) = time_data_bound(1) = lastWrite;
[692]2469            time_data_bound(0) = time_data_bound(1) = lastWrite;
[1158]2470            if (timeCounterType==instant)
2471            {
2472              time_counter(0) = time_data(0);
2473              time_counter_bound(0) = time_data_bound(0);
2474              time_counter_bound(1) = time_data_bound(1);
2475              wtimeCounter=true ;
2476            }
2477            if (hasTimeInstant) wtimeData=true ;
2478          }
2479          else if (field->hasTimeCentered)
[488]2480          {
[1158]2481            time_data(0) = (lastWrite + lastLastWrite) / 2;
[692]2482            time_data_bound(0) = lastLastWrite;
2483            time_data_bound(1) = lastWrite;
[1158]2484            if (timeCounterType==centered)
2485            {
2486              time_counter(0) = time_data(0) ;
2487              time_counter_bound(0) = time_data_bound(0) ;
2488              time_counter_bound(1) = time_data_bound(1) ;
2489              wtimeCounter=true ;
2490            }
2491            if (hasTimeCentered) wtimeData=true ;
[488]2492          }
2493
[1158]2494          if (timeCounterType==record)
2495          {
[692]2496            time_counter(0) = field->getNStep() - 1;
[1158]2497            time_counter_bound(0) = time_counter_bound(1) = field->getNStep() - 1;
2498            wtimeCounter=true ;
2499          }
[692]2500
[1158]2501          if (!field->file->time_units.isEmpty() && field->file->time_units==CFile::time_units_attr::days)
[692]2502          {
[1158]2503            double secByDay=context->getCalendar()->getDayLengthInSeconds() ;
2504            time_data/=secByDay;
2505            time_data_bound/=secByDay;
2506            time_counter/=secByDay;
2507            time_counter_bound/=secByDay;
[692]2508          }
2509        }
2510
[707]2511         bool isRoot = (server->intraCommRank == 0);
[488]2512
[464]2513         if (!field->scale_factor.isEmpty() || !field->add_offset.isEmpty())
2514         {
[707]2515           double scaleFactor = 1.0;
2516           double addOffset = 0.0;
2517           if (!field->scale_factor.isEmpty()) scaleFactor = field->scale_factor;
2518           if (!field->add_offset.isEmpty()) addOffset = field->add_offset;
2519           field->scaleFactorAddOffset(scaleFactor, addOffset);
[464]2520         }
[488]2521
[498]2522         try
[219]2523         {
[676]2524           size_t writtenSize;
2525           if (field->getUseCompressedOutput())
2526             writtenSize = grid->getNumberWrittenIndexes();
2527           else
2528             writtenSize = grid->getWrittenDataSize();
2529
2530           CArray<double,1> fieldData(writtenSize);
[567]2531           if (!field->default_value.isEmpty()) fieldData = field->default_value;
[676]2532
2533           if (field->getUseCompressedOutput())
2534             field->outputCompressedField(fieldData);
2535           else
2536             field->outputField(fieldData);
2537
[707]2538           if (!field->prec.isEmpty() && field->prec == 2) fieldData = round(fieldData);
[567]2539
2540           switch (SuperClass::type)
[498]2541           {
[567]2542              case (MULTI_FILE) :
2543              {
[1158]2544                 CTimer::get("Files : writing data").resume();
[692]2545                 SuperClassWriter::writeData(fieldData, fieldid, isCollective, field->getNStep() - 1);
[1158]2546                 CTimer::get("Files : writing data").suspend();
[567]2547                 if (wtime)
2548                 {
[1158]2549                   CTimer::get("Files : writing time axis").resume();
2550                   if ( wtimeData)
[692]2551                   {
[1158]2552//                     SuperClassWriter::writeData(time_data, timeAxisId, isCollective, field->getNStep() - 1);
2553//                     SuperClassWriter::writeData(time_data_bound, timeAxisBoundId, isCollective, field->getNStep() - 1);
2554                       SuperClassWriter::writeTimeAxisData(time_data, timeAxisId, isCollective, field->getNStep() - 1, isRoot);
2555                       SuperClassWriter::writeTimeAxisDataBounds(time_data_bound, timeAxisBoundId, isCollective, field->getNStep() - 1, isRoot);
2556                  }
2557                   if (wtimeCounter)
2558                   {
2559//                     SuperClassWriter::writeData(time_counter, getTimeCounterName(), isCollective, field->getNStep() - 1);
2560//                     if (timeCounterType!=record) SuperClassWriter::writeData(time_counter_bound, timeBoundId, isCollective, field->getNStep() - 1);
2561                     SuperClassWriter::writeTimeAxisData(time_counter, getTimeCounterName(), isCollective, field->getNStep() - 1,isRoot);
2562                     if (timeCounterType!=record) SuperClassWriter::writeTimeAxisDataBounds(time_counter_bound, timeBoundId, isCollective, field->getNStep() - 1, isRoot);
[692]2563                   }
[1158]2564                   CTimer::get("Files : writing time axis").suspend();
[567]2565                 }
[707]2566                 break;
[567]2567              }
2568              case (ONE_FILE) :
2569              {
[676]2570                const std::vector<int>& nZoomBeginGlobal = grid->getDistributionServer()->getZoomBeginGlobal();
2571                const std::vector<int>& nZoomBeginServer = grid->getDistributionServer()->getZoomBeginServer();
2572                const std::vector<int>& nZoomSizeServer  = grid->getDistributionServer()->getZoomSizeServer();
[464]2573
[676]2574                std::vector<StdSize> start, count;
[464]2575
[676]2576                if (field->getUseCompressedOutput())
2577                {
2578                  if (grid->isCompressible())
2579                  {
2580                    start.push_back(grid->getOffsetWrittenIndexes());
2581                    count.push_back(grid->getNumberWrittenIndexes());
2582                  }
2583                  else
2584                  {
[887]2585                    CArray<int,1> axisDomainOrder = grid->axis_domain_order;
[676]2586                    std::vector<StdString> domainList = grid->getDomainList();
2587                    std::vector<StdString> axisList   = grid->getAxisList();
2588                    int numElement = axisDomainOrder.numElements();
2589                    int idxDomain = domainList.size() - 1, idxAxis = axisList.size() - 1;
2590                    int idx = nZoomBeginGlobal.size() - 1;
[464]2591
[676]2592                    start.reserve(nZoomBeginGlobal.size());
2593                    count.reserve(nZoomBeginGlobal.size());
2594
2595
2596                    for (int i = numElement - 1; i >= 0; --i)
2597                    {
[887]2598                      if (2 == axisDomainOrder(i))
[676]2599                      {
2600                        CDomain* domain = CDomain::get(domainList[idxDomain]);
2601
2602                        if (domain->isCompressible())
2603                        {
[1249]2604                          start.push_back(domain->getOffsetWrittenIndexes(comm_file));
2605                          count.push_back(domain->getNumberWrittenIndexes(comm_file));
[710]2606                          idx -= 2;
[676]2607                        }
2608                        else
2609                        {
[710]2610                          if ((domain->type) != CDomain::type_attr::unstructured)
2611                          {
2612                            start.push_back(nZoomBeginServer[idx] - nZoomBeginGlobal[idx]);
2613                            count.push_back(nZoomSizeServer[idx]);
2614                          }
2615                          --idx;
[676]2616                          start.push_back(nZoomBeginServer[idx] - nZoomBeginGlobal[idx]);
2617                          count.push_back(nZoomSizeServer[idx]);
[710]2618                          --idx;
[676]2619                        }
2620                        --idxDomain;
2621                      }
[887]2622                      else if (1 == axisDomainOrder(i))
[676]2623                      {
2624                        CAxis* axis = CAxis::get(axisList[idxAxis]);
2625
2626                        if (axis->isCompressible())
2627                        {
[1249]2628                          start.push_back(axis->getOffsetWrittenIndexes(comm_file));
2629                          count.push_back(axis->getNumberWrittenIndexes(comm_file));
[676]2630                        }
2631                        else
2632                        {
2633                          start.push_back(nZoomBeginServer[idx] - nZoomBeginGlobal[idx]);
2634                          count.push_back(nZoomSizeServer[idx]);
2635                        }
2636
2637                        --idxAxis;
2638                        --idx;
2639                      }
2640                    }
[1158]2641                  }
[676]2642                }
2643                else
[498]2644                {
[887]2645                  CArray<int,1> axisDomainOrder = grid->axis_domain_order;
[705]2646                  std::vector<StdString> domainList = grid->getDomainList();
2647                  std::vector<StdString> axisList   = grid->getAxisList();
2648                  int numElement = axisDomainOrder.numElements();
2649                  int idxDomain = domainList.size() - 1, idxAxis = axisList.size() - 1;
[1025]2650                  int idx = domainList.size() * 2 + axisList.size() - 1;// nZoomBeginGlobal.size() - 1;
[705]2651
2652                  start.reserve(nZoomBeginGlobal.size());
2653                  count.reserve(nZoomBeginGlobal.size());
2654
2655                  for (int i = numElement - 1; i >= 0; --i)
2656                  {
[887]2657                    if (2 == axisDomainOrder(i))
[705]2658                    {
2659                      CDomain* domain = CDomain::get(domainList[idxDomain]);
[710]2660                      if ((domain->type) != CDomain::type_attr::unstructured)
[705]2661                      {
[1099]2662                        start.push_back(domain->zoom_jbegin - domain->global_zoom_jbegin);
2663                        count.push_back(domain->zoom_nj);
[705]2664                      }
2665                      --idx ;
[1143]2666
[1099]2667                        start.push_back(domain->zoom_ibegin - domain->global_zoom_ibegin);
2668                        count.push_back(domain->zoom_ni);
[705]2669                      --idx ;
2670                      --idxDomain;
2671                    }
[887]2672                    else if (1 == axisDomainOrder(i))
[705]2673                    {
[1143]2674                        CAxis* axis = CAxis::get(axisList[idxAxis]);
[1099]2675                        start.push_back(axis->zoom_begin - axis->global_zoom_begin);
2676                        count.push_back(axis->zoom_n);
[705]2677                      --idx;
[1025]2678                      --idxAxis;
[887]2679                    }
2680                    else
2681                    {
2682                      if (1 == axisDomainOrder.numElements())
2683                      {
2684                        start.push_back(0);
2685                        count.push_back(1);
2686                      }
2687                      --idx;
2688                    }
[705]2689                  }
[498]2690                }
[488]2691
[1158]2692
2693                CTimer::get("Files : writing data").resume();
[676]2694                SuperClassWriter::writeData(fieldData, fieldid, isCollective, field->getNStep() - 1, &start, &count);
[1158]2695                CTimer::get("Files : writing data").suspend();
2696
2697                 if (wtime)
2698                 {
2699                   CTimer::get("Files : writing time axis").resume();
2700                   if ( wtimeData)
[692]2701                   {
[1158]2702//                     SuperClassWriter::writeData(time_data, timeAxisId, isCollective, field->getNStep() - 1);
2703//                     SuperClassWriter::writeData(time_data_bound, timeAxisBoundId, isCollective, field->getNStep() - 1);
2704                     SuperClassWriter::writeTimeAxisData(time_data, timeAxisId, isCollective, field->getNStep() - 1, isRoot);
2705                     SuperClassWriter::writeTimeAxisDataBounds(time_data_bound, timeAxisBoundId, isCollective, field->getNStep() - 1, isRoot);
[692]2706                   }
[1158]2707                   if (wtimeCounter)
2708                   {
2709//                     SuperClassWriter::writeData(time_counter, getTimeCounterName(), isCollective, field->getNStep() - 1);
2710//                     if (timeCounterType!=record) SuperClassWriter::writeData(time_counter_bound, timeBoundId, isCollective, field->getNStep() - 1);
2711                     SuperClassWriter::writeTimeAxisData(time_counter, getTimeCounterName(), isCollective, field->getNStep() - 1,isRoot);
2712                     if (timeCounterType!=record) SuperClassWriter::writeTimeAxisDataBounds(time_counter_bound, timeBoundId, isCollective, field->getNStep() - 1, isRoot);
[586]2713
[1158]2714                   }
2715                   CTimer::get("Files : writing time axis").suspend(); 
2716                 }
2717
[586]2718                break;
[286]2719              }
[567]2720            }
[219]2721         }
[498]2722         catch (CNetCdfException& e)
2723         {
2724           StdString msg("On writing field data: ");
2725           msg.append(fieldid); msg.append("\n");
2726           msg.append("In the context : ");
2727           msg.append(context->getId()); msg.append("\n");
2728           msg.append(e.what());
[1130]2729           ERROR("CNc4DataOutput::writeFieldData_ (CField*  field)", << msg);
[498]2730         }
[219]2731      }
2732
2733      //---------------------------------------------------------------
2734
2735      void CNc4DataOutput::writeTimeAxis_
[347]2736                  (CField*    field,
[343]2737                   const boost::shared_ptr<CCalendar> cal)
[219]2738      {
2739         StdOStringStream oss;
[1158]2740         bool createInstantAxis=false ;
2741         bool createCenteredAxis=false ;
2742         bool createTimeCounterAxis=false ;
2743         
[645]2744         if (field->getOperationTimeType() == func::CFunctor::once) return ;
[488]2745
2746
[1158]2747         StdString axisId ;
2748         StdString axisBoundId;
[802]2749         StdString timeid(getTimeCounterName());
[614]2750         StdString timeBoundId("axis_nbounds");
[488]2751
[1158]2752         StdString strTimeUnits ;
2753         if (!field->file->time_units.isEmpty() && field->file->time_units==CFile::time_units_attr::days) strTimeUnits="days since " ;
2754         else  strTimeUnits="seconds since " ;
2755 
2756         if (field->getOperationTimeType() == func::CFunctor::instant) field->hasTimeInstant = true;
2757         if (field->getOperationTimeType() == func::CFunctor::centered) field->hasTimeCentered = true;
2758
2759
2760         if (field->file->time_counter.isEmpty())
[488]2761         {
[1158]2762           if (timeCounterType==none) createTimeCounterAxis=true ;
2763           if (field->hasTimeCentered)
2764           {
2765             timeCounterType=centered ;
2766             if (!hasTimeCentered) createCenteredAxis=true ;
2767           }
2768           if (field->hasTimeInstant)
2769           {
2770             if (timeCounterType==none) timeCounterType=instant ;
2771             if (!hasTimeInstant) createInstantAxis=true ;
2772           }
[488]2773         }
[1158]2774         else if (field->file->time_counter==CFile::time_counter_attr::instant)
2775         {
2776           if (field->hasTimeCentered)
2777           {
2778             if (!hasTimeCentered) createCenteredAxis=true ;
2779           }
2780           if (field->hasTimeInstant)
2781           {
2782             if (timeCounterType==none) createTimeCounterAxis=true ;
2783             timeCounterType=instant ;
2784             if (!hasTimeInstant) createInstantAxis=true ;
2785           }
2786         }
2787         else if (field->file->time_counter==CFile::time_counter_attr::centered)
2788         {
2789           if (field->hasTimeCentered)
2790           {
2791             if (timeCounterType==none) createTimeCounterAxis=true ;
2792             timeCounterType=centered ;
2793             if (!hasTimeCentered) createCenteredAxis=true ;
2794           }
2795           if (field->hasTimeInstant)
2796           {
2797             if (!hasTimeInstant) createInstantAxis=true ;
2798           }
2799         }
2800         else if (field->file->time_counter==CFile::time_counter_attr::instant_exclusive)
2801         {
2802           if (field->hasTimeCentered)
2803           {
2804             if (!hasTimeCentered) createCenteredAxis=true ;
2805           }
2806           if (field->hasTimeInstant)
2807           {
2808             if (timeCounterType==none) createTimeCounterAxis=true ;
2809             timeCounterType=instant ;
2810           }
2811         }
2812         else if (field->file->time_counter==CFile::time_counter_attr::centered_exclusive)
2813         {
2814           if (field->hasTimeCentered)
2815           {
2816             if (timeCounterType==none) createTimeCounterAxis=true ;
2817             timeCounterType=centered ;
2818           }
2819           if (field->hasTimeInstant)
2820           {
2821             if (!hasTimeInstant) createInstantAxis=true ;
2822           }
2823         }
2824         else if (field->file->time_counter==CFile::time_counter_attr::exclusive)
2825         {
2826           if (field->hasTimeCentered)
2827           {
2828             if (timeCounterType==none) createTimeCounterAxis=true ;
2829             if (timeCounterType==instant) createInstantAxis=true ;
2830             timeCounterType=centered ;
2831           }
2832           if (field->hasTimeInstant)
2833           {
2834             if (timeCounterType==none)
2835             {
2836               createTimeCounterAxis=true ;
2837               timeCounterType=instant ;
2838             }
2839             if (timeCounterType==centered)
2840             {
2841               if (!hasTimeInstant) createInstantAxis=true ;
2842             }
2843           }
2844         }
2845         else if (field->file->time_counter==CFile::time_counter_attr::none)
2846         {
2847           if (field->hasTimeCentered)
2848           {
2849             if (!hasTimeCentered) createCenteredAxis=true ;
2850           }
2851           if (field->hasTimeInstant)
2852           {
2853             if (!hasTimeInstant) createInstantAxis=true ;
2854           }
2855         }
2856         else if (field->file->time_counter==CFile::time_counter_attr::record)
2857         {
2858           if (timeCounterType==none) createTimeCounterAxis=true ;
2859           timeCounterType=record ;
2860           if (field->hasTimeCentered)
2861           {
2862             if (!hasTimeCentered) createCenteredAxis=true ;
2863           }
2864           if (field->hasTimeInstant)
2865           {
2866             if (!hasTimeInstant) createInstantAxis=true ;
2867           }
2868         }
2869         
2870         if (createInstantAxis)
2871         {
2872           axisId="time_instant" ;
2873           axisBoundId="time_instant_bounds";
2874           hasTimeInstant=true ;
2875         }
[488]2876
[1158]2877         if (createCenteredAxis)
2878         {
2879           axisId="time_centered" ;
2880           axisBoundId="time_centered_bounds";
2881           hasTimeCentered=true ;
2882         }
2883
2884         
[498]2885         try
[219]2886         {
[1158]2887            std::vector<StdString> dims;
2888           
2889            if (createInstantAxis || createCenteredAxis)
2890            {
2891              // Adding time_instant or time_centered
2892              dims.push_back(timeid);
2893              if (!SuperClassWriter::varExist(axisId))
2894              {
2895                SuperClassWriter::addVariable(axisId, NC_DOUBLE, dims);
[488]2896
[1158]2897                CDate timeOrigin=cal->getTimeOrigin() ;
2898                StdOStringStream oss2;
2899                StdString strInitdate=oss2.str() ;
2900                StdString strTimeOrigin=timeOrigin.toString() ;
2901                this->writeTimeAxisAttributes(axisId, cal->getType(),strTimeUnits+strTimeOrigin,
2902                                              strTimeOrigin, axisBoundId);
2903             }
[219]2904
[1158]2905             // Adding time_instant_bounds or time_centered_bounds variables
2906             if (!SuperClassWriter::varExist(axisBoundId))
2907             {
2908                dims.clear() ;
2909                dims.push_back(timeid);
2910                dims.push_back(timeBoundId);
2911                SuperClassWriter::addVariable(axisBoundId, NC_DOUBLE, dims);
2912             }
[498]2913           }
[488]2914
[1158]2915           if (createTimeCounterAxis)
[498]2916           {
[692]2917             // Adding time_counter
[1158]2918             axisId = getTimeCounterName();
[802]2919             axisBoundId = getTimeCounterName() + "_bounds";
[692]2920             dims.clear();
2921             dims.push_back(timeid);
[1158]2922             if (!SuperClassWriter::varExist(axisId))
[692]2923             {
[1158]2924                SuperClassWriter::addVariable(axisId, NC_DOUBLE, dims);
2925                SuperClassWriter::addAttribute("axis", string("T"), &axisId);
[488]2926
[1158]2927                if (field->file->time_counter.isEmpty() || 
2928                   (field->file->time_counter != CFile::time_counter_attr::record))
[692]2929                {
2930                  CDate timeOrigin = cal->getTimeOrigin();
2931                  StdString strTimeOrigin = timeOrigin.toString();
[498]2932
[1158]2933                  this->writeTimeAxisAttributes(axisId, cal->getType(),
2934                                                strTimeUnits+strTimeOrigin,
[692]2935                                                strTimeOrigin, axisBoundId);
2936                }
2937             }
2938
2939             // Adding time_counter_bound dimension
[1158]2940             if (field->file->time_counter.isEmpty() || (field->file->time_counter != CFile::time_counter_attr::record))
[692]2941             {
2942                if (!SuperClassWriter::varExist(axisBoundId))
2943                {
2944                  dims.clear();
2945                  dims.push_back(timeid);
2946                  dims.push_back(timeBoundId);
2947                  SuperClassWriter::addVariable(axisBoundId, NC_DOUBLE, dims);
2948                }
2949             }
[498]2950           }
[488]2951         }
[498]2952         catch (CNetCdfException& e)
[488]2953         {
[498]2954           StdString msg("On writing time axis data: ");
2955           msg.append("In the context : ");
2956           CContext* context = CContext::getCurrent() ;
2957           msg.append(context->getId()); msg.append("\n");
2958           msg.append(e.what());
2959           ERROR("CNc4DataOutput::writeTimeAxis_ (CField*    field, \
2960                  const boost::shared_ptr<CCalendar> cal)", << msg);
[488]2961         }
[219]2962      }
2963
2964      //---------------------------------------------------------------
[488]2965
[219]2966      void CNc4DataOutput::writeTimeAxisAttributes(const StdString & axis_name,
2967                                                   const StdString & calendar,
2968                                                   const StdString & units,
2969                                                   const StdString & time_origin,
[488]2970                                                   const StdString & time_bounds,
[219]2971                                                   const StdString & standard_name,
[613]2972                                                   const StdString & long_name)
[219]2973      {
[498]2974         try
2975         {
2976           SuperClassWriter::addAttribute("standard_name", standard_name, &axis_name);
2977           SuperClassWriter::addAttribute("long_name",     long_name    , &axis_name);
2978           SuperClassWriter::addAttribute("calendar",      calendar     , &axis_name);
2979           SuperClassWriter::addAttribute("units",         units        , &axis_name);
2980           SuperClassWriter::addAttribute("time_origin",   time_origin  , &axis_name);
2981           SuperClassWriter::addAttribute("bounds",        time_bounds  , &axis_name);
2982         }
2983         catch (CNetCdfException& e)
2984         {
2985           StdString msg("On writing time axis Attribute: ");
2986           msg.append("In the context : ");
2987           CContext* context = CContext::getCurrent() ;
2988           msg.append(context->getId()); msg.append("\n");
2989           msg.append(e.what());
2990           ERROR("CNc4DataOutput::writeTimeAxisAttributes(const StdString & axis_name, \
[613]2991                                                          const StdString & calendar,\
2992                                                          const StdString & units, \
2993                                                          const StdString & time_origin, \
2994                                                          const StdString & time_bounds, \
2995                                                          const StdString & standard_name, \
2996                                                          const StdString & long_name)", << msg);
[498]2997         }
[219]2998      }
[488]2999
[219]3000      //---------------------------------------------------------------
3001
3002      void CNc4DataOutput::writeAxisAttributes(const StdString & axis_name,
3003                                               const StdString & axis,
3004                                               const StdString & standard_name,
3005                                               const StdString & long_name,
3006                                               const StdString & units,
3007                                               const StdString & nav_model)
3008      {
[498]3009         try
3010         {
[613]3011          if (!axis.empty())
3012            SuperClassWriter::addAttribute("axis"       , axis         , &axis_name);
3013
[498]3014          SuperClassWriter::addAttribute("standard_name", standard_name, &axis_name);
3015          SuperClassWriter::addAttribute("long_name"    , long_name    , &axis_name);
3016          SuperClassWriter::addAttribute("units"        , units        , &axis_name);
[973]3017//          SuperClassWriter::addAttribute("nav_model"    , nav_model    , &axis_name);
[498]3018         }
3019         catch (CNetCdfException& e)
3020         {
3021           StdString msg("On writing Axis Attribute: ");
3022           msg.append("In the context : ");
3023           CContext* context = CContext::getCurrent() ;
3024           msg.append(context->getId()); msg.append("\n");
3025           msg.append(e.what());
3026           ERROR("CNc4DataOutput::writeAxisAttributes(const StdString & axis_name, \
[613]3027                                                      const StdString & axis, \
3028                                                      const StdString & standard_name, \
3029                                                      const StdString & long_name, \
3030                                                      const StdString & units, \
3031                                                      const StdString & nav_model)", << msg);
[498]3032         }
[219]3033      }
3034
3035      //---------------------------------------------------------------
[488]3036
[219]3037      void CNc4DataOutput::writeLocalAttributes
3038         (int ibegin, int ni, int jbegin, int nj, StdString domid)
3039      {
[498]3040        try
3041        {
[318]3042         SuperClassWriter::addAttribute(StdString("ibegin").append(domid), ibegin);
3043         SuperClassWriter::addAttribute(StdString("ni"    ).append(domid), ni);
3044         SuperClassWriter::addAttribute(StdString("jbegin").append(domid), jbegin);
3045         SuperClassWriter::addAttribute(StdString("nj"    ).append(domid), nj);
[498]3046        }
3047        catch (CNetCdfException& e)
3048        {
3049           StdString msg("On writing Local Attributes: ");
3050           msg.append("In the context : ");
3051           CContext* context = CContext::getCurrent() ;
3052           msg.append(context->getId()); msg.append("\n");
3053           msg.append(e.what());
3054           ERROR("CNc4DataOutput::writeLocalAttributes \
3055                  (int ibegin, int ni, int jbegin, int nj, StdString domid)", << msg);
3056        }
3057
[219]3058      }
3059
[628]3060      void CNc4DataOutput::writeLocalAttributes_IOIPSL(const StdString& dimXid, const StdString& dimYid,
3061                                                       int ibegin, int ni, int jbegin, int nj, int ni_glo, int nj_glo, int rank, int size)
[391]3062      {
3063         CArray<int,1> array(2) ;
3064
[498]3065         try
3066         {
3067           SuperClassWriter::addAttribute("DOMAIN_number_total",size ) ;
3068           SuperClassWriter::addAttribute("DOMAIN_number", rank) ;
[629]3069           array = SuperClassWriter::getDimension(dimXid) + 1, SuperClassWriter::getDimension(dimYid) + 1;
[498]3070           SuperClassWriter::addAttribute("DOMAIN_dimensions_ids",array) ;
3071           array=ni_glo,nj_glo ;
3072           SuperClassWriter::addAttribute("DOMAIN_size_global", array) ;
3073           array=ni,nj ;
3074           SuperClassWriter::addAttribute("DOMAIN_size_local", array) ;
[819]3075           array=ibegin+1,jbegin+1 ;
[498]3076           SuperClassWriter::addAttribute("DOMAIN_position_first", array) ;
[819]3077           array=ibegin+ni-1+1,jbegin+nj-1+1 ;
[498]3078           SuperClassWriter::addAttribute("DOMAIN_position_last",array) ;
3079           array=0,0 ;
3080           SuperClassWriter::addAttribute("DOMAIN_halo_size_start", array) ;
3081           SuperClassWriter::addAttribute("DOMAIN_halo_size_end", array);
3082           SuperClassWriter::addAttribute("DOMAIN_type",string("box")) ;
3083  /*
3084           SuperClassWriter::addAttribute("DOMAIN_DIM_N001",string("x")) ;
3085           SuperClassWriter::addAttribute("DOMAIN_DIM_N002",string("y")) ;
3086           SuperClassWriter::addAttribute("DOMAIN_DIM_N003",string("axis_A")) ;
3087           SuperClassWriter::addAttribute("DOMAIN_DIM_N004",string("time_counter")) ;
3088  */
3089         }
3090         catch (CNetCdfException& e)
3091         {
[628]3092           StdString msg("On writing Local Attributes IOIPSL \n");
[498]3093           msg.append("In the context : ");
3094           CContext* context = CContext::getCurrent() ;
3095           msg.append(context->getId()); msg.append("\n");
3096           msg.append(e.what());
3097           ERROR("CNc4DataOutput::writeLocalAttributes_IOIPSL \
3098                  (int ibegin, int ni, int jbegin, int nj, int ni_glo, int nj_glo, int rank, int size)", << msg);
3099         }
[391]3100      }
[219]3101      //---------------------------------------------------------------
3102
3103      void CNc4DataOutput:: writeFileAttributes(const StdString & name,
3104                                                const StdString & description,
3105                                                const StdString & conventions,
3106                                                const StdString & production,
3107                                                const StdString & timeStamp)
3108      {
[498]3109         try
3110         {
3111           SuperClassWriter::addAttribute("name"       , name);
3112           SuperClassWriter::addAttribute("description", description);
[613]3113           SuperClassWriter::addAttribute("title"      , description);
3114           SuperClassWriter::addAttribute("Conventions", conventions);
[1158]3115           // SuperClassWriter::addAttribute("production" , production);
3116
3117           StdString timeStampStr ;
3118           if (file->time_stamp_name.isEmpty()) timeStampStr="timeStamp" ;
3119           else timeStampStr=file->time_stamp_name ;
3120           SuperClassWriter::addAttribute(timeStampStr, timeStamp);
3121
3122           StdString uuidName ;
3123           if (file->uuid_name.isEmpty()) uuidName="uuid" ;
3124           else uuidName=file->uuid_name ;
3125
3126           if (file->uuid_format.isEmpty()) SuperClassWriter::addAttribute(uuidName, getUuidStr());
3127           else SuperClassWriter::addAttribute(uuidName, getUuidStr(file->uuid_format));
3128         
[498]3129         }
3130         catch (CNetCdfException& e)
3131         {
3132           StdString msg("On writing File Attributes \n ");
3133           msg.append("In the context : ");
3134           CContext* context = CContext::getCurrent() ;
3135           msg.append(context->getId()); msg.append("\n");
3136           msg.append(e.what());
3137           ERROR("CNc4DataOutput:: writeFileAttributes(const StdString & name, \
3138                                                const StdString & description, \
3139                                                const StdString & conventions, \
3140                                                const StdString & production, \
3141                                                const StdString & timeStamp)", << msg);
3142         }
[219]3143      }
3144
3145      //---------------------------------------------------------------
3146
3147      void CNc4DataOutput::writeMaskAttributes(const StdString & mask_name,
3148                                               int data_dim,
3149                                               int data_ni,
3150                                               int data_nj,
3151                                               int data_ibegin,
3152                                               int data_jbegin)
3153      {
[498]3154         try
3155         {
3156           SuperClassWriter::addAttribute("data_dim"   , data_dim   , &mask_name);
3157           SuperClassWriter::addAttribute("data_ni"    , data_ni    , &mask_name);
3158           SuperClassWriter::addAttribute("data_nj"    , data_nj    , &mask_name);
3159           SuperClassWriter::addAttribute("data_ibegin", data_ibegin, &mask_name);
3160           SuperClassWriter::addAttribute("data_jbegin", data_jbegin, &mask_name);
3161         }
3162         catch (CNetCdfException& e)
3163         {
3164           StdString msg("On writing Mask Attributes \n ");
3165           msg.append("In the context : ");
3166           CContext* context = CContext::getCurrent() ;
3167           msg.append(context->getId()); msg.append("\n");
3168           msg.append(e.what());
3169           ERROR("CNc4DataOutput::writeMaskAttributes(const StdString & mask_name, \
3170                                               int data_dim, \
3171                                               int data_ni, \
3172                                               int data_nj, \
3173                                               int data_ibegin, \
3174                                               int data_jbegin)", << msg);
3175         }
[219]3176      }
3177
3178      ///--------------------------------------------------------------
3179
[1158]3180      StdSize CNc4DataOutput::getRecordFromTime(Time time, double factorUnit)
[707]3181      {
3182        std::map<Time, StdSize>::const_iterator it = timeToRecordCache.find(time);
3183        if (it == timeToRecordCache.end())
3184        {
[802]3185          StdString timeAxisBoundsId(getTimeCounterName() + "_bounds");
[1158]3186          if (!SuperClassWriter::varExist(timeAxisBoundsId)) timeAxisBoundsId = "time_centered_bounds";
3187          if (!SuperClassWriter::varExist(timeAxisBoundsId)) timeAxisBoundsId = "time_instant_bounds";
[707]3188
3189          CArray<double,2> timeAxisBounds;
[1158]3190          std::vector<StdSize> dimSize(SuperClassWriter::getDimensions(timeAxisBoundsId)) ;
3191         
[707]3192          StdSize record = 0;
3193          double dtime(time);
[1158]3194          for (int n = dimSize[0] - 1; n >= 0; n--)
[707]3195          {
[1158]3196            SuperClassWriter::getTimeAxisBounds(timeAxisBounds, timeAxisBoundsId, isCollective, n);
3197            timeAxisBounds*=factorUnit ;
3198            if (timeAxisBounds(1, 0) < dtime)
[707]3199            {
3200              record = n + 1;
3201              break;
3202            }
3203          }
3204          it = timeToRecordCache.insert(std::make_pair(time, record)).first;
3205        }
3206        return it->second;
3207      }
[774]3208
3209      ///--------------------------------------------------------------
3210
3211      bool CNc4DataOutput::isWrittenDomain(const std::string& domainName) const
3212      {
3213        return (this->writtenDomains.find(domainName) != this->writtenDomains.end());
3214      }
3215
3216      bool CNc4DataOutput::isWrittenCompressedDomain(const std::string& domainName) const
3217      {
3218        return (this->writtenCompressedDomains.find(domainName) != this->writtenCompressedDomains.end());
3219      }
3220
3221      bool CNc4DataOutput::isWrittenAxis(const std::string& axisName) const
3222      {
3223        return (this->writtenAxis.find(axisName) != this->writtenAxis.end());
3224      }
3225
3226      bool CNc4DataOutput::isWrittenCompressedAxis(const std::string& axisName) const
3227      {
3228        return (this->writtenCompressedAxis.find(axisName) != this->writtenCompressedAxis.end());
3229      }
3230
[887]3231      bool CNc4DataOutput::isWrittenScalar(const std::string& scalarName) const
3232      {
3233        return (this->writtenScalar.find(scalarName) != this->writtenScalar.end());
3234      }
3235
[774]3236      void CNc4DataOutput::setWrittenDomain(const std::string& domainName)
3237      {
3238        this->writtenDomains.insert(domainName);
3239      }
3240
3241      void CNc4DataOutput::setWrittenCompressedDomain(const std::string& domainName)
3242      {
3243        this->writtenCompressedDomains.insert(domainName);
3244      }
3245
3246      void CNc4DataOutput::setWrittenAxis(const std::string& axisName)
3247      {
3248        this->writtenAxis.insert(axisName);
3249      }
3250
3251      void CNc4DataOutput::setWrittenCompressedAxis(const std::string& axisName)
3252      {
3253        this->writtenCompressedAxis.insert(axisName);
3254      }
[887]3255
3256      void CNc4DataOutput::setWrittenScalar(const std::string& scalarName)
3257      {
3258        this->writtenScalar.insert(scalarName);
3259      }
[335]3260} // namespace xios
Note: See TracBrowser for help on using the repository browser.