Changeset 2529 for XIOS3/trunk/src/io
- Timestamp:
- 07/18/23 15:12:50 (12 months ago)
- Location:
- XIOS3/trunk/src/io
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS3/trunk/src/io/nc4_data_output.cpp
r2507 r2529 1948 1948 if (field->compression_level.isEmpty()) 1949 1949 field->compression_level = field->getRelFile()->compression_level.isEmpty() ? 0 : field->getRelFile()->compression_level; 1950 SuperClassWriter::setCompressionLevel(fieldid, field->compression_level); 1950 else 1951 field->compression_type.setValue( "gzip" ); 1952 if (field->compression_type.isEmpty()) 1953 field->compression_type = "None"; 1954 if (field->compression_params.isEmpty()) 1955 field->compression_params.resize( 0 ); 1956 SuperClassWriter::setCompressionLevel(fieldid, field->compression_type, field->compression_level, field->compression_params); 1951 1957 1952 1958 { // Ecriture des coordonnes -
XIOS3/trunk/src/io/netCdfInterface.cpp
r2426 r2529 11 11 #include "netCdfException.hpp" 12 12 #include "mem_checker.hpp" 13 #include <string> 14 #include <sys/stat.h> 13 15 14 16 namespace xios … … 776 778 throw CNetCdfException(e); 777 779 } 778 780 781 return status; 782 } 783 784 int CNetCdfInterface::defVarFilter(int ncid, int varId, unsigned int filterId , size_t filterNbrParams, unsigned int* filterParams) 785 { 786 const char* cplugin = getenv("HDF5_PLUGIN_PATH") ; 787 bool filterAvailable( false ); 788 789 StdString pluginLibName; 790 if ( filterId == 32017 ) // 32017 = SZ 791 { 792 pluginLibName = "libhdf5sz.so"; 793 } 794 if (cplugin) 795 { 796 string plugin( cplugin ); 797 string libsz( plugin+"/"+pluginLibName ); 798 struct stat sb; 799 if (stat(libsz.c_str(), &sb) == 0) filterAvailable = true; 800 } 801 if (!filterAvailable) 802 { 803 StdStringStream sstr; 804 sstr << "Error when calling function nc_def_var_filter(...)" << std::endl; 805 sstr << "The SZ filter required for " << varId << " is not available." 806 << "Check that $HDF5_PLUGIN_PATH/"<< pluginLibName <<" exists." ; 807 StdString e = sstr.str(); 808 throw CNetCdfException(e); 809 } 810 811 int status = nc_def_var_filter(ncid, varId, filterId, filterNbrParams, filterParams); 812 if (NC_NOERR != status) 813 { 814 StdString errormsg(nc_strerror(status)); 815 StdStringStream sstr; 816 817 sstr << "Error when calling function nc_def_var_filter(...)" << std::endl; 818 sstr << errormsg << std::endl; 819 sstr << "Unable to set the compression filter of the variable with id: " << varId 820 << " and plugin: " << filterId << std::endl; 821 StdString e = sstr.str(); 822 throw CNetCdfException(e); 823 } 824 779 825 return status; 780 826 } -
XIOS3/trunk/src/io/netCdfInterface.hpp
r1639 r2529 116 116 static int defVarDeflate(int ncid, int varId, int compressionLevel); 117 117 118 //! Define variable filter 119 static int defVarFilter(int ncid, int varId, unsigned int filterId , size_t filterNbrParams, unsigned int* filterParams ); 120 118 121 //! Set or unset the fill mode 119 122 static int setFill(int ncid, bool fill); … … 121 124 //! Define variable fill parameters 122 125 static int defVarFill(int ncid, int varId, int noFill, void* fillValue); 123 124 126 125 127 //! Change access type of a variable -
XIOS3/trunk/src/io/onetcdf4.cpp
r2481 r2529 2 2 3 3 #include "onetcdf4.hpp" 4 #include "onetcdf4_plugin.hpp" 4 5 #include "group_template.hpp" 5 6 #include "mpi.hpp" … … 505 506 CNetCdfInterface::defVarFill(grpid, varid, true, NULL); 506 507 } 507 508 setCompressionLevel(name, compressionLevel) ;509 508 510 509 return varid; … … 513 512 //--------------------------------------------------------------- 514 513 515 void CONetCDF4::setCompressionLevel(const StdString& varname, int compressionLevel)514 void CONetCDF4::setCompressionLevel(const StdString& varname, const StdString& compressionType, int compressionLevel, const CArray<double,1>& compressionParams) 516 515 { 517 516 if (compressionLevel < 0 || compressionLevel > 9) 518 517 ERROR("void CONetCDF4::setCompressionLevel(const StdString& varname, int compressionLevel)", 519 518 "Invalid compression level for variable \"" << varname << "\", the value should range between 0 and 9."); 520 if (compressionLevel && wmpi) 519 #ifndef PARALLEL_COMPRESSION 520 if ( ((compressionLevel)||(compressionParams.numElements())) && wmpi) 521 521 ERROR("void CONetCDF4::setCompressionLevel(const StdString& varname, int compressionLevel)", 522 522 "Impossible to use compression for variable \"" << varname << "\" when using parallel mode."); 523 #endif 523 524 int grpid = this->getCurrentGroup(); 524 525 int varid = this->getVariable(varname); 525 CNetCdfInterface::defVarDeflate(grpid, varid, compressionLevel); 526 if (compressionType=="None") 527 { 528 } 529 else if (compressionType=="gzip") 530 { 531 CNetCdfInterface::defVarDeflate(grpid, varid, compressionLevel); 532 } 533 else 534 { 535 size_t cd_nelmts; 536 unsigned int* cd_values = NULL; 537 if (compressionType=="SZ") 538 { 539 CONetCDF4Plugin::interpretParametersSZ(compressionParams, &cd_nelmts, &cd_values); 540 CNetCdfInterface::defVarFilter(grpid, varid, 32017, cd_nelmts, cd_values); 541 } 542 else 543 { 544 ERROR("void CONetCDF4::setCompressionLevel(...)", "compression_type = " << compressionType << " is not managed"); 545 } 546 if (cd_values!=NULL) delete [] cd_values; 547 } 548 526 549 } 527 550 -
XIOS3/trunk/src/io/onetcdf4.hpp
r2481 r2529 59 59 void setDefaultValue(const StdString& varname, const T* value = NULL); 60 60 61 void setCompressionLevel(const StdString& varname, int compressionLevel); 61 void setCompressionLevel(const StdString& varname, const StdString& compressionType, int compressionLevel, 62 const CArray<double,1>& compressionParam ); 62 63 63 64 template <class T> void addAttribute (const StdString& name, const T& value, const StdString* varname = NULL);
Note: See TracChangeset
for help on using the changeset viewer.