Changeset 606
- Timestamp:
- 06/03/15 15:06:25 (10 years ago)
- Location:
- XIOS
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/branchs/xios-1.0/src/config/field_attribute.conf
r501 r606 24 24 DECLARE_ATTRIBUTE(double, add_offset) 25 25 DECLARE_ATTRIBUTE(double, scale_factor) 26 27 DECLARE_ATTRIBUTE(int, compression_level) -
XIOS/branchs/xios-1.0/src/config/file_attribute.conf
r501 r606 14 14 DECLARE_ATTRIBUTE(StdString, par_access) 15 15 16 // DECLARE_ATTRIBUTE_DEF(bool, enabled, true)16 DECLARE_ATTRIBUTE(int, compression_level) -
XIOS/branchs/xios-1.0/src/output/nc4_data_output.cpp
r544 r606 736 736 SuperClassWriter::setDefaultValue(fieldid, default_value); 737 737 } 738 739 if (field->compression_level.isEmpty()) 740 field->compression_level = field->file->compression_level.isEmpty() ? 0 : field->file->compression_level; 741 if (field->compression_level < 0 || field->compression_level > 9) 742 ERROR("void CNc4DataOutput::writeField_(CField* field)", 743 "Invalid compression level, the value should range between 0 and 9."); 744 SuperClassWriter::setCompressionLevel(fieldid, field->compression_level); 738 745 739 746 { // Ecriture des coordonnées -
XIOS/branchs/xios-1.0/src/output/netCdfInterface.cpp
r578 r606 525 525 526 526 /*! 527 This function sets the compression level to the specified variable 528 \param [in] ncid Groud id (or file id) 529 \param [in] varId Id of the variable 530 \param [in] compressionLevel The compression level from 0 to 9 (0 disables the compression, 9 is the higher compression) 531 \return Status code 532 */ 533 int CNetCdfInterface::defVarDeflate(int ncid, int varId, int compressionLevel) 534 { 535 int status = nc_def_var_deflate(ncid, varId, false, (compressionLevel > 0), compressionLevel); 536 if (NC_NOERR != status) 537 { 538 StdString errormsg(nc_strerror(status)); 539 StdStringStream sstr; 540 541 sstr << "Error in calling function " << "nc_def_var_deflate(ncid, varId, false, (compressionLevel > 0), compressionLevel)" << std::endl; 542 sstr << errormsg << std::endl; 543 sstr << "Unable to set the compression level of the variable with id: " << varId 544 << " and compression level: " << compressionLevel << std::endl; 545 StdString e = sstr.str(); 546 throw CNetCdfException(e); 547 } 548 549 return status; 550 } 551 552 /*! 527 553 This function makes a request to netcdf with a ncid, to set the fill parameters for a variable, 528 554 given variable id and type of fill -
XIOS/branchs/xios-1.0/src/output/netCdfInterface.hpp
r524 r606 90 90 static int defVarChunking(int ncid, int varId, int storage, StdSize chunkSize[]); 91 91 92 //! Define variable compression level 93 static int defVarDeflate(int ncid, int varId, int compressionLevel); 94 92 95 //! Define variable fill parameters 93 96 static int defVarFill(int ncid, int varId, int noFill, void* fillValue); -
XIOS/branchs/xios-1.0/src/output/onetcdf4.cpp
r605 r606 288 288 //--------------------------------------------------------------- 289 289 290 void CONetCDF4::setCompressionLevel(const StdString& varname, int compressionLevel) 291 { 292 int grpid = this->getCurrentGroup(); 293 int varid = this->getVariable(varname); 294 CNetCdfInterface::defVarDeflate(grpid, varid, compressionLevel); 295 } 296 297 //--------------------------------------------------------------- 298 290 299 template <> 291 300 void CONetCDF4::addAttribute … … 414 423 { 415 424 sstart.push_back(record); 416 scount.push_back(1); 425 scount.push_back(1); 417 426 if ((start == NULL) && 418 427 (count == NULL)) i++; … … 421 430 422 431 for (;it != end; it++) 423 { 432 { 424 433 if ((start != NULL) && (count != NULL)) 425 434 { -
XIOS/branchs/xios-1.0/src/output/onetcdf4.hpp
r501 r606 46 46 int addVariable(const StdString & name, nc_type type, 47 47 const std::vector<StdString> & dim); 48 48 49 49 //---------------------------------------------------------------- 50 50 public : 51 51 52 52 template <class T> 53 53 void setDefaultValue(const StdString & varname, const T * value = NULL); 54 54 55 void setCompressionLevel(const StdString& varname, int compressionLevel); 56 55 57 template <class T> void addAttribute (const StdString & name, const T & value, const StdString * varname = NULL); 56 58 … … 62 64 const std::vector<StdSize> * count = NULL); 63 65 64 void writeData(const CArray<int, 2>& data, const StdString & name); 66 void writeData(const CArray<int, 2>& data, const StdString & name); 65 67 void writeTimeAxisData(const CArray<double,1>& data, const StdString & name, 66 68 bool collective, StdSize record, bool Isroot) ; … … 70 72 /// Destructeur /// 71 73 virtual ~CONetCDF4(void); 72 74 73 75 //---------------------------------------------------------------- 74 76 75 77 protected : 76 78 … … 93 95 94 96 //---------------------------------------------------------------- 95 97 96 98 private : 97 99 98 100 template <class T> 99 101 void writeData_(int grpid, int varid, … … 118 120 119 121 ///--------------------------------------------------------------- 120 122 121 123 122 124 -
XIOS/trunk/src/config/field_attribute.conf
r593 r606 25 25 DECLARE_ATTRIBUTE(double, add_offset) 26 26 DECLARE_ATTRIBUTE(double, scale_factor) 27 28 DECLARE_ATTRIBUTE(int, compression_level) -
XIOS/trunk/src/config/file_attribute.conf
r598 r606 17 17 DECLARE_ENUM2(mode, read, write) 18 18 19 // DECLARE_ATTRIBUTE_DEF(bool, enabled, true)19 DECLARE_ATTRIBUTE(int, compression_level) -
XIOS/trunk/src/output/nc4_data_output.cpp
r586 r606 756 756 SuperClassWriter::setDefaultValue(fieldid, (double*)NULL); 757 757 758 if (field->compression_level.isEmpty()) 759 field->compression_level = field->file->compression_level.isEmpty() ? 0 : field->file->compression_level; 760 if (field->compression_level < 0 || field->compression_level > 9) 761 ERROR("void CNc4DataOutput::writeField_(CField* field)", 762 "Invalid compression level, the value should range between 0 and 9."); 763 SuperClassWriter::setCompressionLevel(fieldid, field->compression_level); 764 758 765 { // Ecriture des coordonnées 759 766 -
XIOS/trunk/src/output/netCdfInterface.cpp
r578 r606 525 525 526 526 /*! 527 This function sets the compression level to the specified variable 528 \param [in] ncid Groud id (or file id) 529 \param [in] varId Id of the variable 530 \param [in] compressionLevel The compression level from 0 to 9 (0 disables the compression, 9 is the higher compression) 531 \return Status code 532 */ 533 int CNetCdfInterface::defVarDeflate(int ncid, int varId, int compressionLevel) 534 { 535 int status = nc_def_var_deflate(ncid, varId, false, (compressionLevel > 0), compressionLevel); 536 if (NC_NOERR != status) 537 { 538 StdString errormsg(nc_strerror(status)); 539 StdStringStream sstr; 540 541 sstr << "Error in calling function " << "nc_def_var_deflate(ncid, varId, false, (compressionLevel > 0), compressionLevel)" << std::endl; 542 sstr << errormsg << std::endl; 543 sstr << "Unable to set the compression level of the variable with id: " << varId 544 << " and compression level: " << compressionLevel << std::endl; 545 StdString e = sstr.str(); 546 throw CNetCdfException(e); 547 } 548 549 return status; 550 } 551 552 /*! 527 553 Set or unset the fill mode for a NetCDF file specified by its file id. 528 554 \param [in] ncid File id -
XIOS/trunk/src/output/netCdfInterface.hpp
r591 r606 90 90 static int defVarChunking(int ncid, int varId, int storage, StdSize chunkSize[]); 91 91 92 //! Define variable compression level 93 static int defVarDeflate(int ncid, int varId, int compressionLevel); 94 92 95 //! Set or unset the fill mode 93 96 static int setFill(int ncid, bool fill); -
XIOS/trunk/src/output/onetcdf4.cpp
r605 r606 84 84 // This is done per variable for the NetCDF4 format. 85 85 if (useClassicFormat) 86 CNetCdfInterface::setFill(this->ncidp, false); 86 CNetCdfInterface::setFill(this->ncidp, false); 87 87 } 88 88 … … 277 277 278 278 int CONetCDF4::addVariable(const StdString & name, nc_type type, 279 279 const std::vector<StdString> & dim) 280 280 { 281 281 int varid = 0; 282 282 std::vector<int> dimids; 283 std::vector<StdSize> dimsizes ; 284 StdSize size ; 285 StdSize totalSize ; 286 StdSize maxSize=1024*1024*256 ; // == 2GB/8 if output double 287 288 int grpid = this->getCurrentGroup(); 289 290 std::vector<StdString>::const_iterator 291 it = dim.begin(), end = dim.end(); 292 293 for (;it != end; it++) 283 std::vector<StdSize> dimsizes; 284 StdSize size; 285 StdSize totalSize; 286 StdSize maxSize = 1024 * 1024 * 256; // == 2GB/8 if output double 287 288 int grpid = this->getCurrentGroup(); 289 290 std::vector<StdString>::const_iterator it = dim.begin(), end = dim.end(); 291 292 for (; it != end; it++) 294 293 { 295 294 const StdString & dimid = *it; 296 295 dimids.push_back(this->getDimension(dimid)); 297 (CNetCdfInterface::inqDimLen(grpid, this->getDimension(dimid), size));298 if (size ==NC_UNLIMITED) size=1;299 dimsizes.push_back(size) 300 } 301 302 CNetCdfInterface::defVar(grpid, name, type, dimids.size(), & (dimids[0]), varid);296 CNetCdfInterface::inqDimLen(grpid, this->getDimension(dimid), size); 297 if (size == NC_UNLIMITED) size = 1; 298 dimsizes.push_back(size); 299 } 300 301 CNetCdfInterface::defVar(grpid, name, type, dimids.size(), &dimids[0], varid); 303 302 304 303 // The classic NetCDF format does not support chunking nor fill parameters … … 318 317 } 319 318 320 return (varid); 319 return varid; 320 } 321 322 //--------------------------------------------------------------- 323 324 void CONetCDF4::setCompressionLevel(const StdString& varname, int compressionLevel) 325 { 326 int grpid = this->getCurrentGroup(); 327 int varid = this->getVariable(varname); 328 CNetCdfInterface::defVarDeflate(grpid, varid, compressionLevel); 321 329 } 322 330 … … 449 457 { 450 458 sstart.push_back(record + recordOffset); 451 scount.push_back(1); 459 scount.push_back(1); 452 460 if ((start == NULL) && 453 461 (count == NULL)) i++; … … 456 464 457 465 for (;it != end; it++) 458 { 466 { 459 467 if ((start != NULL) && (count != NULL)) 460 468 { -
XIOS/trunk/src/output/onetcdf4.hpp
r599 r606 48 48 int addVariable(const StdString & name, nc_type type, 49 49 const std::vector<StdString> & dim); 50 50 51 51 //---------------------------------------------------------------- 52 52 public : 53 53 54 54 template <class T> 55 55 void setDefaultValue(const StdString & varname, const T * value = NULL); 56 56 57 void setCompressionLevel(const StdString& varname, int compressionLevel); 58 57 59 template <class T> void addAttribute (const StdString & name, const T & value, const StdString * varname = NULL); 58 60 … … 64 66 const std::vector<StdSize> * count = NULL); 65 67 66 void writeData(const CArray<int, 2>& data, const StdString & name); 68 void writeData(const CArray<int, 2>& data, const StdString & name); 67 69 void writeTimeAxisData(const CArray<double,1>& data, const StdString & name, 68 70 bool collective, StdSize record, bool Isroot) ; … … 72 74 /// Destructeur /// 73 75 virtual ~CONetCDF4(void); 74 76 75 77 //---------------------------------------------------------------- 76 78 77 79 protected : 78 80 … … 97 99 98 100 //---------------------------------------------------------------- 99 101 100 102 private : 101 103 102 104 template <class T> 103 105 void writeData_(int grpid, int varid, … … 125 127 126 128 ///--------------------------------------------------------------- 127 129 128 130 129 131
Note: See TracChangeset
for help on using the changeset viewer.