Verify valid compression level ranges
This commit is contained in:
@ -27,7 +27,7 @@ DumpAtomGZ::DumpAtomGZ(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
{
|
{
|
||||||
gzFp = NULL;
|
gzFp = NULL;
|
||||||
|
|
||||||
compression_level = 9;
|
compression_level = Z_BEST_COMPRESSION;
|
||||||
|
|
||||||
if (!compressed)
|
if (!compressed)
|
||||||
error->all(FLERR,"Dump atom/gz only writes compressed files");
|
error->all(FLERR,"Dump atom/gz only writes compressed files");
|
||||||
@ -171,8 +171,10 @@ int DumpAtomGZ::modify_param(int narg, char **arg)
|
|||||||
if(consumed == 0) {
|
if(consumed == 0) {
|
||||||
if (strcmp(arg[0],"compression_level") == 0) {
|
if (strcmp(arg[0],"compression_level") == 0) {
|
||||||
if (narg < 2) error->all(FLERR,"Illegal dump_modify command");
|
if (narg < 2) error->all(FLERR,"Illegal dump_modify command");
|
||||||
compression_level = force->inumeric(FLERR,arg[1]);
|
int min_level = Z_DEFAULT_COMPRESSION;
|
||||||
if (compression_level <= 0) error->all(FLERR,"Illegal dump_modify command");
|
int max_level = Z_BEST_COMPRESSION;
|
||||||
|
if (compression_level < 0 || compression_level > max_level)
|
||||||
|
error->all(FLERR, fmt::format("Illegal dump_modify command: compression level must in the range of [{}, {}]", min_level, max_level));
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -201,7 +201,10 @@ int DumpAtomZstd::modify_param(int narg, char **arg)
|
|||||||
} else if (strcmp(arg[0],"compression_level") == 0) {
|
} else if (strcmp(arg[0],"compression_level") == 0) {
|
||||||
if (narg < 2) error->all(FLERR,"Illegal dump_modify command");
|
if (narg < 2) error->all(FLERR,"Illegal dump_modify command");
|
||||||
compression_level = force->inumeric(FLERR,arg[1]);
|
compression_level = force->inumeric(FLERR,arg[1]);
|
||||||
if (compression_level <= 0) error->all(FLERR,"Illegal dump_modify command");
|
int min_level = ZSTD_minCLevel();
|
||||||
|
int max_level = ZSTD_maxCLevel();
|
||||||
|
if (compression_level < min_level || compression_level > max_level)
|
||||||
|
error->all(FLERR, fmt::format("Illegal dump_modify command: compression level must in the range of [{}, {}]", min_level, max_level));
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user