1 | #ifndef __XIOS_ONETCDF4_PLUGIN__ |
---|
2 | #define __XIOS_ONETCDF4_PLUGIN__ |
---|
3 | |
---|
4 | #include "xios_spl.hpp" |
---|
5 | |
---|
6 | #if !defined(USING_NETCDF_PAR) |
---|
7 | #include "exception.hpp" |
---|
8 | #endif |
---|
9 | |
---|
10 | #include "mpi.hpp" |
---|
11 | namespace xios |
---|
12 | { |
---|
13 | /*! |
---|
14 | \class CONetCDF4Plugin |
---|
15 | This class computes parameters for HDF5 plugin compression filters : SZ, ZFP ... |
---|
16 | */ |
---|
17 | class CONetCDF4Plugin |
---|
18 | { |
---|
19 | public: |
---|
20 | //! Compute HDF5 plugin parameters from SZ parameters |
---|
21 | static void interpretParametersSZ(const CArray<double,1>& inParams, size_t* nOutParams, unsigned int **outParams) |
---|
22 | { |
---|
23 | if (inParams.numElements()!=5) |
---|
24 | { |
---|
25 | ERROR("CONetCDF4Plugin::interpretParametersSZ(...)", "The SZ compressor requires 5 parameters : " |
---|
26 | << "compression_params=\"(0,4)[mode abs_err rel_err pw_rel_err psnr]\" must be specified," |
---|
27 | << " see details in https://www.mcs.anl.gov/~shdi/download/sz-2.0-user-guide.pdf" ); |
---|
28 | } |
---|
29 | *nOutParams = 9; |
---|
30 | *outParams = new unsigned int[*nOutParams]; |
---|
31 | |
---|
32 | for (size_t iParam=0 ; iParam<(*nOutParams) ; iParam++) (*outParams)[iParam] = 0; |
---|
33 | |
---|
34 | // 1st parameter is the SZ error bound mode |
---|
35 | // https://github.com/szcompressor/SZ/blob/master/hdf5-filter/H5Z-SZ/docs/H5Z-SZ-Guide.pdf |
---|
36 | (*outParams)[0] = (unsigned int)(inParams(0)); |
---|
37 | |
---|
38 | // 1 double -> 2 unsigned int |
---|
39 | for (size_t iParam=0 ; iParam<4 ; iParam++) |
---|
40 | { |
---|
41 | memcpy( &((*outParams)[1+iParam*2]), &(inParams(1+iParam)), sizeof(double) ); |
---|
42 | unsigned int tmp_swap = (*outParams)[1+iParam*2 ]; |
---|
43 | (*outParams)[1+iParam*2 ] = (*outParams)[1+iParam*2+1]; |
---|
44 | (*outParams)[1+iParam*2+1] = tmp_swap; |
---|
45 | } |
---|
46 | } |
---|
47 | |
---|
48 | }; |
---|
49 | } |
---|
50 | |
---|
51 | |
---|
52 | #endif // __XIOS_ONETCDF4_PLUGIN__ |
---|