Changeset 2530
- Timestamp:
- 07/19/23 09:07:54 (18 months ago)
- Location:
- XIOS3/branches/xios-3.0-beta
- Files:
-
- 1 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS3/branches/xios-3.0-beta/make_xios
r2213 r2530 212 212 fi 213 213 214 215 # Detecting if parallel compression is available : 216 # - NetCDF is HDF5 based and >= 4.7.4 ? 217 # - HDF5 is parallel and >= 1.10.3 ? 218 USE_HDF5=0 219 if [[ ! -z $NETCDF_INCDIR ]] 220 then 221 NETCDF_LOOKUP=`echo ${NETCDF_INCDIR} | sed 's/\-I/\ /g'` 222 netcdf_meta_file=`find $NETCDF_LOOKUP -name netcdf_meta.h 2> /dev/null` 223 else 224 for dir in `echo $CPATH | sed 's/\:/\ /g'` ; do 225 if [ -f "$dir/netcdf_meta.h" ] 226 then 227 netcdf_meta_file=$dir/netcdf_meta.h 228 break 229 fi 230 done 231 fi 232 if [[ ! -z $netcdf_meta_file ]] 233 then 234 NC_MAJOR=`grep "NC_VERSION_MAJOR" $netcdf_meta_file | awk '{ print $3 }'` 235 NC_MINOR=`grep "NC_VERSION_MINOR" $netcdf_meta_file | awk '{ print $3 }'` 236 NC_PATCH=`grep "NC_VERSION_PATCH" $netcdf_meta_file | awk '{ print $3 }'` 237 if ( [[ "$NC_MAJOR" -ge 5 || ( "$NC_MAJOR" -eq 4 && "$NC_MINOR" -ge 8 )|| ( "$NC_MAJOR" -eq 4 && "$NC_MINOR" -eq 7 && "$NC_PATCH" -ge 4 ) ]] ) 238 then 239 USE_HDF5=`grep NC_HAS_HDF5 $netcdf_meta_file | awk '{ print $3 }'` 240 fi 241 fi 242 243 if [ "$USE_HDF5" == "1" ] 244 then 245 # https://forum.hdfgroup.org/t/parallel-compression-support-detection/5398 246 if [[ ! -z $HDF5_LIBDIR ]] 247 then 248 HDF5_LOOKUP=`echo ${HDF5_LIBDIR} | sed 's/\-L/\ /g'` 249 hdf5_settings_file=`find $HDF5_LOOKUP -name libhdf5.settings 2> /dev/null` 250 else 251 for dir in `echo $LD_LIBRARY_PATH | sed 's/\:/\ /g'` ; do 252 if [ -f "$dir/libhdf5.settings" ] 253 then 254 hdf5_settings_file=$dir/libhdf5.settings 255 break 256 fi 257 done 258 fi 259 HDF5_VERSION=`grep "HDF5 Version" $hdf5_settings_file | awk -F ':' '{ print $2 }'` 260 HDF5_MAJOR_VERSION=`echo $HDF5_VERSION | awk -F '.' '{ print $2 }'` 261 HDF5_MINOR_VERSION=`echo $HDF5_VERSION | awk -F '.' '{ print $3 }'` 262 HDF5_PARALLEL=`grep "Parallel HDF5" $hdf5_settings_file | awk -F ':' '{ print $2 }'` 263 HDF5_DEFLATE=`grep "I/O filters (external)" $hdf5_settings_file | awk -F ':' '{ print $2 }'` 264 if ( [[ "$HDF5_MAJOR_VERSION" -ge 11 || ( "$HDF5_MAJOR_VERSION" -eq 10 && "$HDF5_MINOR_VERSION" -ge 3 ) ]] ) 265 then 266 if [[ "$HDF5_PARALLEL" =~ "yes" && "$HDF5_DEFLATE" =~ "zlib" ]] 267 then 268 XIOS_CPPKEY="$XIOS_CPPKEY PARALLEL_COMPRESSION" 269 fi 270 fi 271 fi 272 if [[ "$XIOS_CPPKEY" =~ "PARALLEL_COMPRESSION" ]] 273 then 274 echo "->Parallel compression is available" 275 else 276 echo "->Parallel compression is NOT available" 277 fi 278 # End "Detecting if parallel compression is available" 279 280 214 281 # Setting path for boost 215 282 if [[ "$use_extern_boost" == "true" ]] -
XIOS3/branches/xios-3.0-beta/src/config/field_attribute.conf
r2478 r2530 33 33 DECLARE_ATTRIBUTE(double, scale_factor) 34 34 35 DECLARE_ATTRIBUTE(StdString, compression_type) 35 36 DECLARE_ATTRIBUTE(int, compression_level) 37 DECLARE_ARRAY(double , 1, compression_params) 36 38 DECLARE_ATTRIBUTE(double, chunking_blocksize_target) 37 39 -
XIOS3/branches/xios-3.0-beta/src/io/nc4_data_output.cpp
r2516 r2530 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/branches/xios-3.0-beta/src/io/netCdfInterface.cpp
r2427 r2530 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/branches/xios-3.0-beta/src/io/netCdfInterface.hpp
r1639 r2530 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/branches/xios-3.0-beta/src/io/onetcdf4.cpp
r2480 r2530 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/branches/xios-3.0-beta/src/io/onetcdf4.hpp
r2480 r2530 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.