Changeset 1456


Ignore:
Timestamp:
03/12/18 18:40:28 (3 years ago)
Author:
ymipsl
Message:

Add compression for lon, lat and axis.
Activated only if file attribute compression_level>0.

YM

Location:
XIOS/dev/XIOS_DEV_CMIP6/src/io
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/XIOS_DEV_CMIP6/src/io/nc4_data_output.cpp

    r1446 r1456  
    2323      { 
    2424        SuperClass::type = MULTI_FILE; 
     25        compressionLevel= file->compression_level.isEmpty() ? 0 :file->compression_level ; 
    2526      } 
    2627 
     
    3637      { 
    3738        SuperClass::type = (multifile) ? MULTI_FILE : ONE_FILE; 
     39        compressionLevel= file->compression_level.isEmpty() ? 0 :file->compression_level ; 
    3840      } 
    3941 
     
    274276                   { 
    275277                     case CDomain::type_attr::curvilinear : 
    276                        SuperClassWriter::addVariable(latid, typePrec, dim0); 
    277                        SuperClassWriter::addVariable(lonid, typePrec, dim0); 
     278                       SuperClassWriter::addVariable(latid, typePrec, dim0, compressionLevel); 
     279                       SuperClassWriter::addVariable(lonid, typePrec, dim0, compressionLevel); 
    278280                       break ; 
    279281                      case CDomain::type_attr::rectilinear : 
    280                         SuperClassWriter::addVariable(latid, typePrec, dim0); 
    281                         SuperClassWriter::addVariable(lonid, typePrec, dim1); 
     282                        SuperClassWriter::addVariable(latid, typePrec, dim0, compressionLevel); 
     283                        SuperClassWriter::addVariable(lonid, typePrec, dim1, compressionLevel); 
    282284                        break ; 
    283285                   } 
     
    295297                     dim0.push_back(dimXid); 
    296298                     dim0.push_back(dimVertId); 
    297                      SuperClassWriter::addVariable(bounds_lonid, typePrec, dim0); 
    298                      SuperClassWriter::addVariable(bounds_latid, typePrec, dim0); 
     299                     SuperClassWriter::addVariable(bounds_lonid, typePrec, dim0, compressionLevel); 
     300                     SuperClassWriter::addVariable(bounds_latid, typePrec, dim0, compressionLevel); 
    299301                   } 
    300302                 } 
     
    321323                 if (domain->hasArea) 
    322324                 { 
    323                    SuperClassWriter::addVariable(areaId, typePrec, dim0); 
     325                   SuperClassWriter::addVariable(areaId, typePrec, dim0, compressionLevel); 
    324326                   SuperClassWriter::addAttribute("standard_name", StdString("cell_area"), &areaId); 
    325327                   SuperClassWriter::addAttribute("units", StdString("m2"), &areaId); 
     
    376378                       lonid = lonName+appendDomid; 
    377379                       latid = latName+appendDomid; 
    378                        SuperClassWriter::addVariable(latid, typePrec, dim0); 
    379                        SuperClassWriter::addVariable(lonid, typePrec, dim0); 
     380                       SuperClassWriter::addVariable(latid, typePrec, dim0, compressionLevel); 
     381                       SuperClassWriter::addVariable(lonid, typePrec, dim0, compressionLevel); 
    380382                       break; 
    381383 
     
    385387                       lonid = lonName+appendDomid; 
    386388                       latid = latName+appendDomid; 
    387                        SuperClassWriter::addVariable(latid, typePrec, dim0); 
    388                        SuperClassWriter::addVariable(lonid, typePrec, dim1); 
     389                       SuperClassWriter::addVariable(latid, typePrec, dim0, compressionLevel); 
     390                       SuperClassWriter::addVariable(lonid, typePrec, dim1, compressionLevel); 
    389391                       break; 
    390392                   } 
     
    408410                     dim0.push_back(dimXid); 
    409411                     dim0.push_back(dimVertId); 
    410                      SuperClassWriter::addVariable(bounds_lonid, typePrec, dim0); 
    411                      SuperClassWriter::addVariable(bounds_latid, typePrec, dim0); 
     412                     SuperClassWriter::addVariable(bounds_lonid, typePrec, dim0, compressionLevel); 
     413                     SuperClassWriter::addVariable(bounds_latid, typePrec, dim0, compressionLevel); 
    412414                   } 
    413415                 } 
     
    417419                   dim0.clear(); 
    418420                   dim0.push_back(dimYid); dim0.push_back(dimXid); 
    419                    SuperClassWriter::addVariable(areaId, typePrec, dim0); 
     421                   SuperClassWriter::addVariable(areaId, typePrec, dim0, compressionLevel); 
    420422                   SuperClassWriter::addAttribute("standard_name", StdString("cell_area"), &areaId); 
    421423                   SuperClassWriter::addAttribute("units", StdString("m2"), &areaId); 
     
    593595      { 
    594596        dim0.clear(); 
    595         SuperClassWriter::addVariable(domainName, NC_INT, dim0); 
     597        SuperClassWriter::addVariable(domainName, NC_INT, dim0, compressionLevel); 
    596598        SuperClassWriter::addAttribute("cf_role", StdString("mesh_topology"), &domainName); 
    597599        SuperClassWriter::addAttribute("long_name", StdString("Topology data of 2D unstructured mesh"), &domainName); 
     
    614616                dim0.clear(); 
    615617                dim0.push_back(dimNode); 
    616                 SuperClassWriter::addVariable(node_x, typePrec, dim0); 
     618                SuperClassWriter::addVariable(node_x, typePrec, dim0, compressionLevel); 
    617619                SuperClassWriter::addAttribute("standard_name", StdString("longitude"), &node_x); 
    618620                SuperClassWriter::addAttribute("long_name", StdString("Longitude of mesh nodes."), &node_x); 
    619621                SuperClassWriter::addAttribute("units", StdString("degrees_east"), &node_x); 
    620                 SuperClassWriter::addVariable(node_y, typePrec, dim0); 
     622                SuperClassWriter::addVariable(node_y, typePrec, dim0, compressionLevel); 
    621623                SuperClassWriter::addAttribute("standard_name", StdString("latitude"), &node_y); 
    622624                SuperClassWriter::addAttribute("long_name", StdString("Latitude of mesh nodes."), &node_y); 
     
    633635                dim0.clear(); 
    634636                dim0.push_back(dimNode); 
    635                 SuperClassWriter::addVariable(node_x, typePrec, dim0); 
     637                SuperClassWriter::addVariable(node_x, typePrec, dim0, compressionLevel); 
    636638                SuperClassWriter::addAttribute("standard_name", StdString("longitude"), &node_x); 
    637639                SuperClassWriter::addAttribute("long_name", StdString("Longitude of mesh nodes."), &node_x); 
    638640                SuperClassWriter::addAttribute("units", StdString("degrees_east"), &node_x); 
    639                 SuperClassWriter::addVariable(node_y, typePrec, dim0); 
     641                SuperClassWriter::addVariable(node_y, typePrec, dim0, compressionLevel); 
    640642                SuperClassWriter::addAttribute("standard_name", StdString("latitude"), &node_y); 
    641643                SuperClassWriter::addAttribute("long_name", StdString("Latitude of mesh nodes."), &node_y); 
     
    647649              dim0.clear(); 
    648650              dim0.push_back(dimEdge); 
    649               SuperClassWriter::addVariable(edge_x, typePrec, dim0); 
     651              SuperClassWriter::addVariable(edge_x, typePrec, dim0, compressionLevel); 
    650652              SuperClassWriter::addAttribute("standard_name", StdString("longitude"), &edge_x); 
    651653              SuperClassWriter::addAttribute("long_name", StdString("Characteristic longitude of mesh edges."), &edge_x); 
    652654              SuperClassWriter::addAttribute("units", StdString("degrees_east"), &edge_x); 
    653               SuperClassWriter::addVariable(edge_y, typePrec, dim0); 
     655              SuperClassWriter::addVariable(edge_y, typePrec, dim0, compressionLevel); 
    654656              SuperClassWriter::addAttribute("standard_name", StdString("latitude"), &edge_y); 
    655657              SuperClassWriter::addAttribute("long_name", StdString("Characteristic latitude of mesh edges."), &edge_y); 
     
    658660              dim0.push_back(dimEdge); 
    659661              dim0.push_back(dimTwo); 
    660               SuperClassWriter::addVariable(edge_nodes, NC_INT, dim0); 
     662              SuperClassWriter::addVariable(edge_nodes, NC_INT, dim0, compressionLevel); 
    661663              SuperClassWriter::addAttribute("cf_role", StdString("edge_node_connectivity"), &edge_nodes); 
    662664              SuperClassWriter::addAttribute("long_name", StdString("Maps every edge/link to two nodes that it connects."), &edge_nodes); 
     
    673675                dim0.clear(); 
    674676                dim0.push_back(dimNode); 
    675                 SuperClassWriter::addVariable(node_x, typePrec, dim0); 
     677                SuperClassWriter::addVariable(node_x, typePrec, dim0, compressionLevel); 
    676678                SuperClassWriter::addAttribute("standard_name", StdString("longitude"), &node_x); 
    677679                SuperClassWriter::addAttribute("long_name", StdString("Longitude of mesh nodes."), &node_x); 
    678680                SuperClassWriter::addAttribute("units", StdString("degrees_east"), &node_x); 
    679                 SuperClassWriter::addVariable(node_y, typePrec, dim0); 
     681                SuperClassWriter::addVariable(node_y, typePrec, dim0, compressionLevel); 
    680682                SuperClassWriter::addAttribute("standard_name", StdString("latitude"), &node_y); 
    681683                SuperClassWriter::addAttribute("long_name", StdString("Latitude of mesh nodes."), &node_y); 
     
    689691                dim0.clear(); 
    690692                dim0.push_back(dimEdge); 
    691                 SuperClassWriter::addVariable(edge_x, typePrec, dim0); 
     693                SuperClassWriter::addVariable(edge_x, typePrec, dim0, compressionLevel); 
    692694                SuperClassWriter::addAttribute("standard_name", StdString("longitude"), &edge_x); 
    693695                SuperClassWriter::addAttribute("long_name", StdString("Characteristic longitude of mesh edges."), &edge_x); 
    694696                SuperClassWriter::addAttribute("units", StdString("degrees_east"), &edge_x); 
    695                 SuperClassWriter::addVariable(edge_y, typePrec, dim0); 
     697                SuperClassWriter::addVariable(edge_y, typePrec, dim0, compressionLevel); 
    696698                SuperClassWriter::addAttribute("standard_name", StdString("latitude"), &edge_y); 
    697699                SuperClassWriter::addAttribute("long_name", StdString("Characteristic latitude of mesh edges."), &edge_y); 
     
    700702                dim0.push_back(dimEdge); 
    701703                dim0.push_back(dimTwo); 
    702                 SuperClassWriter::addVariable(edge_nodes, NC_INT, dim0); 
     704                SuperClassWriter::addVariable(edge_nodes, NC_INT, dim0, compressionLevel); 
    703705                SuperClassWriter::addAttribute("cf_role", StdString("edge_node_connectivity"), &edge_nodes); 
    704706                SuperClassWriter::addAttribute("long_name", StdString("Maps every edge/link to two nodes that it connects."), &edge_nodes); 
     
    711713              dim0.clear(); 
    712714              dim0.push_back(dimFace); 
    713               SuperClassWriter::addVariable(face_x, typePrec, dim0); 
     715              SuperClassWriter::addVariable(face_x, typePrec, dim0, compressionLevel); 
    714716              SuperClassWriter::addAttribute("standard_name", StdString("longitude"), &face_x); 
    715717              SuperClassWriter::addAttribute("long_name", StdString("Characteristic longitude of mesh faces."), &face_x); 
    716718              SuperClassWriter::addAttribute("units", StdString("degrees_east"), &face_x); 
    717               SuperClassWriter::addVariable(face_y, typePrec, dim0); 
     719              SuperClassWriter::addVariable(face_y, typePrec, dim0, compressionLevel); 
    718720              SuperClassWriter::addAttribute("standard_name", StdString("latitude"), &face_y); 
    719721              SuperClassWriter::addAttribute("long_name", StdString("Characteristic latitude of mesh faces."), &face_y); 
     
    722724              dim0.push_back(dimFace); 
    723725              dim0.push_back(dimVertex); 
    724               SuperClassWriter::addVariable(face_nodes, NC_INT, dim0); 
     726              SuperClassWriter::addVariable(face_nodes, NC_INT, dim0, compressionLevel); 
    725727              SuperClassWriter::addAttribute("cf_role", StdString("face_node_connectivity"), &face_nodes); 
    726728              SuperClassWriter::addAttribute("long_name", StdString("Maps every face to its corner nodes."), &face_nodes); 
     
    729731              dim0.push_back(dimFace); 
    730732              dim0.push_back(dimVertex); 
    731               SuperClassWriter::addVariable(face_edges, NC_INT, dim0); 
     733              SuperClassWriter::addVariable(face_edges, NC_INT, dim0, compressionLevel); 
    732734              SuperClassWriter::addAttribute("cf_role", StdString("face_edge_connectivity"), &face_edges); 
    733735              SuperClassWriter::addAttribute("long_name", StdString("Maps every face to its edges."), &face_edges); 
     
    737739              dim0.push_back(dimEdge); 
    738740              dim0.push_back(dimTwo); 
    739               SuperClassWriter::addVariable(edge_faces, NC_INT, dim0); 
     741              SuperClassWriter::addVariable(edge_faces, NC_INT, dim0, compressionLevel); 
    740742              SuperClassWriter::addAttribute("cf_role", StdString("edge_face connectivity"), &edge_faces); 
    741743              SuperClassWriter::addAttribute("long_name", StdString("neighbor faces for edges"), &edge_faces); 
     
    746748              dim0.push_back(dimFace); 
    747749              dim0.push_back(dimVertex); 
    748               SuperClassWriter::addVariable(face_faces, NC_INT, dim0); 
     750              SuperClassWriter::addVariable(face_faces, NC_INT, dim0, compressionLevel); 
    749751              SuperClassWriter::addAttribute("cf_role", StdString("face_face connectivity"), &face_faces); 
    750752              SuperClassWriter::addAttribute("long_name", StdString("Indicates which other faces neighbor each face"), &face_faces); 
     
    10731075                 if (domain->hasLonLat) 
    10741076                 { 
    1075                    SuperClassWriter::addVariable(latid, typePrec, dim0); 
    1076                    SuperClassWriter::addVariable(lonid, typePrec, dim0); 
     1077                   SuperClassWriter::addVariable(latid, typePrec, dim0, compressionLevel); 
     1078                   SuperClassWriter::addVariable(lonid, typePrec, dim0, compressionLevel); 
    10771079                   this->writeAxisAttributes(lonid, "", "longitude", "Longitude", "degrees_east", domid); 
    10781080                   if (domain->hasBounds) SuperClassWriter::addAttribute("bounds",bounds_lonid, &lonid); 
     
    10861088                   dim0.push_back(dimXid); 
    10871089                   dim0.push_back(dimVertId); 
    1088                    SuperClassWriter::addVariable(bounds_lonid, typePrec, dim0); 
    1089                    SuperClassWriter::addVariable(bounds_latid, typePrec, dim0); 
     1090                   SuperClassWriter::addVariable(bounds_lonid, typePrec, dim0, compressionLevel); 
     1091                   SuperClassWriter::addVariable(bounds_latid, typePrec, dim0, compressionLevel); 
    10901092                 } 
    10911093 
     
    10941096                 if (domain->hasArea) 
    10951097                 { 
    1096                    SuperClassWriter::addVariable(areaId, typePrec, dim0); 
     1098                   SuperClassWriter::addVariable(areaId, typePrec, dim0, compressionLevel); 
    10971099                   SuperClassWriter::addAttribute("standard_name", StdString("cell_area"), &areaId); 
    10981100                   SuperClassWriter::addAttribute("units", StdString("m2"), &areaId); 
     
    11321134                 if (domain->hasLonLat) 
    11331135                 { 
    1134                    SuperClassWriter::addVariable(latid, typePrec, dim0); 
    1135                    SuperClassWriter::addVariable(lonid, typePrec, dim0); 
     1136                   SuperClassWriter::addVariable(latid, typePrec, dim0, compressionLevel); 
     1137                   SuperClassWriter::addVariable(lonid, typePrec, dim0, compressionLevel); 
    11361138 
    11371139                   this->writeAxisAttributes(lonid, "", "longitude", "Longitude", "degrees_east", domid); 
     
    11471149                   dim0.push_back(dimXid); 
    11481150                   dim0.push_back(dimVertId); 
    1149                    SuperClassWriter::addVariable(bounds_lonid, typePrec, dim0); 
    1150                    SuperClassWriter::addVariable(bounds_latid, typePrec, dim0); 
     1151                   SuperClassWriter::addVariable(bounds_lonid, typePrec, dim0, compressionLevel); 
     1152                   SuperClassWriter::addVariable(bounds_latid, typePrec, dim0, compressionLevel); 
    11511153                 } 
    11521154 
     
    11551157                   dim0.clear(); 
    11561158                   dim0.push_back(dimXid); 
    1157                    SuperClassWriter::addVariable(areaId, typePrec, dim0); 
     1159                   SuperClassWriter::addVariable(areaId, typePrec, dim0, compressionLevel); 
    11581160                   SuperClassWriter::addAttribute("standard_name", StdString("cell_area"), &areaId); 
    11591161                   SuperClassWriter::addAttribute("units", StdString("m2"), &areaId); 
     
    12641266            if (!axis->label.isEmpty()) dims.push_back(strId); 
    12651267 
    1266             SuperClassWriter::addVariable(axisid, typePrec, dims); 
     1268            SuperClassWriter::addVariable(axisid, typePrec, dims, compressionLevel); 
    12671269 
    12681270            if (!axis->name.isEmpty()) 
     
    13141316            { 
    13151317              dims.push_back("axis_nbounds"); 
    1316               SuperClassWriter::addVariable(axisBoundsId, typePrec, dims); 
     1318              SuperClassWriter::addVariable(axisBoundsId, typePrec, dims, compressionLevel); 
    13171319              SuperClassWriter::addAttribute("bounds", axisBoundsId, &axisid); 
    13181320 
  • XIOS/dev/XIOS_DEV_CMIP6/src/io/nc4_data_output.hpp

    r1158 r1456  
    4141            bool singleDomain ; 
    4242            bool isCollective ; 
     43            int compressionLevel ; 
    4344                       
    4445            CFile* file; 
  • XIOS/dev/XIOS_DEV_CMIP6/src/io/onetcdf4.cpp

    r1201 r1456  
    308308 
    309309      int CONetCDF4::addVariable(const StdString& name, nc_type type, 
    310                                  const std::vector<StdString>& dim) 
     310                                 const std::vector<StdString>& dim, int compressionLevel) 
    311311      { 
    312312         int varid = 0; 
     
    350350         } 
    351351 
     352         setCompressionLevel(name, compressionLevel) ; 
     353          
    352354         return varid; 
    353355      } 
  • XIOS/dev/XIOS_DEV_CMIP6/src/io/onetcdf4.hpp

    r1158 r1456  
    4949            int addDimension(const StdString& name, const StdSize size = UNLIMITED_DIM); 
    5050            int addVariable(const StdString& name, nc_type type, 
    51                             const std::vector<StdString>& dim); 
     51                            const std::vector<StdString>& dim, int compressionLevel=0); 
    5252 
    5353      //---------------------------------------------------------------- 
Note: See TracChangeset for help on using the changeset viewer.