[2c47b73] | 1 | /** |
---|
| 2 | * @file conf.c |
---|
| 3 | * @author Sheng Di ([email protected] or [email protected]) |
---|
| 4 | * @date 2015. |
---|
| 5 | * @brief Configuration loading functions for the SZ library. |
---|
| 6 | * (C) 2015 by Mathematics and Computer Science (MCS), Argonne National Laboratory. |
---|
| 7 | * See COPYRIGHT in top-level directory. |
---|
| 8 | */ |
---|
| 9 | |
---|
| 10 | #include <math.h> |
---|
| 11 | #include "string.h" |
---|
| 12 | #include "sz.h" |
---|
| 13 | #include "iniparser.h" |
---|
| 14 | #include "Huffman.h" |
---|
| 15 | #include "pastri.h" |
---|
| 16 | |
---|
| 17 | /*-------------------------------------------------------------------------*/ |
---|
| 18 | /** |
---|
| 19 | @brief It reads the configuration given in the configuration file. |
---|
| 20 | @return integer 1 if successfull. |
---|
| 21 | |
---|
| 22 | This function reads the configuration given in the SZ configuration |
---|
| 23 | file and sets other required parameters. |
---|
| 24 | |
---|
| 25 | **/ |
---|
| 26 | |
---|
| 27 | /*struct node_t *pool; |
---|
| 28 | node *qqq; |
---|
| 29 | node *qq; |
---|
| 30 | int n_nodes = 0, qend; |
---|
| 31 | unsigned long **code; |
---|
| 32 | unsigned char *cout; |
---|
| 33 | int n_inode;*/ |
---|
| 34 | |
---|
| 35 | unsigned int roundUpToPowerOf2(unsigned int base) |
---|
| 36 | { |
---|
| 37 | base -= 1; |
---|
| 38 | |
---|
| 39 | base = base | (base >> 1); |
---|
| 40 | base = base | (base >> 2); |
---|
| 41 | base = base | (base >> 4); |
---|
| 42 | base = base | (base >> 8); |
---|
| 43 | base = base | (base >> 16); |
---|
| 44 | |
---|
| 45 | return base + 1; |
---|
| 46 | } |
---|
| 47 | |
---|
| 48 | void updateQuantizationInfo(int quant_intervals) |
---|
| 49 | { |
---|
| 50 | exe_params->intvCapacity = quant_intervals; |
---|
| 51 | exe_params->intvRadius = quant_intervals/2; |
---|
| 52 | } |
---|
| 53 | |
---|
| 54 | double computeABSErrBoundFromPSNR(double psnr, double threshold, double value_range) |
---|
| 55 | { |
---|
| 56 | double v1 = psnr + 10 * log10(1-2.0/3.0*threshold); |
---|
| 57 | double v2 = v1/(-20); |
---|
| 58 | double v3 = pow(10, v2); |
---|
| 59 | return value_range * v3; |
---|
| 60 | } |
---|
| 61 | |
---|
| 62 | /*-------------------------------------------------------------------------*/ |
---|
| 63 | /** |
---|
| 64 | * |
---|
| 65 | * |
---|
| 66 | * @return the status of loading conf. file: 1 (success) or 0 (error code); |
---|
| 67 | * */ |
---|
| 68 | int SZ_ReadConf(const char* sz_cfgFile) { |
---|
| 69 | // Check access to SZ configuration file and load dictionary |
---|
| 70 | //record the setting in confparams_cpr |
---|
| 71 | confparams_cpr = (sz_params*)malloc(sizeof(sz_params)); |
---|
| 72 | exe_params = (sz_exedata*)malloc(sizeof(sz_exedata)); |
---|
| 73 | |
---|
| 74 | int x = 1; |
---|
| 75 | char sol_name[256]; |
---|
| 76 | char *modeBuf; |
---|
| 77 | char *errBoundMode; |
---|
| 78 | char *endianTypeString; |
---|
| 79 | dictionary *ini; |
---|
| 80 | char *par; |
---|
| 81 | |
---|
| 82 | char *y = (char*)&x; |
---|
| 83 | |
---|
| 84 | if(*y==1) |
---|
| 85 | sysEndianType = LITTLE_ENDIAN_SYSTEM; |
---|
| 86 | else //=0 |
---|
| 87 | sysEndianType = BIG_ENDIAN_SYSTEM; |
---|
| 88 | |
---|
| 89 | if(sz_cfgFile == NULL) |
---|
| 90 | { |
---|
| 91 | dataEndianType = LITTLE_ENDIAN_DATA; |
---|
| 92 | confparams_cpr->sol_ID = SZ; |
---|
| 93 | confparams_cpr->max_quant_intervals = 65536; |
---|
| 94 | confparams_cpr->maxRangeRadius = confparams_cpr->max_quant_intervals/2; |
---|
| 95 | |
---|
| 96 | exe_params->intvCapacity = confparams_cpr->maxRangeRadius*2; |
---|
| 97 | exe_params->intvRadius = confparams_cpr->maxRangeRadius; |
---|
| 98 | |
---|
| 99 | confparams_cpr->quantization_intervals = 0; |
---|
| 100 | exe_params->optQuantMode = 1; |
---|
| 101 | confparams_cpr->predThreshold = 0.99; |
---|
| 102 | confparams_cpr->sampleDistance = 100; |
---|
| 103 | |
---|
| 104 | confparams_cpr->szMode = SZ_BEST_COMPRESSION; |
---|
[9ee2ce3] | 105 | confparams_cpr->losslessCompressor = ZSTD_COMPRESSOR; //other option: GZIP_COMPRESSOR; |
---|
| 106 | if(confparams_cpr->losslessCompressor==ZSTD_COMPRESSOR) |
---|
| 107 | confparams_cpr->gzipMode = 3; //fast mode |
---|
| 108 | else |
---|
| 109 | confparams_cpr->gzipMode = 1; //high speed mode |
---|
[2c47b73] | 110 | |
---|
| 111 | confparams_cpr->errorBoundMode = PSNR; |
---|
| 112 | confparams_cpr->psnr = 90; |
---|
[9ee2ce3] | 113 | confparams_cpr->absErrBound = 1E-4; |
---|
| 114 | confparams_cpr->relBoundRatio = 1E-4; |
---|
[2c47b73] | 115 | |
---|
| 116 | confparams_cpr->pw_relBoundRatio = 1E-3; |
---|
| 117 | confparams_cpr->segment_size = 36; |
---|
| 118 | |
---|
| 119 | confparams_cpr->pwr_type = SZ_PWR_MIN_TYPE; |
---|
| 120 | |
---|
| 121 | confparams_cpr->snapshotCmprStep = 5; |
---|
[9ee2ce3] | 122 | |
---|
| 123 | sz_with_regression = SZ_WITH_LINEAR_REGRESSION; |
---|
[2c47b73] | 124 | |
---|
| 125 | return SZ_SCES; |
---|
| 126 | } |
---|
| 127 | |
---|
| 128 | if (access(sz_cfgFile, F_OK) != 0) |
---|
| 129 | { |
---|
| 130 | printf("[SZ] Configuration file NOT accessible.\n"); |
---|
| 131 | return SZ_NSCS; |
---|
| 132 | } |
---|
| 133 | |
---|
| 134 | //printf("[SZ] Reading SZ configuration file (%s) ...\n", sz_cfgFile); |
---|
| 135 | ini = iniparser_load(sz_cfgFile); |
---|
| 136 | if (ini == NULL) |
---|
| 137 | { |
---|
| 138 | printf("[SZ] Iniparser failed to parse the conf. file.\n"); |
---|
| 139 | return SZ_NSCS; |
---|
| 140 | } |
---|
| 141 | |
---|
| 142 | endianTypeString = iniparser_getstring(ini, "ENV:dataEndianType", "LITTLE_ENDIAN_DATA"); |
---|
| 143 | if(strcmp(endianTypeString, "LITTLE_ENDIAN_DATA")==0) |
---|
| 144 | dataEndianType = LITTLE_ENDIAN_DATA; |
---|
| 145 | else if(strcmp(endianTypeString, "BIG_ENDIAN_DATA")==0) |
---|
| 146 | dataEndianType = BIG_ENDIAN_DATA; |
---|
| 147 | else |
---|
| 148 | { |
---|
| 149 | printf("Error: Wrong dataEndianType: please set it correctly in sz.config.\n"); |
---|
| 150 | iniparser_freedict(ini); |
---|
| 151 | return SZ_NSCS; |
---|
| 152 | } |
---|
| 153 | |
---|
| 154 | // Reading/setting detection parameters |
---|
| 155 | |
---|
| 156 | par = iniparser_getstring(ini, "ENV:sol_name", NULL); |
---|
| 157 | snprintf(sol_name, 256, "%s", par); |
---|
| 158 | |
---|
| 159 | if(strcmp(sol_name, "SZ")==0) |
---|
| 160 | confparams_cpr->sol_ID = SZ; |
---|
| 161 | else if(strcmp(sol_name, "PASTRI")==0) |
---|
| 162 | confparams_cpr->sol_ID = PASTRI; |
---|
| 163 | else{ |
---|
| 164 | printf("[SZ] Error: wrong solution name (please check sz.config file)\n"); |
---|
| 165 | iniparser_freedict(ini); |
---|
| 166 | return SZ_NSCS; |
---|
| 167 | } |
---|
| 168 | |
---|
| 169 | if(confparams_cpr->sol_ID==SZ) |
---|
| 170 | { |
---|
| 171 | int max_quant_intervals = iniparser_getint(ini, "PARAMETER:max_quant_intervals", 65536); |
---|
| 172 | confparams_cpr->max_quant_intervals = max_quant_intervals; |
---|
| 173 | |
---|
| 174 | int quantization_intervals = (int)iniparser_getint(ini, "PARAMETER:quantization_intervals", 0); |
---|
| 175 | confparams_cpr->quantization_intervals = quantization_intervals; |
---|
| 176 | if(quantization_intervals>0) |
---|
| 177 | { |
---|
| 178 | updateQuantizationInfo(quantization_intervals); |
---|
| 179 | confparams_cpr->max_quant_intervals = max_quant_intervals = quantization_intervals; |
---|
| 180 | exe_params->optQuantMode = 0; |
---|
| 181 | } |
---|
| 182 | else //==0 |
---|
| 183 | { |
---|
| 184 | confparams_cpr->maxRangeRadius = max_quant_intervals/2; |
---|
| 185 | |
---|
| 186 | exe_params->intvCapacity = confparams_cpr->maxRangeRadius*2; |
---|
| 187 | exe_params->intvRadius = confparams_cpr->maxRangeRadius; |
---|
| 188 | |
---|
| 189 | exe_params->optQuantMode = 1; |
---|
| 190 | } |
---|
| 191 | |
---|
| 192 | if(quantization_intervals%2!=0) |
---|
| 193 | { |
---|
| 194 | printf("Error: quantization_intervals must be an even number!\n"); |
---|
| 195 | iniparser_freedict(ini); |
---|
| 196 | return SZ_NSCS; |
---|
| 197 | } |
---|
| 198 | |
---|
| 199 | confparams_cpr->predThreshold = (float)iniparser_getdouble(ini, "PARAMETER:predThreshold", 0); |
---|
| 200 | confparams_cpr->sampleDistance = (int)iniparser_getint(ini, "PARAMETER:sampleDistance", 0); |
---|
| 201 | |
---|
| 202 | modeBuf = iniparser_getstring(ini, "PARAMETER:szMode", NULL); |
---|
| 203 | if(modeBuf==NULL) |
---|
| 204 | { |
---|
| 205 | printf("[SZ] Error: Null szMode setting (please check sz.config file)\n"); |
---|
| 206 | iniparser_freedict(ini); |
---|
| 207 | return SZ_NSCS; |
---|
| 208 | } |
---|
| 209 | else if(strcmp(modeBuf, "SZ_BEST_SPEED")==0) |
---|
| 210 | confparams_cpr->szMode = SZ_BEST_SPEED; |
---|
| 211 | else if(strcmp(modeBuf, "SZ_DEFAULT_COMPRESSION")==0) |
---|
| 212 | confparams_cpr->szMode = SZ_DEFAULT_COMPRESSION; |
---|
| 213 | else if(strcmp(modeBuf, "SZ_BEST_COMPRESSION")==0) |
---|
| 214 | confparams_cpr->szMode = SZ_BEST_COMPRESSION; |
---|
| 215 | else |
---|
| 216 | { |
---|
| 217 | printf("[SZ] Error: Wrong szMode setting (please check sz.config file)\n"); |
---|
| 218 | iniparser_freedict(ini); |
---|
| 219 | return SZ_NSCS; |
---|
| 220 | } |
---|
| 221 | |
---|
[9ee2ce3] | 222 | modeBuf = iniparser_getstring(ini, "PARAMETER:losslessCompressor", "ZSTD_COMPRESSOR"); |
---|
| 223 | if(strcmp(modeBuf, "GZIP_COMPRESSOR")==0) |
---|
| 224 | confparams_cpr->losslessCompressor = GZIP_COMPRESSOR; |
---|
| 225 | else if(strcmp(modeBuf, "ZSTD_COMPRESSOR")==0) |
---|
| 226 | confparams_cpr->losslessCompressor = ZSTD_COMPRESSOR; |
---|
| 227 | else |
---|
| 228 | { |
---|
| 229 | printf("[SZ] Error: Wrong losslessCompressor setting (please check sz.config file)\n");\ |
---|
| 230 | printf("No Such a lossless compressor: %s\n", modeBuf); |
---|
| 231 | iniparser_freedict(ini); |
---|
| 232 | return SZ_NSCS; |
---|
| 233 | } |
---|
| 234 | |
---|
| 235 | modeBuf = iniparser_getstring(ini, "PARAMETER:withLinearRegression", "YES"); |
---|
| 236 | if(strcmp(modeBuf, "YES")==0 || strcmp(modeBuf, "yes")==0) |
---|
| 237 | sz_with_regression = SZ_WITH_LINEAR_REGRESSION; |
---|
| 238 | else |
---|
| 239 | sz_with_regression = SZ_NO_REGRESSION; |
---|
| 240 | |
---|
| 241 | modeBuf = iniparser_getstring(ini, "PARAMETER:gzipMode", "Gzip_BEST_SPEED"); |
---|
[2c47b73] | 242 | if(modeBuf==NULL) |
---|
| 243 | { |
---|
| 244 | printf("[SZ] Error: Null Gzip mode setting (please check sz.config file)\n"); |
---|
| 245 | iniparser_freedict(ini); |
---|
| 246 | return SZ_NSCS; |
---|
| 247 | } |
---|
| 248 | else if(strcmp(modeBuf, "Gzip_NO_COMPRESSION")==0) |
---|
| 249 | confparams_cpr->gzipMode = 0; |
---|
| 250 | else if(strcmp(modeBuf, "Gzip_BEST_SPEED")==0) |
---|
| 251 | confparams_cpr->gzipMode = 1; |
---|
| 252 | else if(strcmp(modeBuf, "Gzip_BEST_COMPRESSION")==0) |
---|
| 253 | confparams_cpr->gzipMode = 9; |
---|
| 254 | else if(strcmp(modeBuf, "Gzip_DEFAULT_COMPRESSION")==0) |
---|
| 255 | confparams_cpr->gzipMode = -1; |
---|
| 256 | else |
---|
| 257 | { |
---|
| 258 | printf("[SZ] Error: Wrong gzip Mode (please check sz.config file)\n"); |
---|
| 259 | return SZ_NSCS; |
---|
| 260 | } |
---|
| 261 | |
---|
[9ee2ce3] | 262 | modeBuf = iniparser_getstring(ini, "PARAMETER:zstdMode", "Zstd_HIGH_SPEED"); |
---|
| 263 | if(modeBuf==NULL) |
---|
| 264 | { |
---|
| 265 | printf("[SZ] Error: Null Zstd mode setting (please check sz.config file)\n"); |
---|
| 266 | iniparser_freedict(ini); |
---|
| 267 | return SZ_NSCS; |
---|
| 268 | } |
---|
| 269 | else if(strcmp(modeBuf, "Zstd_BEST_SPEED")==0) |
---|
| 270 | confparams_cpr->gzipMode = 1; |
---|
| 271 | else if(strcmp(modeBuf, "Zstd_HIGH_SPEED")==0) |
---|
| 272 | confparams_cpr->gzipMode = 3; |
---|
| 273 | else if(strcmp(modeBuf, "Zstd_HIGH_COMPRESSION")==0) |
---|
| 274 | confparams_cpr->gzipMode = 19; |
---|
| 275 | else if(strcmp(modeBuf, "Zstd_BEST_COMPRESSION")==0) |
---|
| 276 | confparams_cpr->gzipMode = 22; |
---|
| 277 | else if(strcmp(modeBuf, "Zstd_DEFAULT_COMPRESSION")==0) |
---|
| 278 | confparams_cpr->gzipMode = 3; |
---|
| 279 | else |
---|
| 280 | { |
---|
| 281 | printf("[SZ] Error: Wrong zstd Mode (please check sz.config file)\n"); |
---|
| 282 | return SZ_NSCS; |
---|
| 283 | } |
---|
| 284 | |
---|
[2c47b73] | 285 | //TODO |
---|
| 286 | confparams_cpr->snapshotCmprStep = (int)iniparser_getint(ini, "PARAMETER:snapshotCmprStep", 5); |
---|
| 287 | |
---|
| 288 | errBoundMode = iniparser_getstring(ini, "PARAMETER:errorBoundMode", NULL); |
---|
| 289 | if(errBoundMode==NULL) |
---|
| 290 | { |
---|
| 291 | printf("[SZ] Error: Null error bound setting (please check sz.config file)\n"); |
---|
| 292 | iniparser_freedict(ini); |
---|
| 293 | return SZ_NSCS; |
---|
| 294 | } |
---|
| 295 | else if(strcmp(errBoundMode,"ABS")==0||strcmp(errBoundMode,"abs")==0) |
---|
| 296 | confparams_cpr->errorBoundMode=ABS; |
---|
| 297 | else if(strcmp(errBoundMode, "REL")==0||strcmp(errBoundMode,"rel")==0) |
---|
| 298 | confparams_cpr->errorBoundMode=REL; |
---|
| 299 | else if(strcmp(errBoundMode, "ABS_AND_REL")==0||strcmp(errBoundMode, "abs_and_rel")==0) |
---|
| 300 | confparams_cpr->errorBoundMode=ABS_AND_REL; |
---|
| 301 | else if(strcmp(errBoundMode, "ABS_OR_REL")==0||strcmp(errBoundMode, "abs_or_rel")==0) |
---|
| 302 | confparams_cpr->errorBoundMode=ABS_OR_REL; |
---|
| 303 | else if(strcmp(errBoundMode, "PW_REL")==0||strcmp(errBoundMode, "pw_rel")==0) |
---|
| 304 | confparams_cpr->errorBoundMode=PW_REL; |
---|
| 305 | else if(strcmp(errBoundMode, "PSNR")==0||strcmp(errBoundMode, "psnr")==0) |
---|
| 306 | confparams_cpr->errorBoundMode=PSNR; |
---|
| 307 | else if(strcmp(errBoundMode, "ABS_AND_PW_REL")==0||strcmp(errBoundMode, "abs_and_pw_rel")==0) |
---|
| 308 | confparams_cpr->errorBoundMode=ABS_AND_PW_REL; |
---|
| 309 | else if(strcmp(errBoundMode, "ABS_OR_PW_REL")==0||strcmp(errBoundMode, "abs_or_pw_rel")==0) |
---|
| 310 | confparams_cpr->errorBoundMode=ABS_OR_PW_REL; |
---|
| 311 | else if(strcmp(errBoundMode, "REL_AND_PW_REL")==0||strcmp(errBoundMode, "rel_and_pw_rel")==0) |
---|
| 312 | confparams_cpr->errorBoundMode=REL_AND_PW_REL; |
---|
| 313 | else if(strcmp(errBoundMode, "REL_OR_PW_REL")==0||strcmp(errBoundMode, "rel_or_pw_rel")==0) |
---|
| 314 | confparams_cpr->errorBoundMode=REL_OR_PW_REL; |
---|
| 315 | else |
---|
| 316 | { |
---|
| 317 | printf("[SZ] Error: Wrong error bound mode (please check sz.config file)\n"); |
---|
| 318 | iniparser_freedict(ini); |
---|
| 319 | return SZ_NSCS; |
---|
| 320 | } |
---|
| 321 | |
---|
| 322 | confparams_cpr->absErrBound = (double)iniparser_getdouble(ini, "PARAMETER:absErrBound", 0); |
---|
| 323 | confparams_cpr->relBoundRatio = (double)iniparser_getdouble(ini, "PARAMETER:relBoundRatio", 0); |
---|
| 324 | confparams_cpr->psnr = (double)iniparser_getdouble(ini, "PARAMETER:psnr", 0); |
---|
| 325 | confparams_cpr->pw_relBoundRatio = (double)iniparser_getdouble(ini, "PARAMETER:pw_relBoundRatio", 0); |
---|
| 326 | confparams_cpr->segment_size = (int)iniparser_getint(ini, "PARAMETER:segment_size", 0); |
---|
| 327 | |
---|
| 328 | modeBuf = iniparser_getstring(ini, "PARAMETER:pwr_type", "MIN"); |
---|
| 329 | |
---|
| 330 | if(strcmp(modeBuf, "MIN")==0) |
---|
| 331 | confparams_cpr->pwr_type = SZ_PWR_MIN_TYPE; |
---|
| 332 | else if(strcmp(modeBuf, "AVG")==0) |
---|
| 333 | confparams_cpr->pwr_type = SZ_PWR_AVG_TYPE; |
---|
| 334 | else if(strcmp(modeBuf, "MAX")==0) |
---|
| 335 | confparams_cpr->pwr_type = SZ_PWR_MAX_TYPE; |
---|
| 336 | else if(modeBuf!=NULL) |
---|
| 337 | { |
---|
| 338 | printf("[SZ] Error: Wrong pwr_type setting (please check sz.config file).\n"); |
---|
| 339 | iniparser_freedict(ini); |
---|
| 340 | return SZ_NSCS; |
---|
| 341 | } |
---|
| 342 | else //by default |
---|
| 343 | confparams_cpr->pwr_type = SZ_PWR_AVG_TYPE; |
---|
| 344 | |
---|
| 345 | //initialization for Huffman encoding |
---|
| 346 | //SZ_Reset(); |
---|
| 347 | } |
---|
| 348 | else if(confparams_cpr->sol_ID == PASTRI) |
---|
| 349 | {//load parameters for PSTRI |
---|
| 350 | pastri_par.bf[0] = (int)iniparser_getint(ini, "PARAMETER:basisFunction_0", 0); |
---|
| 351 | pastri_par.bf[1] = (int)iniparser_getint(ini, "PARAMETER:basisFunction_1", 0); |
---|
| 352 | pastri_par.bf[2] = (int)iniparser_getint(ini, "PARAMETER:basisFunction_2", 0); |
---|
| 353 | pastri_par.bf[3] = (int)iniparser_getint(ini, "PARAMETER:basisFunction_3", 0); |
---|
| 354 | pastri_par.numBlocks = (int)iniparser_getint(ini, "PARAMETER:numBlocks", 0); |
---|
| 355 | confparams_cpr->absErrBound = pastri_par.originalEb = (double)iniparser_getdouble(ini, "PARAMETER:absErrBound", 1E-3); |
---|
| 356 | } |
---|
| 357 | |
---|
| 358 | iniparser_freedict(ini); |
---|
| 359 | return SZ_SCES; |
---|
| 360 | } |
---|
| 361 | |
---|
| 362 | /*-------------------------------------------------------------------------*/ |
---|
| 363 | /** |
---|
| 364 | @brief It reads and tests the configuration given. |
---|
| 365 | @return integer 1 if successfull. |
---|
| 366 | |
---|
| 367 | This function reads the configuration file. Then test that the |
---|
| 368 | configuration parameters are correct (including directories). |
---|
| 369 | |
---|
| 370 | **/ |
---|
| 371 | /*-------------------------------------------------------------------------*/ |
---|
| 372 | int SZ_LoadConf(const char* sz_cfgFile) { |
---|
| 373 | int res = SZ_ReadConf(sz_cfgFile); |
---|
| 374 | if (res != SZ_SCES) |
---|
| 375 | { |
---|
| 376 | printf("[SZ] ERROR: Impossible to read configuration.\n"); |
---|
| 377 | return SZ_NSCS; |
---|
| 378 | } |
---|
| 379 | return SZ_SCES; |
---|
| 380 | } |
---|
| 381 | |
---|
| 382 | int checkVersion(char* version) |
---|
| 383 | { |
---|
| 384 | int i = 0; |
---|
| 385 | for(;i<3;i++) |
---|
| 386 | if(version[i]!=versionNumber[i]) |
---|
| 387 | return 0; |
---|
| 388 | return 1; |
---|
| 389 | } |
---|
| 390 | |
---|
| 391 | void initSZ_TSC() |
---|
| 392 | { |
---|
| 393 | sz_tsc = (sz_tsc_metadata*)malloc(sizeof(sz_tsc_metadata)); |
---|
| 394 | memset(sz_tsc, 0, sizeof(sz_tsc_metadata)); |
---|
| 395 | sprintf(sz_tsc->metadata_filename, "sz_tsc_metainfo.txt"); |
---|
| 396 | sz_tsc->metadata_file = fopen(sz_tsc->metadata_filename, "wb"); |
---|
| 397 | if (sz_tsc->metadata_file == NULL) |
---|
| 398 | { |
---|
| 399 | printf("Failed to open sz_tsc_metainfo.txt file for writing metainfo.\n"); |
---|
| 400 | exit(1); |
---|
| 401 | } |
---|
| 402 | fputs("#metadata of the time-step based compression\n", sz_tsc->metadata_file); |
---|
| 403 | } |
---|
| 404 | |
---|
| 405 | /*double fabs(double value) |
---|
| 406 | { |
---|
| 407 | if(value<0) |
---|
| 408 | return -value; |
---|
| 409 | else |
---|
| 410 | return value; |
---|
| 411 | }*/ |
---|