Skip to content

Commit

Permalink
EXODUS: Add support for lossy compression via netCDF quantize method
Browse files Browse the repository at this point in the history
  • Loading branch information
gdsjaar committed Jun 19, 2024
1 parent 18cd027 commit 47474bd
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
12 changes: 7 additions & 5 deletions packages/seacas/libraries/exodus/include/exodusII.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@
#endif

/* EXODUS version number */
#define EXODUS_VERSION "9.00"
#define EXODUS_VERSION "9.01"
#define EXODUS_VERSION_MAJOR 9
#define EXODUS_VERSION_MINOR 0
#define EXODUS_VERSION_MINOR 1
#define EXODUS_RELEASE_DATE "May 30, 2024"

#define EX_API_VERS 9.00f
#define EX_API_VERS 9.01f
#define EX_API_VERS_NODOT (100 * EXODUS_VERSION_MAJOR + EXODUS_VERSION_MINOR)
#define EX_VERS EX_API_VERS

Expand Down Expand Up @@ -242,9 +242,11 @@ NetCDF-4.?.? and later
enum ex_option_type {
EX_OPT_MAX_NAME_LENGTH =
1, /**< Maximum length of names that will be returned/passed via api call. */
EX_OPT_COMPRESSION_TYPE, /**< Not currently used; default is gzip */
EX_OPT_COMPRESSION_LEVEL, /**< In the range [0..9]. A value of 0 indicates no compression */
EX_OPT_COMPRESSION_TYPE, /**< Default is gzip */
EX_OPT_COMPRESSION_LEVEL, /**< Range depends on compression type. */
EX_OPT_COMPRESSION_SHUFFLE, /**< 1 if enabled, 0 if disabled */
EX_OPT_QUANTIZE_NSD, /**< if > 0, Number of significant digits to retain in lossy quantize
compression */
EX_OPT_INTEGER_SIZE_API, /**< 4 or 8 indicating byte size of integers used in api functions. */
EX_OPT_INTEGER_SIZE_DB, /**< Query only, returns 4 or 8 indicating byte size of integers stored
on the database. */
Expand Down
2 changes: 2 additions & 0 deletions packages/seacas/libraries/exodus/include/exodusII_int.h
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,8 @@ struct exi_file_item
compression_algorithm : 2; /**< GZIP/ZLIB, SZIP, more may be supported by NetCDF soon */
unsigned int compression_level : 6; /**< 0 (disabled) to 9 (maximum) compression level for
gzip, 4..32 and even for szip; NetCDF-4 only */
unsigned int quantize_nsd : 4; /**< 0 (disabled) to 15 (maximum) number of significant digits
retained for lossy quanitzation compression */
unsigned int user_compute_wordsize : 1; /**< 0 for 4 byte or 1 for 8 byte reals */
unsigned int shuffle : 1; /**< 1 true, 0 false */
unsigned int
Expand Down
2 changes: 2 additions & 0 deletions packages/seacas/libraries/exodus/src/ex_conv.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ int exi_conv_init(int exoid, int *comp_wordsize, int *io_wordsize, int file_word
new_file->assembly_count = 0;
new_file->blob_count = 0;
new_file->compression_level = 0;
new_file->quantize_nsd = 0;
new_file->shuffle = 0;
new_file->file_type = filetype - 1;
new_file->is_parallel = is_parallel;
Expand Down Expand Up @@ -454,6 +455,7 @@ int ex_set_option(int exoid, ex_option_type option, int option_value)
file->compression_level = 0;
}
break;
case EX_OPT_QUANTIZE_NSD: file->quantize_nsd = option_value; break;
case EX_OPT_COMPRESSION_SHUFFLE: /* 0 (disabled); 1 (enabled) */
file->shuffle = option_value != 0 ? 1 : 0;
break;
Expand Down
5 changes: 5 additions & 0 deletions packages/seacas/libraries/exodus/src/ex_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -1763,6 +1763,11 @@ void exi_compress_variable(int exoid, int varid, int type)
ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM);
#endif
}

if (type == 2 && file->quantize_nsd > 0) {
// Lossy compression using netCDF quantize methods.
nc_def_var_quantize(exoid, varid, NC_QUANTIZE_GRANULARBR, file->quantize_nsd);
}
}
#if defined(PARALLEL_AWARE_EXODUS)
if (file->is_parallel) {
Expand Down

0 comments on commit 47474bd

Please sign in to comment.