Ignore:
Timestamp:
07/01/16 20:51:52 (8 years ago)
Author:
oabramkina
Message:

Corrected submit for UGRID.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/io/nc4_data_output.cpp

    r878 r879  
    2121            , filename(filename) 
    2222      { 
    23                 SuperClass::type = MULTI_FILE; 
     23    SuperClass::type = MULTI_FILE; 
    2424      } 
    2525 
     
    3333            , isCollective(isCollective) 
    3434      { 
    35                 SuperClass::type = (multifile) ? MULTI_FILE : ONE_FILE; 
     35    SuperClass::type = (multifile) ? MULTI_FILE : ONE_FILE; 
    3636      } 
    3737 
    3838      CNc4DataOutput::~CNc4DataOutput(void) 
    39           { /* Ne rien faire de plus */ } 
     39    { /* Ne rien faire de plus */ } 
    4040 
    4141      ///-------------------------------------------------------------- 
     
    5252         if (domain->type == CDomain::type_attr::unstructured) 
    5353         { 
    54                         if (SuperClassWriter::useCFConvention) 
    55                                 writeUnstructuredDomain(domain) ; 
    56                         else 
    57                                 writeUnstructuredDomainUgrid(domain) ; 
     54      if (SuperClassWriter::useCFConvention) 
     55        writeUnstructuredDomain(domain) ; 
     56      else 
     57        writeUnstructuredDomainUgrid(domain) ; 
    5858           return ; 
    5959         } 
     
    434434      } 
    435435 
    436           //-------------------------------------------------------------- 
    437  
    438                 void CNc4DataOutput::writeUnstructuredDomainUgrid(CDomain* domain) 
    439                 { 
    440                         CContext* context = CContext::getCurrent() ; 
    441                         CContextServer* server=context->server ; 
    442  
    443                         if (domain->IsWritten(this->filename)) return; 
    444                         domain->checkAttributes(); 
    445                         if (domain->isEmpty()) 
    446                                 if (SuperClass::type==MULTI_FILE) return ; 
    447  
    448                         std::vector<StdString> dim0; 
    449                         StdString domid = domain->getDomainOutputName(); 
    450                         StdString domainName = domain->name; 
    451  
    452                         if (domain->mesh->isWritten(domainName)) domain->mesh = CMesh::getMesh; 
    453  
    454                         domain->mesh->createMesh(domain->lonvalue_srv, domain->latvalue_srv, domain->bounds_lon_srv, domain->bounds_lat_srv); 
    455                         //domain->mesh->createMeshEpsilon(domain->lonvalue_srv, domain->latvalue_srv, domain->bounds_lon_srv, domain->bounds_lat_srv); 
    456  
    457                         StdString node_x = domainName + "_node_x"; 
    458                         StdString node_y = domainName + "_node_y"; 
    459  
    460                         StdString edge_x = domainName + "_edge_x"; 
    461                         StdString edge_y = domainName + "_edge_y"; 
    462                         StdString edge_nodes = domainName + "_edge_nodes"; 
    463  
    464                         StdString face_x = domainName + "_face_x"; 
    465                         StdString face_y = domainName + "_face_y"; 
    466                         StdString face_nodes = domainName + "_face_nodes"; 
    467  
    468                         StdString dimNode = "n" + domainName + "_node"; 
    469                         StdString dimEdge = "n" + domainName + "_edge"; 
    470                         StdString dimFace = "n" + domainName + "_face"; 
    471                         StdString dimVertex = "n" + domainName + "_vertex"; 
    472                         StdString dimTwo = "Two"; 
    473  
    474                         if (!SuperClassWriter::dimExist(dimTwo)) SuperClassWriter::addDimension(dimTwo, 2); 
    475                         if (!isWrittenDomain(domid)) 
    476                         { 
    477                                 dim0.clear(); 
    478                                 SuperClassWriter::addVariable(domainName, NC_INT, dim0); 
    479                                 SuperClassWriter::addAttribute("cf_role", StdString("mesh_topology"), &domainName); 
    480                                 SuperClassWriter::addAttribute("node_coordinates", node_x + " " + node_y, &domainName); 
    481                         } 
    482  
    483                         try 
    484                         { 
    485                                 switch (SuperClass::type) 
    486                                 { 
    487                                         case (ONE_FILE) : 
    488                                         { 
    489                                                 // Adding nodes 
    490                                                 if (domain->nvertex == 1) 
    491                                                 { 
    492                                                         if (!SuperClassWriter::varExist(node_x) || !SuperClassWriter::varExist(node_y)) 
    493                                                         { 
    494                                                                 SuperClassWriter::addDimension(dimNode, domain->mesh->nbNodes); 
    495                                                                 dim0.clear(); 
    496                                                                 dim0.push_back(dimNode); 
    497                                                                 SuperClassWriter::addVariable(node_x, NC_FLOAT, dim0); 
    498                                                                 SuperClassWriter::addAttribute("standard_name", StdString("longitude"), &node_x); 
    499                                                                 SuperClassWriter::addAttribute("longname_name", StdString("Longitude of mesh nodes."), &node_x); 
    500                                                                 SuperClassWriter::addAttribute("units", StdString("degrees_east"), &node_x); 
    501                                                                 SuperClassWriter::addVariable(node_y, NC_FLOAT, dim0); 
    502                                                                 SuperClassWriter::addAttribute("standard_name", StdString("latitude"), &node_y); 
    503                                                                 SuperClassWriter::addAttribute("longname_name", StdString("Latitude of mesh nodes."), &node_y); 
    504                                                                 SuperClassWriter::addAttribute("units", StdString("degrees_north"), &node_y); 
    505                                                         } 
    506                                                 } // domain->nvertex == 1 
    507  
    508                                                 // Adding edges and nodes, if nodes have not been defined previously 
    509                                                 if (domain->nvertex == 2) 
    510                                                 { 
    511                                                         // Nodes 
    512                                                         if (!SuperClassWriter::varExist(node_x) || !SuperClassWriter::varExist(node_y)) 
    513                                                         { 
    514                                                                 SuperClassWriter::addDimension(dimNode, domain->mesh->nbNodes); 
    515                                                                 dim0.clear(); 
    516                                                                 dim0.push_back(dimNode); 
    517                                                                 SuperClassWriter::addVariable(node_x, NC_FLOAT, dim0); 
    518                                                                 SuperClassWriter::addAttribute("standard_name", StdString("longitude"), &node_x); 
    519                                                                 SuperClassWriter::addAttribute("longname_name", StdString("Longitude of mesh nodes."), &node_x); 
    520                                                                 SuperClassWriter::addAttribute("units", StdString("degrees_east"), &node_x); 
    521                                                                 SuperClassWriter::addVariable(node_y, NC_FLOAT, dim0); 
    522                                                                 SuperClassWriter::addAttribute("standard_name", StdString("latitude"), &node_y); 
    523                                                                 SuperClassWriter::addAttribute("longname_name", StdString("Latitude of mesh nodes."), &node_y); 
    524                                                                 SuperClassWriter::addAttribute("units", StdString("degrees_north"), &node_y); 
    525                                                         } 
    526                                                         // Edges 
    527                                                         if (!SuperClassWriter::varExist(edge_x) || !SuperClassWriter::varExist(edge_y)) 
    528                                                         { 
    529                                                                 SuperClassWriter::addAttribute("edge_node_connectivity", edge_nodes, &domainName); 
    530                                                                 SuperClassWriter::addAttribute("edge_coordinates", edge_x + " " + edge_y, &domainName); 
    531                                                                 SuperClassWriter::addDimension(dimEdge, domain->mesh->nbEdges); 
    532                                                                 dim0.clear(); 
    533                                                                 dim0.push_back(dimEdge); 
    534                                                                 SuperClassWriter::addVariable(edge_x, NC_FLOAT, dim0); 
    535                                                                 SuperClassWriter::addAttribute("standard_name", StdString("longitude"), &edge_x); 
    536                                                                 SuperClassWriter::addAttribute("longname_name", StdString("Characteristic longitude of mesh edges."), &edge_x); 
    537                                                                 SuperClassWriter::addAttribute("units", StdString("degrees_east"), &edge_x); 
    538                                                                 SuperClassWriter::addVariable(edge_y, NC_FLOAT, dim0); 
    539                                                                 SuperClassWriter::addAttribute("standard_name", StdString("latitude"), &edge_y); 
    540                                                                 SuperClassWriter::addAttribute("longname_name", StdString("Characteristic latitude of mesh edges."), &edge_y); 
    541                                                                 SuperClassWriter::addAttribute("units", StdString("degrees_north"), &edge_y); 
    542                                                                 dim0.clear(); 
    543                                                                 dim0.push_back(dimEdge); 
    544                                                                 dim0.push_back(dimTwo); 
    545                                                                 SuperClassWriter::addVariable(edge_nodes, NC_INT, dim0); 
    546                                                                 SuperClassWriter::addAttribute("cf_role", StdString("edge_node_connectivity"), &edge_nodes); 
    547                                                                 SuperClassWriter::addAttribute("long_name", StdString("Maps every edge/link to two nodes that it connects."), &edge_nodes); 
    548                                                                 SuperClassWriter::addAttribute("start_index", 0, &edge_nodes); 
    549                                                         } 
    550                                                 } // domain->nvertex == 2 
    551  
    552                                                 // Adding faces, edges, and nodes, if edges and nodes have not been defined previously 
    553                                                 if (domain->nvertex > 2) 
    554                                                 { 
    555                                                         // Nodes 
    556                                                         if (!SuperClassWriter::varExist(node_x) || !SuperClassWriter::varExist(node_y)) 
    557                                                         { 
    558                                                                 SuperClassWriter::addDimension(dimNode, domain->mesh->nbNodes); 
    559                                                                 dim0.clear(); 
    560                                                                 dim0.push_back(dimNode); 
    561                                                                 SuperClassWriter::addVariable(node_x, NC_FLOAT, dim0); 
    562                                                                 SuperClassWriter::addAttribute("standard_name", StdString("longitude"), &node_x); 
    563                                                                 SuperClassWriter::addAttribute("longname_name", StdString("Longitude of mesh nodes."), &node_x); 
    564                                                                 SuperClassWriter::addAttribute("units", StdString("degrees_east"), &node_x); 
    565                                                                 SuperClassWriter::addVariable(node_y, NC_FLOAT, dim0); 
    566                                                                 SuperClassWriter::addAttribute("standard_name", StdString("latitude"), &node_y); 
    567                                                                 SuperClassWriter::addAttribute("longname_name", StdString("Latitude of mesh nodes."), &node_y); 
    568                                                                 SuperClassWriter::addAttribute("units", StdString("degrees_north"), &node_y); 
    569                                                         } 
    570                                                         // Edges 
    571                                                         if (!SuperClassWriter::varExist(edge_x) || !SuperClassWriter::varExist(edge_y)) 
    572                                                         { 
    573                                                                 SuperClassWriter::addAttribute("edge_coordinates", edge_x + " " + edge_y, &domainName); 
    574                                                                 SuperClassWriter::addAttribute("edge_node_connectivity", edge_nodes, &domainName); 
    575                                                                 SuperClassWriter::addDimension(dimEdge, domain->mesh->nbEdges); 
    576                                                                 dim0.clear(); 
    577                                                                 dim0.push_back(dimEdge); 
    578                                                                 SuperClassWriter::addVariable(edge_x, NC_FLOAT, dim0); 
    579                                                                 SuperClassWriter::addAttribute("standard_name", StdString("longitude"), &edge_x); 
    580                                                                 SuperClassWriter::addAttribute("longname_name", StdString("Characteristic longitude of mesh edges."), &edge_x); 
    581                                                                 SuperClassWriter::addAttribute("units", StdString("degrees_east"), &edge_x); 
    582                                                                 SuperClassWriter::addVariable(edge_y, NC_FLOAT, dim0); 
    583                                                                 SuperClassWriter::addAttribute("standard_name", StdString("latitude"), &edge_y); 
    584                                                                 SuperClassWriter::addAttribute("longname_name", StdString("Characteristic latitude of mesh edges."), &edge_y); 
    585                                                                 SuperClassWriter::addAttribute("units", StdString("degrees_north"), &edge_y); 
    586                                                                 dim0.clear(); 
    587                                                                 dim0.push_back(dimEdge); 
    588                                                                 dim0.push_back(dimTwo); 
    589                                                                 SuperClassWriter::addVariable(edge_nodes, NC_INT, dim0); 
    590                                                                 SuperClassWriter::addAttribute("cf_role", StdString("edge_node_connectivity"), &edge_nodes); 
    591                                                                 SuperClassWriter::addAttribute("long_name", StdString("Maps every edge/link to two nodes that it connects."), &edge_nodes); 
    592                                                                 SuperClassWriter::addAttribute("start_index", 0, &edge_nodes); 
    593                                                         } 
    594                                                         // Faces 
    595                                                                 SuperClassWriter::addAttribute("face_coordinates", face_x + " " + face_y, &domainName); 
    596                                                                 SuperClassWriter::addAttribute("face_node_connectivity", face_nodes, &domainName); 
    597                                                                 SuperClassWriter::addDimension(dimFace, domain->mesh->nbFaces); 
    598                                                                 SuperClassWriter::addDimension(dimVertex, domain->mesh->nvertex); 
    599                                                                 dim0.clear(); 
    600                                                                 dim0.push_back(dimFace); 
    601                                                                 SuperClassWriter::addVariable(face_x, NC_FLOAT, dim0); 
    602                                                                 SuperClassWriter::addAttribute("standard_name", StdString("longitude"), &face_x); 
    603                                                                 SuperClassWriter::addAttribute("longname_name", StdString("Characteristic longitude of mesh faces."), &face_x); 
    604                                                                 SuperClassWriter::addAttribute("units", StdString("degrees_east"), &face_x); 
    605                                                                 SuperClassWriter::addVariable(face_y, NC_FLOAT, dim0); 
    606                                                                 SuperClassWriter::addAttribute("standard_name", StdString("latitude"), &face_y); 
    607                                                                 SuperClassWriter::addAttribute("longname_name", StdString("Characteristic latitude of mesh faces."), &face_y); 
    608                                                                 SuperClassWriter::addAttribute("units", StdString("degrees_north"), &face_y); 
    609                                                                 dim0.clear(); 
    610                                                                 dim0.push_back(dimFace); 
    611                                                                 dim0.push_back(dimVertex); 
    612                                                                 SuperClassWriter::addVariable(face_nodes, NC_INT, dim0); 
    613                                                                 SuperClassWriter::addAttribute("cf_role", StdString("face_node_connectivity"), &face_nodes); 
    614                                                                 SuperClassWriter::addAttribute("long_name", StdString("Maps every face to its corner nodes."), &face_nodes); 
    615                                                                 SuperClassWriter::addAttribute("start_index", 0, &face_nodes); 
    616                                                 } // domain->nvertex > 2 
    617  
    618                                                 SuperClassWriter::definition_end(); 
    619  
    620                                                 if (!isWrittenDomain(domid)) 
    621                                                 { 
    622                                                         if (domain->nvertex == 1) 
    623                                                         { 
    624                                                                 SuperClassWriter::writeData(domain->mesh->node_lat, node_y, isCollective, 0); 
    625                                                                 SuperClassWriter::writeData(domain->mesh->node_lon, node_x, isCollective, 0); 
    626                                                         } 
    627                                                         else if (domain->nvertex == 2) 
     436    //-------------------------------------------------------------- 
     437 
     438    void CNc4DataOutput::writeUnstructuredDomainUgrid(CDomain* domain) 
     439    { 
     440      CContext* context = CContext::getCurrent() ; 
     441      CContextServer* server=context->server ; 
     442 
     443      if (domain->IsWritten(this->filename)) return; 
     444      domain->checkAttributes(); 
     445      if (domain->isEmpty()) 
     446        if (SuperClass::type==MULTI_FILE) return ; 
     447 
     448      std::vector<StdString> dim0; 
     449      StdString domid = domain->getDomainOutputName(); 
     450      StdString domainName = domain->name; 
     451 
     452      if (domain->mesh->isWritten(domainName)) domain->mesh = CMesh::getMesh; 
     453 
     454      //domain->mesh->createMesh(domain->lonvalue_srv, domain->latvalue_srv, domain->bounds_lon_srv, domain->bounds_lat_srv); 
     455      domain->mesh->createMeshEpsilon(domain->lonvalue_srv, domain->latvalue_srv, domain->bounds_lon_srv, domain->bounds_lat_srv); 
     456 
     457      StdString node_x = domainName + "_node_x"; 
     458      StdString node_y = domainName + "_node_y"; 
     459 
     460      StdString edge_x = domainName + "_edge_x"; 
     461      StdString edge_y = domainName + "_edge_y"; 
     462      StdString edge_nodes = domainName + "_edge_nodes"; 
     463 
     464      StdString face_x = domainName + "_face_x"; 
     465      StdString face_y = domainName + "_face_y"; 
     466      StdString face_nodes = domainName + "_face_nodes"; 
     467 
     468      StdString dimNode = "n" + domainName + "_node"; 
     469      StdString dimEdge = "n" + domainName + "_edge"; 
     470      StdString dimFace = "n" + domainName + "_face"; 
     471      StdString dimVertex = "n" + domainName + "_vertex"; 
     472      StdString dimTwo = "Two"; 
     473 
     474      if (!SuperClassWriter::dimExist(dimTwo)) SuperClassWriter::addDimension(dimTwo, 2); 
     475      if (!isWrittenDomain(domid)) 
     476      { 
     477        dim0.clear(); 
     478        SuperClassWriter::addVariable(domainName, NC_INT, dim0); 
     479        SuperClassWriter::addAttribute("cf_role", StdString("mesh_topology"), &domainName); 
     480        SuperClassWriter::addAttribute("node_coordinates", node_x + " " + node_y, &domainName); 
     481      } 
     482 
     483      try 
     484      { 
     485        switch (SuperClass::type) 
     486        { 
     487          case (ONE_FILE) : 
     488          { 
     489            // Adding nodes 
     490            if (domain->nvertex == 1) 
     491            { 
     492              if (!SuperClassWriter::varExist(node_x) || !SuperClassWriter::varExist(node_y)) 
     493              { 
     494                SuperClassWriter::addDimension(dimNode, domain->mesh->nbNodes); 
     495                dim0.clear(); 
     496                dim0.push_back(dimNode); 
     497                SuperClassWriter::addVariable(node_x, NC_FLOAT, dim0); 
     498                SuperClassWriter::addAttribute("standard_name", StdString("longitude"), &node_x); 
     499                SuperClassWriter::addAttribute("longname_name", StdString("Longitude of mesh nodes."), &node_x); 
     500                SuperClassWriter::addAttribute("units", StdString("degrees_east"), &node_x); 
     501                SuperClassWriter::addVariable(node_y, NC_FLOAT, dim0); 
     502                SuperClassWriter::addAttribute("standard_name", StdString("latitude"), &node_y); 
     503                SuperClassWriter::addAttribute("longname_name", StdString("Latitude of mesh nodes."), &node_y); 
     504                SuperClassWriter::addAttribute("units", StdString("degrees_north"), &node_y); 
     505              } 
     506            } // domain->nvertex == 1 
     507 
     508            // Adding edges and nodes, if nodes have not been defined previously 
     509            if (domain->nvertex == 2) 
     510            { 
     511              // Nodes 
     512              if (!SuperClassWriter::varExist(node_x) || !SuperClassWriter::varExist(node_y)) 
     513              { 
     514                SuperClassWriter::addDimension(dimNode, domain->mesh->nbNodes); 
     515                dim0.clear(); 
     516                dim0.push_back(dimNode); 
     517                SuperClassWriter::addVariable(node_x, NC_FLOAT, dim0); 
     518                SuperClassWriter::addAttribute("standard_name", StdString("longitude"), &node_x); 
     519                SuperClassWriter::addAttribute("longname_name", StdString("Longitude of mesh nodes."), &node_x); 
     520                SuperClassWriter::addAttribute("units", StdString("degrees_east"), &node_x); 
     521                SuperClassWriter::addVariable(node_y, NC_FLOAT, dim0); 
     522                SuperClassWriter::addAttribute("standard_name", StdString("latitude"), &node_y); 
     523                SuperClassWriter::addAttribute("longname_name", StdString("Latitude of mesh nodes."), &node_y); 
     524                SuperClassWriter::addAttribute("units", StdString("degrees_north"), &node_y); 
     525              } 
     526              // Edges 
     527              if (!SuperClassWriter::varExist(edge_x) || !SuperClassWriter::varExist(edge_y)) 
     528              { 
     529                SuperClassWriter::addAttribute("edge_node_connectivity", edge_nodes, &domainName); 
     530                SuperClassWriter::addAttribute("edge_coordinates", edge_x + " " + edge_y, &domainName); 
     531                SuperClassWriter::addDimension(dimEdge, domain->mesh->nbEdges); 
     532                dim0.clear(); 
     533                dim0.push_back(dimEdge); 
     534                SuperClassWriter::addVariable(edge_x, NC_FLOAT, dim0); 
     535                SuperClassWriter::addAttribute("standard_name", StdString("longitude"), &edge_x); 
     536                SuperClassWriter::addAttribute("longname_name", StdString("Characteristic longitude of mesh edges."), &edge_x); 
     537                SuperClassWriter::addAttribute("units", StdString("degrees_east"), &edge_x); 
     538                SuperClassWriter::addVariable(edge_y, NC_FLOAT, dim0); 
     539                SuperClassWriter::addAttribute("standard_name", StdString("latitude"), &edge_y); 
     540                SuperClassWriter::addAttribute("longname_name", StdString("Characteristic latitude of mesh edges."), &edge_y); 
     541                SuperClassWriter::addAttribute("units", StdString("degrees_north"), &edge_y); 
     542                dim0.clear(); 
     543                dim0.push_back(dimEdge); 
     544                dim0.push_back(dimTwo); 
     545                SuperClassWriter::addVariable(edge_nodes, NC_INT, dim0); 
     546                SuperClassWriter::addAttribute("cf_role", StdString("edge_node_connectivity"), &edge_nodes); 
     547                SuperClassWriter::addAttribute("long_name", StdString("Maps every edge/link to two nodes that it connects."), &edge_nodes); 
     548                SuperClassWriter::addAttribute("start_index", 0, &edge_nodes); 
     549              } 
     550            } // domain->nvertex == 2 
     551 
     552            // Adding faces, edges, and nodes, if edges and nodes have not been defined previously 
     553            if (domain->nvertex > 2) 
     554            { 
     555              // Nodes 
     556              if (!SuperClassWriter::varExist(node_x) || !SuperClassWriter::varExist(node_y)) 
     557              { 
     558                SuperClassWriter::addDimension(dimNode, domain->mesh->nbNodes); 
     559                dim0.clear(); 
     560                dim0.push_back(dimNode); 
     561                SuperClassWriter::addVariable(node_x, NC_FLOAT, dim0); 
     562                SuperClassWriter::addAttribute("standard_name", StdString("longitude"), &node_x); 
     563                SuperClassWriter::addAttribute("longname_name", StdString("Longitude of mesh nodes."), &node_x); 
     564                SuperClassWriter::addAttribute("units", StdString("degrees_east"), &node_x); 
     565                SuperClassWriter::addVariable(node_y, NC_FLOAT, dim0); 
     566                SuperClassWriter::addAttribute("standard_name", StdString("latitude"), &node_y); 
     567                SuperClassWriter::addAttribute("longname_name", StdString("Latitude of mesh nodes."), &node_y); 
     568                SuperClassWriter::addAttribute("units", StdString("degrees_north"), &node_y); 
     569              } 
     570              // Edges 
     571              if (!SuperClassWriter::varExist(edge_x) || !SuperClassWriter::varExist(edge_y)) 
     572              { 
     573                SuperClassWriter::addAttribute("edge_coordinates", edge_x + " " + edge_y, &domainName); 
     574                SuperClassWriter::addAttribute("edge_node_connectivity", edge_nodes, &domainName); 
     575                SuperClassWriter::addDimension(dimEdge, domain->mesh->nbEdges); 
     576                dim0.clear(); 
     577                dim0.push_back(dimEdge); 
     578                SuperClassWriter::addVariable(edge_x, NC_FLOAT, dim0); 
     579                SuperClassWriter::addAttribute("standard_name", StdString("longitude"), &edge_x); 
     580                SuperClassWriter::addAttribute("longname_name", StdString("Characteristic longitude of mesh edges."), &edge_x); 
     581                SuperClassWriter::addAttribute("units", StdString("degrees_east"), &edge_x); 
     582                SuperClassWriter::addVariable(edge_y, NC_FLOAT, dim0); 
     583                SuperClassWriter::addAttribute("standard_name", StdString("latitude"), &edge_y); 
     584                SuperClassWriter::addAttribute("longname_name", StdString("Characteristic latitude of mesh edges."), &edge_y); 
     585                SuperClassWriter::addAttribute("units", StdString("degrees_north"), &edge_y); 
     586                dim0.clear(); 
     587                dim0.push_back(dimEdge); 
     588                dim0.push_back(dimTwo); 
     589                SuperClassWriter::addVariable(edge_nodes, NC_INT, dim0); 
     590                SuperClassWriter::addAttribute("cf_role", StdString("edge_node_connectivity"), &edge_nodes); 
     591                SuperClassWriter::addAttribute("long_name", StdString("Maps every edge/link to two nodes that it connects."), &edge_nodes); 
     592                SuperClassWriter::addAttribute("start_index", 0, &edge_nodes); 
     593              } 
     594              // Faces 
     595                SuperClassWriter::addAttribute("face_coordinates", face_x + " " + face_y, &domainName); 
     596                SuperClassWriter::addAttribute("face_node_connectivity", face_nodes, &domainName); 
     597                SuperClassWriter::addDimension(dimFace, domain->mesh->nbFaces); 
     598                SuperClassWriter::addDimension(dimVertex, domain->mesh->nvertex); 
     599                dim0.clear(); 
     600                dim0.push_back(dimFace); 
     601                SuperClassWriter::addVariable(face_x, NC_FLOAT, dim0); 
     602                SuperClassWriter::addAttribute("standard_name", StdString("longitude"), &face_x); 
     603                SuperClassWriter::addAttribute("longname_name", StdString("Characteristic longitude of mesh faces."), &face_x); 
     604                SuperClassWriter::addAttribute("units", StdString("degrees_east"), &face_x); 
     605                SuperClassWriter::addVariable(face_y, NC_FLOAT, dim0); 
     606                SuperClassWriter::addAttribute("standard_name", StdString("latitude"), &face_y); 
     607                SuperClassWriter::addAttribute("longname_name", StdString("Characteristic latitude of mesh faces."), &face_y); 
     608                SuperClassWriter::addAttribute("units", StdString("degrees_north"), &face_y); 
     609                dim0.clear(); 
     610                dim0.push_back(dimFace); 
     611                dim0.push_back(dimVertex); 
     612                SuperClassWriter::addVariable(face_nodes, NC_INT, dim0); 
     613                SuperClassWriter::addAttribute("cf_role", StdString("face_node_connectivity"), &face_nodes); 
     614                SuperClassWriter::addAttribute("long_name", StdString("Maps every face to its corner nodes."), &face_nodes); 
     615                SuperClassWriter::addAttribute("start_index", 0, &face_nodes); 
     616            } // domain->nvertex > 2 
     617 
     618            SuperClassWriter::definition_end(); 
     619 
     620            if (!isWrittenDomain(domid)) 
     621            { 
     622              if (domain->nvertex == 1) 
     623              { 
     624                SuperClassWriter::writeData(domain->mesh->node_lat, node_y, isCollective, 0); 
     625                SuperClassWriter::writeData(domain->mesh->node_lon, node_x, isCollective, 0); 
     626              } 
     627              else if (domain->nvertex == 2) 
    628628                            { 
    629                                                                 SuperClassWriter::writeData(domain->mesh->node_lat, node_y, isCollective, 0); 
    630                                                                 SuperClassWriter::writeData(domain->mesh->node_lon, node_x, isCollective, 0); 
    631                                                                 SuperClassWriter::writeData(domain->mesh->edge_lat, edge_y, isCollective, 0); 
    632                                                                 SuperClassWriter::writeData(domain->mesh->edge_lon, edge_x, isCollective, 0); 
    633                                                                 SuperClassWriter::writeData(domain->mesh->edge_nodes, edge_nodes); 
     629                SuperClassWriter::writeData(domain->mesh->node_lat, node_y, isCollective, 0); 
     630                SuperClassWriter::writeData(domain->mesh->node_lon, node_x, isCollective, 0); 
     631                SuperClassWriter::writeData(domain->mesh->edge_lat, edge_y, isCollective, 0); 
     632                SuperClassWriter::writeData(domain->mesh->edge_lon, edge_x, isCollective, 0); 
     633                SuperClassWriter::writeData(domain->mesh->edge_nodes, edge_nodes); 
    634634                            } 
    635                                                         else 
    636                                                         { 
    637                                                                 SuperClassWriter::writeData(domain->mesh->node_lat, node_y, isCollective, 0); 
    638                                                                 SuperClassWriter::writeData(domain->mesh->node_lon, node_x, isCollective, 0); 
    639                                                                 SuperClassWriter::writeData(domain->mesh->edge_lat, edge_y, isCollective, 0); 
    640                                                                 SuperClassWriter::writeData(domain->mesh->edge_lon, edge_x, isCollective, 0); 
    641                                                                 SuperClassWriter::writeData(domain->mesh->edge_nodes, edge_nodes); 
    642                                                                 SuperClassWriter::writeData(domain->mesh->face_lat, face_y, isCollective, 0); 
    643                                                                 SuperClassWriter::writeData(domain->mesh->face_lon, face_x, isCollective, 0); 
    644                                                                 SuperClassWriter::writeData(domain->mesh->face_nodes, face_nodes); 
    645                                                         } 
    646                                                         setWrittenDomain(domid); 
    647                                                 } // !isWrittenDomain 
    648                                                 else 
    649                                                 { 
    650                                                         if (domain->nvertex == 1) 
    651                                                         { 
     635              else 
     636              { 
     637                SuperClassWriter::writeData(domain->mesh->node_lat, node_y, isCollective, 0); 
     638                SuperClassWriter::writeData(domain->mesh->node_lon, node_x, isCollective, 0); 
     639                SuperClassWriter::writeData(domain->mesh->edge_lat, edge_y, isCollective, 0); 
     640                SuperClassWriter::writeData(domain->mesh->edge_lon, edge_x, isCollective, 0); 
     641                SuperClassWriter::writeData(domain->mesh->edge_nodes, edge_nodes); 
     642                SuperClassWriter::writeData(domain->mesh->face_lat, face_y, isCollective, 0); 
     643                SuperClassWriter::writeData(domain->mesh->face_lon, face_x, isCollective, 0); 
     644                SuperClassWriter::writeData(domain->mesh->face_nodes, face_nodes); 
     645              } 
     646              setWrittenDomain(domid); 
     647            } // !isWrittenDomain 
     648            else 
     649            { 
     650              if (domain->nvertex == 1) 
     651              { 
    652652                                if ( (!domain->mesh->edgesAreWritten) && (!domain->mesh->facesAreWritten) ) 
    653                                                                 { 
    654                                                                         SuperClassWriter::writeData(domain->mesh->node_lat, node_y, isCollective, 0); 
    655                                                                         SuperClassWriter::writeData(domain->mesh->node_lon, node_x, isCollective, 0); 
    656                                                                 } 
    657                                                         } 
    658                                                         if (domain->nvertex == 2) 
    659                                                         { 
     653                { 
     654                  SuperClassWriter::writeData(domain->mesh->node_lat, node_y, isCollective, 0); 
     655                  SuperClassWriter::writeData(domain->mesh->node_lon, node_x, isCollective, 0); 
     656                } 
     657              } 
     658              if (domain->nvertex == 2) 
     659              { 
    660660                                if (!domain->mesh->facesAreWritten) 
    661                                                                 { 
    662                                                                         if (!domain->mesh->nodesAreWritten) 
    663                                                                         { 
    664                                                                                 SuperClassWriter::writeData(domain->mesh->node_lat, node_y, isCollective, 0); 
    665                                                                                 SuperClassWriter::writeData(domain->mesh->node_lon, node_x, isCollective, 0); 
    666                                                                         } 
    667                                                                         SuperClassWriter::writeData(domain->mesh->edge_lat, edge_y, isCollective, 0); 
    668                                                                         SuperClassWriter::writeData(domain->mesh->edge_lon, edge_x, isCollective, 0); 
    669                                                                         SuperClassWriter::writeData(domain->mesh->edge_nodes, edge_nodes); 
    670                                                                 } 
    671                                                         }        
    672                                                         if (domain->nvertex > 2) 
    673                                                         { 
    674                                                                 if (!domain->mesh->edgesAreWritten) 
    675                                                                 { 
    676                                                                         if (!domain->mesh->nodesAreWritten) 
    677                                                                         { 
    678                                                                                 SuperClassWriter::writeData(domain->mesh->node_lat, node_y, isCollective, 0); 
    679                                                                                 SuperClassWriter::writeData(domain->mesh->node_lon, node_x, isCollective, 0); 
    680                                                                         } 
    681                                                                         SuperClassWriter::writeData(domain->mesh->edge_lat, edge_y, isCollective, 0); 
    682                                                                         SuperClassWriter::writeData(domain->mesh->edge_lon, edge_x, isCollective, 0); 
    683                                                                         SuperClassWriter::writeData(domain->mesh->edge_nodes, edge_nodes); 
    684                                                                 } 
    685                                                                 SuperClassWriter::writeData(domain->mesh->face_lat, face_y, isCollective, 0); 
    686                                                                 SuperClassWriter::writeData(domain->mesh->face_lon, face_x, isCollective, 0); 
    687                                                                 SuperClassWriter::writeData(domain->mesh->face_nodes, face_nodes); 
    688                                                         } 
    689                                                 }// isWrittenDomain 
    690  
    691                                                 SuperClassWriter::definition_start(); 
    692  
    693                                                 break; 
    694                                         } // ONE_FILE 
    695  
    696                                         case (MULTI_FILE) : 
    697                                         { 
    698                                                 break; 
    699                                         } 
    700  
    701                                         default : 
    702                                         ERROR("CNc4DataOutput::writeDomain(domain)", 
    703                                         << "[ type = " << SuperClass::type << "]" 
    704                                         << " not implemented yet !"); 
    705                                         } // switch 
    706                                 } // try 
    707  
    708                                 catch (CNetCdfException& e) 
    709                                 { 
    710                                         StdString msg("On writing the domain : "); 
    711                                         msg.append(domid); msg.append("\n"); 
    712                                         msg.append("In the context : "); 
    713                                         msg.append(context->getId()); msg.append("\n"); 
    714                                         msg.append(e.what()); 
    715                                         ERROR("CNc4DataOutput::writeUnstructuredDomain(CDomain* domain)", << msg); 
    716                                 } 
    717  
    718         domain->addRelFile(this->filename); 
    719         } 
    720  
    721           //-------------------------------------------------------------- 
    722  
    723           void CNc4DataOutput::writeUnstructuredDomain(CDomain* domain) 
     661                { 
     662                  if (!domain->mesh->nodesAreWritten) 
     663                  { 
     664                    SuperClassWriter::writeData(domain->mesh->node_lat, node_y, isCollective, 0); 
     665                    SuperClassWriter::writeData(domain->mesh->node_lon, node_x, isCollective, 0); 
     666                  } 
     667                  SuperClassWriter::writeData(domain->mesh->edge_lat, edge_y, isCollective, 0); 
     668                  SuperClassWriter::writeData(domain->mesh->edge_lon, edge_x, isCollective, 0); 
     669                  SuperClassWriter::writeData(domain->mesh->edge_nodes, edge_nodes); 
     670                } 
     671              }   
     672              if (domain->nvertex > 2) 
     673              { 
     674                if (!domain->mesh->edgesAreWritten) 
     675                { 
     676                  if (!domain->mesh->nodesAreWritten) 
     677                  { 
     678                    SuperClassWriter::writeData(domain->mesh->node_lat, node_y, isCollective, 0); 
     679                    SuperClassWriter::writeData(domain->mesh->node_lon, node_x, isCollective, 0); 
     680                  } 
     681                  SuperClassWriter::writeData(domain->mesh->edge_lat, edge_y, isCollective, 0); 
     682                  SuperClassWriter::writeData(domain->mesh->edge_lon, edge_x, isCollective, 0); 
     683                  SuperClassWriter::writeData(domain->mesh->edge_nodes, edge_nodes); 
     684                } 
     685                SuperClassWriter::writeData(domain->mesh->face_lat, face_y, isCollective, 0); 
     686                SuperClassWriter::writeData(domain->mesh->face_lon, face_x, isCollective, 0); 
     687                SuperClassWriter::writeData(domain->mesh->face_nodes, face_nodes); 
     688              } 
     689            }// isWrittenDomain 
     690 
     691            SuperClassWriter::definition_start(); 
     692 
     693            break; 
     694          } // ONE_FILE 
     695 
     696          case (MULTI_FILE) : 
     697          { 
     698            break; 
     699          } 
     700 
     701          default : 
     702          ERROR("CNc4DataOutput::writeDomain(domain)", 
     703          << "[ type = " << SuperClass::type << "]" 
     704          << " not implemented yet !"); 
     705          } // switch 
     706        } // try 
     707 
     708        catch (CNetCdfException& e) 
     709        { 
     710          StdString msg("On writing the domain : "); 
     711          msg.append(domid); msg.append("\n"); 
     712          msg.append("In the context : "); 
     713          msg.append(context->getId()); msg.append("\n"); 
     714          msg.append(e.what()); 
     715          ERROR("CNc4DataOutput::writeUnstructuredDomain(CDomain* domain)", << msg); 
     716        } 
     717 
     718  domain->addRelFile(this->filename); 
     719  } 
     720 
     721    //-------------------------------------------------------------- 
     722 
     723    void CNc4DataOutput::writeUnstructuredDomain(CDomain* domain) 
    724724      { 
    725725         CContext* context = CContext::getCurrent() ; 
     
    13151315               case CDomain::type_attr::unstructured: 
    13161316               { 
    1317                                    if (SuperClassWriter::useCFConvention) 
    1318                                    { 
    1319                                                 dimXid     = StdString("cell").append(appendDomId); 
    1320                                                 dimIdList.push_back(dimXid); 
    1321                                                 dimCoordList.push_back(StdString("lon").append(appendDomId)); 
    1322                                                 dimCoordList.push_back(StdString("lat").append(appendDomId)); 
    1323                                         } 
    1324                                    else 
    1325                                    { 
    1326                                                 StdString domainName = domain->name; 
    1327                                                 if (domain->nvertex == 1) 
    1328                                                 { 
    1329                                                         dimXid     = "n" + domainName + "_node"; 
    1330                                                         dimIdList.push_back(dimXid); 
    1331                                                         dimCoordList.push_back(StdString(domainName + "_node_x")); 
    1332                                                         dimCoordList.push_back(StdString(domainName + "_node_y")); 
    1333                                                 } 
    1334                                                 else if (domain->nvertex == 2) 
    1335                                                 { 
    1336                                                         dimXid     = "n" + domainName + "_edge"; 
    1337                                                         dimIdList.push_back(dimXid); 
    1338                                                         dimCoordList.push_back(StdString(domainName + "_edge_x")); 
    1339                                                         dimCoordList.push_back(StdString(domainName + "_edge_y")); 
    1340                                                 } 
    1341                                                 else 
    1342                                                 { 
    1343                                                         dimXid     = "n" + domainName + "_face"; 
    1344                                                         dimIdList.push_back(dimXid); 
    1345                                                         dimCoordList.push_back(StdString(domainName + "_face_x")); 
    1346                                                         dimCoordList.push_back(StdString(domainName + "_face_y")); 
    1347                                                 } 
    1348                                         }  // ugrid convention 
    1349                                 }  // case unstructured domain 
     1317           if (SuperClassWriter::useCFConvention) 
     1318           { 
     1319            dimXid     = StdString("cell").append(appendDomId); 
     1320            dimIdList.push_back(dimXid); 
     1321            dimCoordList.push_back(StdString("lon").append(appendDomId)); 
     1322            dimCoordList.push_back(StdString("lat").append(appendDomId)); 
     1323          } 
     1324           else 
     1325           { 
     1326            StdString domainName = domain->name; 
     1327            if (domain->nvertex == 1) 
     1328            { 
     1329              dimXid     = "n" + domainName + "_node"; 
     1330              dimIdList.push_back(dimXid); 
     1331              dimCoordList.push_back(StdString(domainName + "_node_x")); 
     1332              dimCoordList.push_back(StdString(domainName + "_node_y")); 
     1333            } 
     1334            else if (domain->nvertex == 2) 
     1335            { 
     1336              dimXid     = "n" + domainName + "_edge"; 
     1337              dimIdList.push_back(dimXid); 
     1338              dimCoordList.push_back(StdString(domainName + "_edge_x")); 
     1339              dimCoordList.push_back(StdString(domainName + "_edge_y")); 
     1340            } 
     1341            else 
     1342            { 
     1343              dimXid     = "n" + domainName + "_face"; 
     1344              dimIdList.push_back(dimXid); 
     1345              dimCoordList.push_back(StdString(domainName + "_face_x")); 
     1346              dimCoordList.push_back(StdString(domainName + "_face_y")); 
     1347            } 
     1348          }  // ugrid convention 
     1349        }  // case unstructured domain 
    13501350             } 
    13511351 
     
    15411541           ERROR("CNc4DataOutput::writeField_(CField* field)", << msg); 
    15421542         } 
    1543       } 
    1544  
    1545       //-------------------------------------------------------------- 
    1546 /* 
    1547       void CNc4DataOutput::writeField_(CField* field) 
    1548       { 
    1549          CContext* context = CContext::getCurrent() ; 
    1550          CContextServer* server=context->server ; 
    1551  
    1552          std::vector<StdString> dims, coodinates; 
    1553          CGrid* grid = field->grid; 
    1554          if (!grid->doGridHaveDataToWrite()) 
    1555           if (SuperClass::type==MULTI_FILE) return ; 
    1556  
    1557          CArray<bool,1> axisDomainOrder = grid->axis_domain_order; 
    1558          int numElement = axisDomainOrder.numElements(), idxDomain = 0, idxAxis = 0; 
    1559          std::vector<StdString> domainList = grid->getDomainList(); 
    1560          std::vector<StdString> axisList   = grid->getAxisList(); 
    1561  
    1562          StdString timeid  = getTimeCounterName(); 
    1563          StdString dimXid,dimYid; 
    1564          std::deque<StdString> dimIdList, dimCoordList; 
    1565          bool hasArea = false; 
    1566          StdString cellMeasures = "area:"; 
    1567          bool compressedOutput = !field->indexed_output.isEmpty() && field->indexed_output; 
    1568  
    1569          for (int i = 0; i < numElement; ++i) 
    1570          { 
    1571            if (axisDomainOrder(i)) 
    1572            { 
    1573              CDomain* domain = CDomain::get(domainList[idxDomain]); 
    1574              StdString domId = domain->getDomainOutputName(); 
    1575              StdString appendDomId  = singleDomain ? "" : "_" + domId ; 
    1576  
    1577              if (compressedOutput && domain->isCompressible() && domain->type != CDomain::type_attr::unstructured) 
    1578              { 
    1579                dimIdList.push_back(domId + "_points"); 
    1580                field->setUseCompressedOutput(); 
    1581              } 
    1582  
    1583              switch (domain->type) 
    1584              { 
    1585                case CDomain::type_attr::curvilinear: 
    1586                  if (!compressedOutput || !domain->isCompressible()) 
    1587                  { 
    1588                    dimXid     = StdString("x").append(appendDomId); 
    1589                    dimIdList.push_back(dimXid); 
    1590                    dimYid     = StdString("y").append(appendDomId); 
    1591                    dimIdList.push_back(dimYid); 
    1592                  } 
    1593                  dimCoordList.push_back(StdString("nav_lon").append(appendDomId)); 
    1594                  dimCoordList.push_back(StdString("nav_lat").append(appendDomId)); 
    1595                  break ; 
    1596                case CDomain::type_attr::rectilinear: 
    1597                  if (!compressedOutput || !domain->isCompressible()) 
    1598                  { 
    1599                    dimXid     = StdString("lon").append(appendDomId); 
    1600                    dimIdList.push_back(dimXid); 
    1601                    dimYid     = StdString("lat").append(appendDomId); 
    1602                    dimIdList.push_back(dimYid); 
    1603                  } 
    1604                  break ; 
    1605                case CDomain::type_attr::unstructured: 
    1606                  dimXid     = StdString("cell").append(appendDomId); 
    1607                  dimIdList.push_back(dimXid); 
    1608                  dimCoordList.push_back(StdString("lon").append(appendDomId)); 
    1609                  dimCoordList.push_back(StdString("lat").append(appendDomId)); 
    1610                  break ; 
    1611              } 
    1612              if (domain->hasArea) 
    1613              { 
    1614                hasArea = true; 
    1615                cellMeasures += " area" + appendDomId; 
    1616              } 
    1617              ++idxDomain; 
    1618            } 
    1619            else 
    1620            { 
    1621              CAxis* axis = CAxis::get(axisList[idxAxis]); 
    1622              StdString axisId = axis->getAxisOutputName(); 
    1623  
    1624              if (compressedOutput && axis->isCompressible()) 
    1625              { 
    1626                dimIdList.push_back(axisId + "_points"); 
    1627                field->setUseCompressedOutput(); 
    1628              } 
    1629              else 
    1630                dimIdList.push_back(axisId); 
    1631  
    1632              dimCoordList.push_back(axisId); 
    1633              ++idxAxis; 
    1634            } 
    1635          } 
    1636  
    1637  
    1638 //         StdString lonid_loc = (server->intraCommSize > 1) 
    1639 //                             ? StdString("lon").append(appendDomid).append("_local") 
    1640 //                             : lonid; 
    1641 //         StdString latid_loc = (server->intraCommSize > 1) 
    1642 //                             ? StdString("lat").append(appendDomid).append("_local") 
    1643 //                             : latid; 
    1644  
    1645          StdString fieldid = field->getFieldOutputName(); 
    1646  
    1647 //         unsigned int ssize = domain->zoom_ni_loc.getValue() * domain->zoom_nj_loc.getValue(); 
    1648 //         bool isCurvilinear = (domain->lonvalue.getValue()->size() == ssize); 
    1649 //          bool isCurvilinear = domain->isCurvilinear ; 
    1650  
    1651          nc_type type ; 
    1652          if (field->prec.isEmpty()) type =  NC_FLOAT ; 
    1653          else 
    1654          { 
    1655            if (field->prec==2) type = NC_SHORT ; 
    1656            else if (field->prec==4)  type =  NC_FLOAT ; 
    1657            else if (field->prec==8)   type =  NC_DOUBLE ; 
    1658          } 
    1659  
    1660          bool wtime   = !(!field->operation.isEmpty() && field->getOperationTimeType() == func::CFunctor::once); 
    1661  
    1662          if (wtime) 
    1663          { 
    1664  
    1665             //StdOStringStream oss; 
    1666            // oss << "time_" << field->operation.getValue() 
    1667            //     << "_" << field->getRelFile()->output_freq.getValue(); 
    1668           //oss 
    1669             if (field->getOperationTimeType() == func::CFunctor::instant) coodinates.push_back(string("time_instant")); 
    1670             else if (field->getOperationTimeType() == func::CFunctor::centered) coodinates.push_back(string("time_centered")); 
    1671             dims.push_back(timeid); 
    1672          } 
    1673  
    1674          if (compressedOutput && grid->isCompressible()) 
    1675          { 
    1676            dims.push_back(grid->getId() + "_points"); 
    1677            field->setUseCompressedOutput(); 
    1678          } 
    1679          else 
    1680          { 
    1681            while (!dimIdList.empty()) 
    1682            { 
    1683              dims.push_back(dimIdList.back()); 
    1684              dimIdList.pop_back(); 
    1685            } 
    1686          } 
    1687  
    1688          while (!dimCoordList.empty()) 
    1689          { 
    1690            coodinates.push_back(dimCoordList.back()); 
    1691            dimCoordList.pop_back(); 
    1692          } 
    1693  
    1694          try 
    1695          { 
    1696            SuperClassWriter::addVariable(fieldid, type, dims); 
    1697  
    1698            if (!field->standard_name.isEmpty()) 
    1699               SuperClassWriter::addAttribute 
    1700                  ("standard_name",  field->standard_name.getValue(), &fieldid); 
    1701  
    1702            if (!field->long_name.isEmpty()) 
    1703               SuperClassWriter::addAttribute 
    1704                  ("long_name", field->long_name.getValue(), &fieldid); 
    1705  
    1706            if (!field->unit.isEmpty()) 
    1707               SuperClassWriter::addAttribute 
    1708                  ("units", field->unit.getValue(), &fieldid); 
    1709  
    1710             if (!field->valid_min.isEmpty()) 
    1711               SuperClassWriter::addAttribute 
    1712                  ("valid_min", field->valid_min.getValue(), &fieldid); 
    1713  
    1714            if (!field->valid_max.isEmpty()) 
    1715               SuperClassWriter::addAttribute 
    1716                  ("valid_max", field->valid_max.getValue(), &fieldid); 
    1717  
    1718             if (!field->scale_factor.isEmpty()) 
    1719               SuperClassWriter::addAttribute 
    1720                  ("scale_factor", field->scale_factor.getValue(), &fieldid); 
    1721  
    1722              if (!field->add_offset.isEmpty()) 
    1723               SuperClassWriter::addAttribute 
    1724                  ("add_offset", field->add_offset.getValue(), &fieldid); 
    1725  
    1726            SuperClassWriter::addAttribute 
    1727                  ("online_operation", field->operation.getValue(), &fieldid); 
    1728  
    1729           // write child variables as attributes 
    1730  
    1731  
    1732            vector<CVariable*> listVars = field->getAllVariables() ; 
    1733            for (vector<CVariable*>::iterator it = listVars.begin() ;it != listVars.end(); it++) writeAttribute_(*it, fieldid) ; 
    1734  
    1735  
    1736            if (wtime) 
    1737            { 
    1738               CDuration freqOp = field->freq_op.getValue(); 
    1739               freqOp.solveTimeStep(*context->calendar); 
    1740               StdString freqOpStr = freqOp.toStringUDUnits(); 
    1741               SuperClassWriter::addAttribute("interval_operation", freqOpStr, &fieldid); 
    1742  
    1743               CDuration freqOut = field->getRelFile()->output_freq.getValue(); 
    1744               freqOut.solveTimeStep(*context->calendar); 
    1745               SuperClassWriter::addAttribute("interval_write", freqOut.toStringUDUnits(), &fieldid); 
    1746  
    1747               StdString cellMethods = "time: "; 
    1748               if (field->operation.getValue() == "instant") cellMethods += "point"; 
    1749               else if (field->operation.getValue() == "average") cellMethods += "mean"; 
    1750               else if (field->operation.getValue() == "accumulate") cellMethods += "sum"; 
    1751               else cellMethods += field->operation; 
    1752               if (freqOp.resolve(*context->calendar) != freqOut.resolve(*context->calendar)) 
    1753                 cellMethods += " (interval: " + freqOpStr + ")"; 
    1754               SuperClassWriter::addAttribute("cell_methods", cellMethods, &fieldid); 
    1755            } 
    1756  
    1757            if (hasArea) 
    1758              SuperClassWriter::addAttribute("cell_measures", cellMeasures, &fieldid); 
    1759  
    1760            if (!field->default_value.isEmpty()) 
    1761            { 
    1762               double default_value = field->default_value.getValue(); 
    1763               float fdefault_value = (float)default_value; 
    1764               if (type == NC_DOUBLE) 
    1765                  SuperClassWriter::setDefaultValue(fieldid, &default_value); 
    1766               else 
    1767                  SuperClassWriter::setDefaultValue(fieldid, &fdefault_value); 
    1768            } 
    1769            else 
    1770               SuperClassWriter::setDefaultValue(fieldid, (double*)NULL); 
    1771  
    1772             if (field->compression_level.isEmpty()) 
    1773               field->compression_level = field->file->compression_level.isEmpty() ? 0 : field->file->compression_level; 
    1774             SuperClassWriter::setCompressionLevel(fieldid, field->compression_level); 
    1775  
    1776            {  // Ecriture des coordonnes 
    1777  
    1778               StdString coordstr; //boost::algorithm::join(coodinates, " ") 
    1779               std::vector<StdString>::iterator 
    1780                  itc = coodinates.begin(), endc = coodinates.end(); 
    1781  
    1782               for (; itc!= endc; itc++) 
    1783               { 
    1784                  StdString & coord = *itc; 
    1785                  if (itc+1 != endc) 
    1786                        coordstr.append(coord).append(" "); 
    1787                  else  coordstr.append(coord); 
    1788               } 
    1789  
    1790               SuperClassWriter::addAttribute("coordinates", coordstr, &fieldid); 
    1791  
    1792            } 
    1793          } 
    1794          catch (CNetCdfException& e) 
    1795          { 
    1796            StdString msg("On writing field : "); 
    1797            msg.append(fieldid); msg.append("\n"); 
    1798            msg.append("In the context : "); 
    1799            msg.append(context->getId()); msg.append("\n"); 
    1800            msg.append(e.what()); 
    1801            ERROR("CNc4DataOutput::writeField_(CField* field)", << msg); 
    1802          } 
    1803       } 
    1804  
    1805 */ 
     1543      } // writeField_() 
     1544 
    18061545      //-------------------------------------------------------------- 
    18071546 
     
    18171556         try 
    18181557         { 
    1819                    if (SuperClassWriter::useCFConvention) 
     1558       if (SuperClassWriter::useCFConvention) 
    18201559             this->writeFileAttributes(filename, description, 
    18211560                                       StdString("CF-1.5"), 
Note: See TracChangeset for help on using the changeset viewer.