Commit e8e1349d authored by Axel Kohlmeyer's avatar Axel Kohlmeyer
Browse files

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).
parent 9f3cb83f
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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
+16 −3
Original line number Diff line number Diff line
@@ -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;

+1 −80
Original line number Diff line number Diff line
@@ -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;
+2 −0
Original line number Diff line number Diff line
@@ -59,6 +59,8 @@ class LAMMPS {

  class CiteMe *citeme;          // citation info

  static const char * installed_packages[];

  LAMMPS(int, char **, MPI_Comm);
  ~LAMMPS();
  void create();