From e8e1349da4d6c083a056d3a16dd480e193593085 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer <akohlmey@gmail.com> Date: Thu, 21 Jun 2018 19:07:16 -0400 Subject: [PATCH] make the list of installed packages a static const class member of the LAMMPS class through this change, the list of packages becomes accessible for the library interface and the python wrapper, e.g. to check whether a prerequisite packages is installed (simpler/faster for quick highlevel check than having to try instantiating a specific style). --- src/Makefile | 2 +- src/info.cpp | 19 ++++++++++-- src/lammps.cpp | 81 +------------------------------------------------- src/lammps.h | 2 ++ 4 files changed, 20 insertions(+), 84 deletions(-) diff --git a/src/Makefile b/src/Makefile index a74e2c76de..29164e4e32 100644 --- a/src/Makefile +++ b/src/Makefile @@ -153,7 +153,7 @@ help: lmpinstalledpkgs.h: $(SRC) $(INC) @echo 'Gathering installed package information (may take a little while)' - @echo 'static const char * lammps_installed_packages[] = {' > lmpinstalledpkgs.tmp + @echo 'const char * LAMMPS_NS::LAMMPS::installed_packages[] = {' > lmpinstalledpkgs.tmp @for p in $(PACKAGEUC) $(PACKUSERUC); do info=$$($(SHELL) Package.sh $$p installed); \ [ -n "$$info" ] && echo "\"$$info\"" | sed -e 's/".*package \(.*\)"/"\1",/' >> lmpinstalledpkgs.tmp || :; done @echo ' NULL };' >> lmpinstalledpkgs.tmp diff --git a/src/info.cpp b/src/info.cpp index 1a5bc21209..0d11836826 100644 --- a/src/info.cpp +++ b/src/info.cpp @@ -259,15 +259,28 @@ void Info::command(int narg, char **arg) fprintf(out,"Printed on %s\n",ctime(&now)); if (flags & CONFIG) { - - fprintf(out,"\nLAMMPS version: %s / %s\n", + fprintf(out,"\nLAMMPS version: %s / %s\n\n", universe->version, universe->num_ver); - lmp->print_config(out); fprintf(out,"sizeof(smallint): %3d-bit\n",(int)sizeof(smallint)*8); fprintf(out,"sizeof(imageint): %3d-bit\n",(int)sizeof(imageint)*8); fprintf(out,"sizeof(tagint): %3d-bit\n",(int)sizeof(tagint)*8); fprintf(out,"sizeof(bigint): %3d-bit\n",(int)sizeof(bigint)*8); + const char *pkg; + int ncword, ncline = 0; + + fputs("\nInstalled packages:\n\n",out); + for (int i = 0; NULL != (pkg = lmp->installed_packages[i]); ++i) { + ncword = strlen(pkg); + if (ncline + ncword > 78) { + ncline = 0; + fputs("\n",out); + } + fprintf(out,"%s ",pkg); + ncline += ncword + 1; + } + fputs("\n",out); + #if defined(_WIN32) DWORD fullversion,majorv,minorv,buildv=0; diff --git a/src/lammps.cpp b/src/lammps.cpp index 3421b24b90..44df7b5a13 100644 --- a/src/lammps.cpp +++ b/src/lammps.cpp @@ -978,84 +978,6 @@ void print_style(FILE *fp, const char *str, int &pos) } } -#define lmp_str(s) #s -#define lmp_xstr(s) lmp_str(s) - -static const char lammps_config_options[] -= "LAMMPS compile time settings:\n\n" - "MPI library setting : " -#if defined(MPI_STUBS) - "Serial version using STUBS" -#elif defined(MPICH_VERSION) - "Parallel version using MPICH " MPICH_VERSION -#elif defined(OPEN_MPI) - "Parallel version using OpenMPI " - lmp_xstr(OMPI_MAJOR_VERSION) "." - lmp_xstr(OMPI_MINOR_VERSION) "." - lmp_xstr(OMPI_RELEASE_VERSION) -#else - "Parallel version using unknown MPI library" -#endif - "\nInteger sizes setting : " -#if defined(LAMMPS_SMALLSMALL) - "-DLAMMPS_SMALLSMALL" -#elif defined(LAMMPS_SMALLBIG) - "-DLAMMPS_SMALLBIG" -#elif defined(LAMMPS_BIGBIG) - "-DLAMMPS_BIGBIG" -#else - "(unkown)" -#endif - "\nExternal commands support :" -#if defined(LAMMPS_GZIP) - " -DLAMMPS_GZIP" -#endif -#if defined(LAMMPS_FFMPEG) - " -DLAMMPS_FFMPEG" -#endif - "\nImage library support :" -#if defined(LAMMPS_JPEG) - " -DLAMMPS_JPEG" -#endif -#if defined(LAMMPS_PNG) - " -DLAMMPS_PNG" -#endif - "\nFFT library support :" -#if defined(FFT_SINGLE) - " -DFFT_SINGLE" -#endif -#if defined(FFT_FFTW) || defined(FFT_FFTW3) - " -DFFT_FFTW3" -#elif defined(FFT_FFTW2) - " -DFFT_FFTW2" -#elif defined(FFT_MKL) - " -DFFT_MKL" -#else - " -DFFT_KISSFFT" -#endif - "\n3d-FFT data packing :" -#if defined(PACK_POINTER) - " -DPACK_POINTER" -#elif defined(PACK_MEMCPY) - " -DPACK_MEMCPY" -#else - " -DPACK_ARRAY" -#endif - "\nMemory alignment :" -#if defined(LAMMPS_MEMALIGN) - " -DLAMMPS_MEMALIGN=" lmp_xstr(LAMMPS_MEMALIGN) -#else - " (default)" -#endif - - "\nException support :" -#if defined(LAMMPS_EXCEPTIONS) - " -DLAMMPS_EXCEPTIONS\n" -#else - " (not enabled)\n" -#endif - "\n"; - #include "lmpinstalledpkgs.h" void LAMMPS::print_config(FILE *fp) @@ -1063,9 +985,8 @@ void LAMMPS::print_config(FILE *fp) const char *pkg; int ncword, ncline = 0; - fputs(lammps_config_options,fp); fputs("Installed packages:\n\n",fp); - for (int i = 0; NULL != (pkg = lammps_installed_packages[i]); ++i) { + for (int i = 0; NULL != (pkg = installed_packages[i]); ++i) { ncword = strlen(pkg); if (ncline + ncword > 78) { ncline = 0; diff --git a/src/lammps.h b/src/lammps.h index 6473985736..b2c8673471 100644 --- a/src/lammps.h +++ b/src/lammps.h @@ -59,6 +59,8 @@ class LAMMPS { class CiteMe *citeme; // citation info + static const char * installed_packages[]; + LAMMPS(int, char **, MPI_Comm); ~LAMMPS(); void create(); -- GitLab