Commit 9ed6f2fc authored by Ryan S. Elliott's avatar Ryan S. Elliott
Browse files

Adjust lib/kim install script and settings

parent b0938b70
Loading
Loading
Loading
Loading
+21 −34
Original line number Diff line number Diff line
@@ -12,21 +12,21 @@ help = """
Syntax from src dir: make lib-kim args="-b -v version -a kim-name"
                 or: make lib-kim args="-b -a everything"
                 or: make lib-kim args="-n -a kim-name"
                 or: make lib-kim args="-p /usr/local/lib/kim-api-v2 -a kim-name"
                 or: make lib-kim args="-p /home/bob/kim -a kim-name"
Syntax from lib dir: python Install.py -b -v version -a kim-name
                 or: python Install.py -b -a everything
                 or: python Install.py -n -a kim-name
                 or: python Install.py -p /usr/local/lib/kim-api-v2 -a kim-name
                 or: python Install.py -p /home/bob/kim -a kim-name

specify one or more options, order does not matter

  -v = version of KIM API library to use
       default = kim-api-v2.0.0-beta.1 (current as of July 2018)
       default = kim-api-v2.0.0-beta.2 (current as of November 2018)
  -b = download and build base KIM API library with example Models
       this will delete any previous installation in the current folder
  -n = do NOT download and build base KIM API library.
       Use an existing installation
  -p = specify location of KIM API installation (implies -n)
  -p = specify install prefix of KIM API installation (implies -n)
  -a = add single KIM model or model driver with kim-name
       to existing KIM API lib (see example below).
       If kim-name = everything, then rebuild KIM API library with
@@ -109,7 +109,7 @@ nargs = len(args)
if nargs == 0: error()

thisdir = os.environ['PWD']
version = "kim-api-v2.0.0-beta.1"
version = "kim-api-v2.0.0-beta.2"

buildflag = False
everythingflag = False
@@ -160,13 +160,10 @@ if pathflag:
    error()

  # configure LAMMPS to use existing kim-api installation
  with open("%s/Makefile.KIM_DIR" % thisdir, 'w') as mkfile:
    mkfile.write("KIM_INSTALL_DIR=%s\n\n" % kimdir)
    mkfile.write(".DUMMY: print_dir\n\n")
    mkfile.write("print_dir:\n")
    mkfile.write("	@printf $(KIM_INSTALL_DIR)\n")
  with open("%s/kim-prefix.txt" % thisdir, 'w') as pffile:
    pffile.write("%s" % kimdir)

  print("Created %s/Makefile.KIM_DIR\n  using %s" % (thisdir,kimdir))
  print("Created %s/kim-prefix.txt\n  using %s" % (thisdir,kimdir))
else:
  kimdir = os.path.join(os.path.abspath(thisdir), "installed-" + version)

@@ -182,13 +179,10 @@ if buildflag:

  # configure LAMMPS to use kim-api to be installed

  with open("%s/Makefile.KIM_DIR" % thisdir, 'w') as mkfile:
    mkfile.write("KIM_INSTALL_DIR=%s\n\n" % kimdir)
    mkfile.write(".DUMMY: print_dir\n\n")
    mkfile.write("print_dir:\n")
    mkfile.write("	@printf $(KIM_INSTALL_DIR)\n")
  with open("%s/kim-prefix.txt" % thisdir, 'w') as pffile:
    pffile.write("%s" % kimdir)

  print("Created %s/Makefile.KIM_DIR\n  using %s" % (thisdir,kimdir))
  print("Created %s/kim-prefix.txt\n  using %s" % (thisdir,kimdir))

  # download entire kim-api tarball

@@ -201,32 +195,25 @@ if buildflag:
  # configure kim-api

  print("Configuring kim-api ...")
  cmd = 'cd "%s/%s"; ./configure --prefix="%s"' % (thisdir,version,kimdir)
  subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
  cmd = 'cd "%s/%s" && mkdir build && cd build && cmake .. -DCMAKE_INSTALL_PREFIX="%s" -DCMAKE_BUILD_TYPE=Release' % (thisdir,version,kimdir)
  txt = subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
  if verboseflag: print(txt.decode("UTF-8"))

  # build kim-api
  print("Building kim-api ...")
  cmd = 'cd "%s/%s"; make' % (thisdir,version)
  cmd = 'cd "%s/%s/build" && make' % (thisdir,version)
  txt = subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
  if verboseflag: print(txt.decode("UTF-8"))

  # install kim-api

  print("Installing kim-api ...")
  cmd = 'cd "%s/%s"; make install' % (thisdir,version)
  cmd = 'cd "%s/%s/build" && make install' % (thisdir,version)
  txt = subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
  if verboseflag: print(txt.decode("UTF-8"))

  # remove source files

  print("Building and installing example Models")
  cmd = 'cd "%s/%s/examples"; make model-drivers-all-system' % (thisdir,version)
  txt = subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
  if verboseflag: print (txt.decode("UTF-8"))
  cmd = 'cd "%s/%s/examples"; make models-all-system' % (thisdir,version)
  txt = subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
  if verboseflag: print (txt.decode("UTF-8"))

  print("Removing kim-api source and build files ...")
  cmd = 'cd "%s"; rm -rf %s; rm -rf %s.txz' % (thisdir,version,version)
  subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
@@ -241,9 +228,9 @@ if buildflag:
# add single OpenKIM model
if addflag:

  makefile_path = os.path.join(thisdir, "Makefile.KIM_DIR")
  if os.path.isfile(makefile_path):
    cmd = 'make --no-print-directory -f %s print_dir' % makefile_path
  pf_path = os.path.join(thisdir, "kim-prefix.txt")
  if os.path.isfile(pf_path):
    cmd = 'cat %s' % pf_path
    kimdir = subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)

  if not os.path.isdir(kimdir):
+15 −2
Original line number Diff line number Diff line
@@ -13,5 +13,18 @@

# Settings that the LAMMPS build will import when this package is installed

kim_SYSINC  = $(shell pkg-config --cflags libkim-api-v2)
kim_SYSLIB  = $(shell pkg-config --libs   libkim-api-v2)

ifeq ($(strip $(shell pkg-config --version)),)
  $(error 'pkg-config' not found, but is required to configure the KIM API)
endif

kim_PREFIX  := $(shell cat ../../lib/kim/kim-prefix.txt 2> /dev/null)
kim_PREFIX  := $(if $(kim_PREFIX),$(kim_PREFIX)/lib/pkgconfig,)
kim_PREFIX  := $(if $(shell printf -- "$${PKG_CONFIG_PATH}"),$(kim_PREFIX):$(shell printf -- "$${PKG_CONFIG_PATH}"),$(kim_PREFIX))

kim_SYSINC  := $(shell export PKG_CONFIG_PATH="$(kim_PREFIX)"; pkg-config --cflags libkim-api-v2 2> /dev/null)
kim_SYSLIB  := $(shell export PKG_CONFIG_PATH="$(kim_PREFIX)"; pkg-config --libs   libkim-api-v2 2> /dev/null)

ifeq ($(strip $(kim_SYSINC)),)
  $(error 'pkg-config' could not find an installed KIM API library.)
endif
+12 −18
Original line number Diff line number Diff line
@@ -3,10 +3,9 @@ is required to use the KIM package and its pair_style kim command in a
LAMMPS input script.

Information about the KIM project can be found at https://openkim.org.
The KIM project is lead by Ellad Tadmor and Ryan Elliott (U Minn) and
James Sethna (Cornell U).  Ryan Elliott is the main developer for the
KIM API and he also maintains the code that implements the pair_style
kim command.
The KIM project is lead by Ellad Tadmor and Ryan Elliott (U Minn).
Ryan Elliott is the main developer for the KIM API and he also
maintains the code that implements the pair_style kim command.

You can type "make lib-kim" from the src directory to see help on
how to download and build this library via make commands, or you can
@@ -21,7 +20,7 @@ Instructions:
1. Configure lammps for use with the kim-api library installed in this directory

# replace X.Y.Z as appropriate here and below
$ printf "KIM_INSTALL_DIR=${PWD}/installed-kim-api-vX.Y.Z\n" > ./Makefile.KIM_DIR
$ printf "${PWD}/installed-kim-api-vX.Y.Z" > ./kim-prefix.txt

2. Download and unpack the kim-api

@@ -30,26 +29,21 @@ $ tar zxvf kim-api-vX.Y.Z.txz

# configure the kim-api
$ cd kim-api-vX.Y.Z
$ ./configure --prefix=${PWD}/../installed-kim-api-vX.Y.Z
$ mkdir build && cd build
$ cmake ..  -DCMAKE_INSTALL_PREFIX=${PWD}/../../installed-kim-api-vX.Y.Z

3. Build and install the kim-api and model

$ make
$ make install

4. To install the example models shipped with the kim-api

$ cd examples
$ make model-drivers-all-system
$ make models-all-system
$ cd ../..

5. Remove source and build files
4. Remove source and build files

$ cd ../../
$ rm -rf kim-api-vX.Y.Z
$ rm -rf kim-api-vX.Y.Z.txz

6. To add items do the following (replace the kim item name with your
5. To add items do the following (replace the kim item name with your
   desired value)

$ source ${PWD}/kim-api-vX.Y.Z/bin/kim-api-vX-activate
@@ -65,6 +59,6 @@ $ cd lammpos/src
$ make yes-kim
$ make g++ (or whatever target you wish)

Note that the Makefile.lammps and Makefile.KIM_DIR files in this directory
are required to allow the LAMMPS build to find the necessary KIM files.
You should not normally need to edit these files.
Note that the Makefile.lammps file in this directory is required to
allow the LAMMPS build to find the necessary KIM files.  You should
not normally need to edit these files.