From 4b22443b25d2bbf944d84c5d852ed76ac338ce5a Mon Sep 17 00:00:00 2001 From: Richard Berger Date: Thu, 8 Sep 2016 14:31:40 -0400 Subject: [PATCH 1/3] Add feature category to is_available function This allows checking if the LAMMPS binary/library was compiled with PNG, JPEG, FFMPEG, GZIP, or exceptions support. Usage: ``` is_available(feature,gzip) is_available(feature,png) is_available(feature,jpeg) is_available(feature,ffmpeg) is_available(feature,exceptions) ``` --- src/info.cpp | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ src/info.h | 6 ++++++ 2 files changed, 58 insertions(+) diff --git a/src/info.cpp b/src/info.cpp index 175ea7c94f..30c696393f 100644 --- a/src/info.cpp +++ b/src/info.cpp @@ -925,6 +925,18 @@ bool Info::is_available(const char *category, const char *name) delete[] name_w_suffix; } } + } else if (strcmp(category,"feature") == 0) { + if (strcmp(name,"gzip") == 0) { + return has_gzip_support(); + } else if (strcmp(name,"png") == 0) { + return has_png_support(); + } else if (strcmp(name,"jpeg") == 0) { + return has_jpeg_support(); + } else if (strcmp(name,"ffmpeg") == 0) { + return has_ffmpeg_support(); + } else if (strcmp(name,"exceptions") == 0) { + return has_exceptions(); + } } else error->all(FLERR,"Unknown category for info is_available()"); return match ? true : false; @@ -1027,3 +1039,43 @@ static void print_columns(FILE* fp, vector & styles) } } } + +bool Info::has_gzip_support() const { +#ifdef LAMMPS_GZIP + return true; +#else + return false; +#endif +} + +bool Info::has_png_support() const { +#ifdef LAMMPS_PNG + return true; +#else + return false; +#endif +} + +bool Info::has_jpeg_support() const { +#ifdef LAMMPS_JPEG + return true; +#else + return false; +#endif +} + +bool Info::has_ffmpeg_support() const { +#ifdef LAMMPS_FFMPEG + return true; +#else + return false; +#endif +} + +bool Info::has_exceptions() const { +#ifdef LAMMPS_EXCEPTIONS + return true; +#else + return false; +#endif +} diff --git a/src/info.h b/src/info.h index f4549badf7..8e7a96d15a 100644 --- a/src/info.h +++ b/src/info.h @@ -33,6 +33,12 @@ class Info : protected Pointers { bool is_defined(const char *, const char *); bool is_available(const char *, const char *); + bool has_gzip_support() const; + bool has_png_support() const; + bool has_jpeg_support() const; + bool has_ffmpeg_support() const; + bool has_exceptions() const; + private: void available_styles(FILE * out, int flags); From dc0c0ab214d3bc73978f21935ccf2c738d289fb0 Mon Sep 17 00:00:00 2001 From: Richard Berger Date: Fri, 9 Sep 2016 05:55:28 -0400 Subject: [PATCH 2/3] Add documentation about new is_available feature category --- doc/src/variable.txt | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/doc/src/variable.txt b/doc/src/variable.txt index 9f40beacb4..7940f2b5e9 100644 --- a/doc/src/variable.txt +++ b/doc/src/variable.txt @@ -894,11 +894,25 @@ The {is_defined()} function allows to query categories like {compute}, {dump}, {fix}, {group}, {region}, and {variable} whether an entry with the provided name or id is defined. -The {is_available()} function allows to query whether a specific -optional feature is available, i.e. compiled in. This currently -works for the following categories: {command}, {compute}, {fix}, -and {pair_style}. For all categories except {command} also appending -active suffixes is tried before reporting failure. +The {is_available(category,name)} function allows to query whether +a specific optional feature is available, i.e. compiled in. +This currently works for the following categories: {command}, +{compute}, {fix}, {pair_style} and {feature}. For all categories +except {command} and {feature} also appending active suffixes is +tried before reporting failure. + +The {feature} category is used to check the availability of compiled in +features such as GZIP support, PNG support, JPEG support, FFMPEG support, +and C++ exceptions for error handling. Corresponding values for name are +{gzip}, {png}, {jpeg}, {ffmpeg} and {exceptions}. + +This enables writing input scripts which only dump using a given format if +the compiled binary supports it. + +if "$(is_available(feature,png))" then "print 'PNG supported'" else "print 'PNG not supported'" :pre + +if "$(is_available(feature,ffmpeg)" then "dump 3 all movie 25 movie.mp4 type type zoom 1.6 adiam 1.0" :pre + :line From e27869daf684e9bffc5f2231e652aee912c4a729 Mon Sep 17 00:00:00 2001 From: Richard Berger Date: Fri, 9 Sep 2016 05:56:24 -0400 Subject: [PATCH 3/3] Add updated HTML documentation about new is_available feature category --- doc/html/variable.html | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/doc/html/variable.html b/doc/html/variable.html index f7fd72fac0..3582bbab10 100644 --- a/doc/html/variable.html +++ b/doc/html/variable.html @@ -965,11 +965,24 @@ if $(is_active(pair,respa)) then "run_style respa 4 3 2 2 improper 1 inner

The is_defined() function allows to query categories like compute, dump, fix, group, region, and variable whether an entry with the provided name or id is defined.

-

The is_available() function allows to query whether a specific -optional feature is available, i.e. compiled in. This currently -works for the following categories: command, compute, fix, -and pair_style. For all categories except command also appending -active suffixes is tried before reporting failure.

+

The is_available(category,name) function allows to query whether +a specific optional feature is available, i.e. compiled in. +This currently works for the following categories: command, +compute, fix, pair_style and feature. For all categories +except command and feature also appending active suffixes is +tried before reporting failure.

+

The feature category is used to check the availability of compiled in +features such as GZIP support, PNG support, JPEG support, FFMPEG support, +and C++ exceptions for error handling. Corresponding values for name are +gzip, png, jpeg, ffmpeg and exceptions.

+

This enables writing input scripts which only dump using a given format if +the compiled binary supports it.

+
+if "$(is_available(feature,png))" then "print 'PNG supported'" else "print 'PNG not supported'"
+
+
+if "$(is_available(feature,ffmpeg)" then "dump 3 all movie 25 movie.mp4 type type zoom 1.6 adiam 1.0"
+