Index: XIOS3/trunk/src/config/field_attribute.conf
===================================================================
--- XIOS3/trunk/src/config/field_attribute.conf	(revision 2528)
+++ XIOS3/trunk/src/config/field_attribute.conf	(revision 2529)
@@ -33,5 +33,7 @@
 DECLARE_ATTRIBUTE(double,    scale_factor)
 
+DECLARE_ATTRIBUTE(StdString, compression_type)
 DECLARE_ATTRIBUTE(int,       compression_level)
+DECLARE_ARRAY(double , 1,    compression_params)
 DECLARE_ATTRIBUTE(double,    chunking_blocksize_target)
 
Index: XIOS3/trunk/src/io/nc4_data_output.cpp
===================================================================
--- XIOS3/trunk/src/io/nc4_data_output.cpp	(revision 2528)
+++ XIOS3/trunk/src/io/nc4_data_output.cpp	(revision 2529)
@@ -1948,5 +1948,11 @@
             if (field->compression_level.isEmpty())
               field->compression_level = field->getRelFile()->compression_level.isEmpty() ? 0 : field->getRelFile()->compression_level;
-            SuperClassWriter::setCompressionLevel(fieldid, field->compression_level);
+            else
+              field->compression_type.setValue( "gzip" );
+            if (field->compression_type.isEmpty())
+              field->compression_type = "None";
+            if (field->compression_params.isEmpty())
+              field->compression_params.resize( 0 );
+            SuperClassWriter::setCompressionLevel(fieldid, field->compression_type, field->compression_level, field->compression_params);
 
            {  // Ecriture des coordonnes
Index: XIOS3/trunk/src/io/netCdfInterface.cpp
===================================================================
--- XIOS3/trunk/src/io/netCdfInterface.cpp	(revision 2528)
+++ XIOS3/trunk/src/io/netCdfInterface.cpp	(revision 2529)
@@ -11,4 +11,6 @@
 #include "netCdfException.hpp"
 #include "mem_checker.hpp"
+#include <string>
+#include <sys/stat.h>
 
 namespace xios
@@ -776,5 +778,49 @@
     throw CNetCdfException(e);
   }
-
+  
+  return status;
+}
+
+int CNetCdfInterface::defVarFilter(int ncid, int varId, unsigned int filterId , size_t filterNbrParams, unsigned int* filterParams)
+{
+  const char* cplugin = getenv("HDF5_PLUGIN_PATH") ;
+  bool filterAvailable( false );
+  
+  StdString pluginLibName;
+  if ( filterId == 32017 ) // 32017 = SZ
+  {
+    pluginLibName = "libhdf5sz.so";
+  }
+  if (cplugin)
+  {
+    string plugin( cplugin );
+    string libsz( plugin+"/"+pluginLibName );
+    struct stat sb;
+    if (stat(libsz.c_str(), &sb) == 0) filterAvailable = true;
+  }
+  if (!filterAvailable)
+  {
+    StdStringStream sstr;
+    sstr << "Error when calling function nc_def_var_filter(...)" << std::endl;
+    sstr << "The SZ filter required for " << varId << " is not available."
+         << "Check that $HDF5_PLUGIN_PATH/"<< pluginLibName <<" exists." ;
+    StdString e = sstr.str();
+    throw CNetCdfException(e);
+  }
+ 
+  int status = nc_def_var_filter(ncid, varId, filterId, filterNbrParams, filterParams);
+  if (NC_NOERR != status)
+  {
+    StdString errormsg(nc_strerror(status));
+    StdStringStream sstr;
+    
+    sstr << "Error when calling function nc_def_var_filter(...)" << std::endl;
+    sstr << errormsg << std::endl;
+    sstr << "Unable to set the compression filter of the variable with id: " << varId
+         << " and plugin: " << filterId << std::endl;
+    StdString e = sstr.str();
+    throw CNetCdfException(e);
+  }
+  
   return status;
 }
Index: XIOS3/trunk/src/io/netCdfInterface.hpp
===================================================================
--- XIOS3/trunk/src/io/netCdfInterface.hpp	(revision 2528)
+++ XIOS3/trunk/src/io/netCdfInterface.hpp	(revision 2529)
@@ -116,4 +116,7 @@
     static int defVarDeflate(int ncid, int varId, int compressionLevel);
 
+    //! Define variable filter
+    static int defVarFilter(int ncid, int varId, unsigned int filterId , size_t filterNbrParams, unsigned int* filterParams );
+
     //! Set or unset the fill mode
     static int setFill(int ncid, bool fill);
@@ -121,5 +124,4 @@
     //! Define variable fill parameters
     static int defVarFill(int ncid, int varId, int noFill, void* fillValue);
-
 
     //! Change access type of a variable
Index: XIOS3/trunk/src/io/onetcdf4.cpp
===================================================================
--- XIOS3/trunk/src/io/onetcdf4.cpp	(revision 2528)
+++ XIOS3/trunk/src/io/onetcdf4.cpp	(revision 2529)
@@ -2,4 +2,5 @@
 
 #include "onetcdf4.hpp"
+#include "onetcdf4_plugin.hpp"
 #include "group_template.hpp"
 #include "mpi.hpp"
@@ -505,6 +506,4 @@
             CNetCdfInterface::defVarFill(grpid, varid, true, NULL);
          }
-
-         setCompressionLevel(name, compressionLevel) ;
          
          return varid;
@@ -513,15 +512,39 @@
       //---------------------------------------------------------------
 
-      void CONetCDF4::setCompressionLevel(const StdString& varname, int compressionLevel)
+      void CONetCDF4::setCompressionLevel(const StdString& varname, const StdString& compressionType, int compressionLevel, const CArray<double,1>& compressionParams)
       {
          if (compressionLevel < 0 || compressionLevel > 9)
            ERROR("void CONetCDF4::setCompressionLevel(const StdString& varname, int compressionLevel)",
                  "Invalid compression level for variable \"" << varname << "\", the value should range between 0 and 9.");
-         if (compressionLevel && wmpi)
+#ifndef PARALLEL_COMPRESSION
+         if ( ((compressionLevel)||(compressionParams.numElements())) && wmpi)
            ERROR("void CONetCDF4::setCompressionLevel(const StdString& varname, int compressionLevel)",
                  "Impossible to use compression for variable \"" << varname << "\" when using parallel mode.");
+#endif
          int grpid = this->getCurrentGroup();
          int varid = this->getVariable(varname);
-         CNetCdfInterface::defVarDeflate(grpid, varid, compressionLevel);
+         if (compressionType=="None")
+         {
+         }
+         else if (compressionType=="gzip")
+         {
+           CNetCdfInterface::defVarDeflate(grpid, varid, compressionLevel);
+         }
+         else
+         {
+           size_t cd_nelmts;
+           unsigned int* cd_values = NULL;
+           if (compressionType=="SZ")
+           {
+             CONetCDF4Plugin::interpretParametersSZ(compressionParams, &cd_nelmts, &cd_values);
+             CNetCdfInterface::defVarFilter(grpid, varid, 32017, cd_nelmts, cd_values);
+           }
+           else
+           {
+               ERROR("void CONetCDF4::setCompressionLevel(...)", "compression_type = " << compressionType << " is not managed");
+           }
+           if (cd_values!=NULL) delete [] cd_values;
+         }
+                      
       }
 
Index: XIOS3/trunk/src/io/onetcdf4.hpp
===================================================================
--- XIOS3/trunk/src/io/onetcdf4.hpp	(revision 2528)
+++ XIOS3/trunk/src/io/onetcdf4.hpp	(revision 2529)
@@ -59,5 +59,6 @@
                void setDefaultValue(const StdString& varname, const T* value = NULL);
 
-            void setCompressionLevel(const StdString& varname, int compressionLevel);
+            void setCompressionLevel(const StdString& varname, const StdString& compressionType, int compressionLevel, 
+                                     const CArray<double,1>& compressionParam );
 
             template <class T>  void addAttribute (const StdString& name, const T& value, const StdString* varname = NULL);
Index: XIOS3/trunk/src/io/onetcdf4_plugin.hpp
===================================================================
--- XIOS3/trunk/src/io/onetcdf4_plugin.hpp	(revision 2529)
+++ XIOS3/trunk/src/io/onetcdf4_plugin.hpp	(revision 2529)
@@ -0,0 +1,52 @@
+#ifndef __XIOS_ONETCDF4_PLUGIN__
+#define __XIOS_ONETCDF4_PLUGIN__
+
+#include "xios_spl.hpp"
+
+#if !defined(USING_NETCDF_PAR)
+#include "exception.hpp"
+#endif
+
+#include "mpi.hpp"
+namespace xios
+{
+  /*!
+  \class CONetCDF4Plugin
+   This class computes parameters for HDF5 plugin compression filters : SZ, ZFP ...
+  */
+  class CONetCDF4Plugin
+  {
+  public:
+    //! Compute HDF5 plugin parameters from SZ parameters
+    static void interpretParametersSZ(const CArray<double,1>& inParams, size_t* nOutParams, unsigned int **outParams)
+    {
+      if (inParams.numElements()!=5)
+      {
+          ERROR("CONetCDF4Plugin::interpretParametersSZ(...)", "The SZ compressor requires 5 parameters : "
+                << "compression_params=\"(0,4)[mode abs_err rel_err pw_rel_err psnr]\" must be specified,"
+                << " see details in https://www.mcs.anl.gov/~shdi/download/sz-2.0-user-guide.pdf" );
+      }
+      *nOutParams = 9;
+      *outParams = new unsigned int[*nOutParams];
+      
+      for (size_t iParam=0 ; iParam<(*nOutParams) ; iParam++) (*outParams)[iParam] = 0;
+
+      // 1st parameter is the SZ error bound mode
+      //   https://github.com/szcompressor/SZ/blob/master/hdf5-filter/H5Z-SZ/docs/H5Z-SZ-Guide.pdf
+      (*outParams)[0] = (unsigned int)(inParams(0));
+      
+      // 1 double -> 2 unsigned int
+      for (size_t iParam=0 ; iParam<4 ; iParam++)
+      {
+        memcpy( &((*outParams)[1+iParam*2]), &(inParams(1+iParam)), sizeof(double) );
+        unsigned int tmp_swap      = (*outParams)[1+iParam*2  ];
+        (*outParams)[1+iParam*2  ] = (*outParams)[1+iParam*2+1];
+        (*outParams)[1+iParam*2+1] = tmp_swap;
+      }
+    }
+      
+  };
+}
+
+
+#endif // __XIOS_ONETCDF4_PLUGIN__
