From eecf75171e9c3491de622238300eda40f8194116 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Fri, 18 Dec 2015 22:25:32 +0100 Subject: [PATCH] Install scripts --- README.md | 13 +++++ configure.sh | 17 +++++++ install/build.ninja | 76 ++++++++++++++++++++++++++++ install/scripts/build.sh | 14 +++++ install/scripts/install_ezfio.sh | 22 ++++++++ install/scripts/install_f77_zmq.sh | 22 ++++++++ install/scripts/install_irpf90.sh | 28 ++++++++++ install/scripts/install_ninja.sh | 25 +++++++++ install/scripts/install_ocaml.sh | 47 +++++++++++++++++ install/scripts/install_ocaml_zmq.sh | 21 ++++++++ install/scripts/install_qmcchemrc.sh | 19 +++++++ install/scripts/install_zmq.sh | 28 ++++++++++ 12 files changed, 332 insertions(+) create mode 100755 configure.sh create mode 100644 install/build.ninja create mode 100755 install/scripts/build.sh create mode 100755 install/scripts/install_ezfio.sh create mode 100755 install/scripts/install_f77_zmq.sh create mode 100755 install/scripts/install_irpf90.sh create mode 100755 install/scripts/install_ninja.sh create mode 100755 install/scripts/install_ocaml.sh create mode 100755 install/scripts/install_ocaml_zmq.sh create mode 100755 install/scripts/install_qmcchemrc.sh create mode 100755 install/scripts/install_zmq.sh diff --git a/README.md b/README.md index f39e0d9..9f034bb 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,19 @@ diffusion Monte Carlo algorithm. software including (via compiler) GPL-licensed code must also be made available under the GPL along with build & install instructions. +Requirements +------------ + +* Ninja building system (replacement for GNU make) +* EZFIO library generator +* ZeroMQ library +* ZeroMQ Fortran77 binding +* IRPF90 Fortran code generator +* OCaml compiler +* Fortran compiler (Intel Fortran recommended) + +All the dependencies will be downloaded automatically + Example of a QMC=Chem calculation --------------------------------- diff --git a/configure.sh b/configure.sh new file mode 100755 index 0000000..c050d38 --- /dev/null +++ b/configure.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +set -e +set -u +cd install +mkdir -p Downloads _build +mkdir -p bin +if [[ ! -x ../bin/ninja ]] +then + echo "Installing Ninja" + ./scripts/install_ninja.sh &> _build/ninja.log + touch _build/ninja.ok +fi +touch ../{src,ocaml}/ls_md5 +exec ../bin/ninja "$@" + + diff --git a/install/build.ninja b/install/build.ninja new file mode 100644 index 0000000..07f3318 --- /dev/null +++ b/install/build.ninja @@ -0,0 +1,76 @@ +# This script should be run in the install dircetory + +# URLs +###### + +URL_OPAM ="http://raw.github.com/ocaml/opam/master/shell/opam_installer.sh" +URL_IRPF90="http://github.com/scemama/irpf90/archive/v1.6.7.tar.gz" +URL_EZFIO ="http://github.com/scemama/EZFIO/archive/v1.3.1.tar.gz" + +URL_ZMQ ="http://download.zeromq.org/zeromq-4.0.7.tar.gz" +#URL_ZMQ ="http://download.zeromq.org/zeromq-4.1.3.tar.gz" +URL_F77ZMQ="http://github.com/scemama/f77_zmq/archive/v4.1.3.tar.gz" + +# Rules +####### + +rule download + command = wget ${url} -O ${out} -o /dev/null + description = Downloading ${descr} + +rule install + command = ./scripts/install_${target}.sh > _build/${target}.log 2>&1 && touch _build/${target}.ok || cat _build/${target}.log + description = Installing ${descr} + + +# Builds +######## + +build Downloads/irpf90.tar.gz: download + url = ${URL_IRPF90} + descr = IRPF90 code generator + +build Downloads/ezfio.tar.gz: download + url = ${URL_EZFIO} + descr = EZFIO I/O library generator + +build Downloads/zmq.tar.gz: download + url = ${URL_ZMQ} + descr = ZeroMQ communication library + +build Downloads/f77_zmq.tar.gz: download + url = ${URL_F77ZMQ} + descr = Fortran ZeroMQ interface + +build Downloads/opam_installer.sh: download + url = ${URL_OPAM} + descr = OCaml OPAM installer + +build _build/irpf90.ok ../bin/irpman ../bin/irpf90: install | Downloads/irpf90.tar.gz + target = irpf90 + descr = IRPF90 + +build _build/zmq.ok ../lib/libzmq.a ../lib/libzmq.so.4 ../lib/libzmq.so ../lib/zmq.h ../lib/zmq_utils.h: install | Downloads/zmq.tar.gz + target = zmq + descr = ZeroMQ + +build _build/ezfio.ok: install | Downloads/ezfio.tar.gz _build/irpf90.ok ../bin/irpman ../bin/irpf90 + target = ezfio + descr = EZFIO + +build _build/f77_zmq.ok ../src/ZMQ/f77_zmq.h ../lib/libf77zmq.a ../lib/libf77zmq.so: install | Downloads/f77_zmq.tar.gz _build/zmq.ok ../lib/libzmq.a ../lib/libzmq.so.4 ../lib/libzmq.so ../lib/zmq.h ../lib/zmq_utils.h + target = f77_zmq + descr = Fortran ZeroMQ interface + +build _build/qmcchemrc.ok ../qmcchemrc: install | _build/irpf90.ok ../bin/irpman ../bin/irpf90 _build/ezfio.ok + target = qmcchemrc + description = QMC=Chem environment variables + +build _build/ocaml.ok ../bin/opam: install | Downloads/opam_installer.sh _build/qmcchemrc.ok ../qmcchemrc + target = ocaml + descr = Ocaml compiler + +build _build/ocaml_zmq.ok: install | ../bin/opam ../lib/libzmq.so ../lib/zmq.h ../lib/zmq_utils.h _build/ocaml.ok _build/zmq.ok ../lib/libzmq.a ../lib/libzmq.so.4 ../lib/libzmq.so ../lib/zmq.h ../lib/zmq_utils.h + target = ocaml_zmq + descr = Ocaml ZeroMQ interface + diff --git a/install/scripts/build.sh b/install/scripts/build.sh new file mode 100755 index 0000000..73a2f57 --- /dev/null +++ b/install/scripts/build.sh @@ -0,0 +1,14 @@ +#!/bin/bash -x +# This script should be included by all other scripts in this directory + +set -u # All variables should be defined +set -e # The script should exit if something goes wrong + +BUILD="_build/${TARGET}" +rm -rf -- "${BUILD}" +mkdir "${BUILD}" +tar -zxf "Downloads/${TARGET}.tar.gz" --strip-components=1 --directory="${BUILD}" +_install +rm -rf -- "${BUILD}" "${BUILD}.log" +exit 0 + diff --git a/install/scripts/install_ezfio.sh b/install/scripts/install_ezfio.sh new file mode 100755 index 0000000..3b3899e --- /dev/null +++ b/install/scripts/install_ezfio.sh @@ -0,0 +1,22 @@ +#!/bin/bash -x + +TARGET=ezfio + +function _install() +{ + set -e + set -u + cd .. + QMCCHEM_PATH="$PWD" + cd - + rm -rf "${QMCCHEM_PATH}"/EZFIO + cd "${BUILD}"/config + rm -f -- qmc.config properties.config + touch "${QMCCHEM_PATH}"/ezfio_config/properties.config + ln -s "${QMCCHEM_PATH}"/ezfio_config/qmc.config qmc.config + ln -s "${QMCCHEM_PATH}"/ezfio_config/properties.config properties.config + cd - + mv "${BUILD}" "${QMCCHEM_PATH}"/EZFIO +} + +source scripts/build.sh diff --git a/install/scripts/install_f77_zmq.sh b/install/scripts/install_f77_zmq.sh new file mode 100755 index 0000000..ecde0df --- /dev/null +++ b/install/scripts/install_f77_zmq.sh @@ -0,0 +1,22 @@ +#!/bin/bash -x + +TARGET=f77_zmq +function _install() +{ + set +u + export C_INCLUDE_PATH=$C_INCLUDE_PATH:../../../lib + set -e + set -u + cd "${BUILD}" + export ZMQ_H=../../../lib/zmq.h + cp "${ZMQ_H}" . + make -j + cd - + rm -f -- "../src/ZMQ/f77_zmq.h" "../lib/libf77zmq.a" "../lib/libf77zmq.so" + cp "${BUILD}"/libf77zmq.{a,so} ../lib/ + cp "${BUILD}"/f77_zmq.h ../src/ZMQ/ + return 0 +} + +source scripts/build.sh + diff --git a/install/scripts/install_irpf90.sh b/install/scripts/install_irpf90.sh new file mode 100755 index 0000000..a881336 --- /dev/null +++ b/install/scripts/install_irpf90.sh @@ -0,0 +1,28 @@ +#!/bin/bash -x + +TARGET=irpf90 +function _install() +{ + set -e + set -u + make -C "${BUILD}" -j + rm -rf -- ../irpf90 + mv "${BUILD}" ../ + # Check the build is OK + [[ -x ../irpf90/bin/irpf90 ]] + [[ -x ../irpf90/bin/irpman ]] + for i in irpf90 irpman + do + rm -rf -- ../bin/$i + cat << EOF > ../bin/$i +#!/bin/bash -u +exec "\${QMCCHEM_PATH}"/irpf90/bin/$i "\$@" +EOF + chmod +x ../bin/$i + done + return 0 +} + +source scripts/build.sh + + diff --git a/install/scripts/install_ninja.sh b/install/scripts/install_ninja.sh new file mode 100755 index 0000000..6b71b5c --- /dev/null +++ b/install/scripts/install_ninja.sh @@ -0,0 +1,25 @@ +#!/bin/bash -x + +set -u +set -e + +TARGET=ninja +URL="http://github.com/martine/ninja/archive/v1.5.3.tar.gz" + +function _install() +{ + set -e + set -u + cd "${BUILD}" + ./configure.py --bootstrap + cd - + mv "${BUILD}/ninja" ../bin/ + return 0 +} + +if [[ ! -f "Downloads/${TARGET}.tar.gz" ]] +then + wget ${URL} -O "Downloads/${TARGET}.tar.gz" +fi +source scripts/build.sh + diff --git a/install/scripts/install_ocaml.sh b/install/scripts/install_ocaml.sh new file mode 100755 index 0000000..eb1f5aa --- /dev/null +++ b/install/scripts/install_ocaml.sh @@ -0,0 +1,47 @@ +#!/bin/bash -x + +set -u +set -e + +PACKAGES="core cryptokit ocamlfind sexplib" + +declare -i i +i=$(gcc -dumpversion | cut -d '.' -f 2) +if [[ i -lt 6 ]] +then + echo "GCC version $(gcc -dumpversion) too old. GCC >= 4.6 required." + exit 1 +fi + +source ../qmcchemrc +cd Downloads +chmod +x opam_installer.sh + +if [[ -d "${HOME}"/.opam ]] +then + set +e + set +u + source "${HOME}"/.opam/opam-init/init.sh + set -e + set -u +fi + +echo N | ./opam_installer.sh "${QMCCHEM_PATH}"/bin/ +if [[ ! -f "${QMCCHEM_PATH}"/bin/opam ]] +then + echo "Installation of OPAM failed" + exit 2 +fi +"${QMCCHEM_PATH}"/bin/opam config setup -a --dot-profile "${QMCCHEM_PATH}"/qmcchemrc +touch "${QMCCHEM_PATH}"/bin/opam + +set +u +export LD_LIBRARY_PATH="${QMCCHEM_PATH}/lib:${LD_LIBRARY_PATH}" +export LIBRARY_PATH="${QMCCHEM_PATH}/lib:${LIBRARY_PATH}" +export C_INCLUDE_PATH="${QMCCHEM_PATH}/lib:${C_INCLUDE_PATH}" +set -u +opam install ${PACKAGES} +rm ../_build/ocaml.log +exit 0 + + diff --git a/install/scripts/install_ocaml_zmq.sh b/install/scripts/install_ocaml_zmq.sh new file mode 100755 index 0000000..925edd0 --- /dev/null +++ b/install/scripts/install_ocaml_zmq.sh @@ -0,0 +1,21 @@ +#!/bin/bash -x + +set -e +set -u + +declare -i i +i=$(gcc -dumpversion | cut -d '.' -f 2) +if [[ i -lt 6 ]] +then + echo "GCC version $(gcc -dumpversion) too old. GCC >= 4.6 required." + exit 1 +fi + +set +u +source ../qmcchemrc +set -u +opam install zmq +rm -f _build/ocaml_zmq.log +exit 0 + + diff --git a/install/scripts/install_qmcchemrc.sh b/install/scripts/install_qmcchemrc.sh new file mode 100755 index 0000000..476abe1 --- /dev/null +++ b/install/scripts/install_qmcchemrc.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +cd .. +cat << EOF > qmcchemrc +# QMC=Chem environment variables +export QMCCHEM_PATH=${PWD} +export PATH="\${QMCCHEM_PATH}/bin:\${PATH}" +export LD_LIBRARY_PATH="\${QMCCHEM_PATH}/lib:\${LD_LIBRARY_PATH}" +export LIBRARY_PATH="\${QMCCHEM_PATH}/lib:\${LIBRARY_PATH}" +export QMCCHEM_MPIRUN="mpirun" +export QMCCHEM_MPIRUN_FLAGS="--bind-to-core" +#export QMCCHEM_NIC=ib0 +source \${QMCCHEM_PATH}/irpf90/bin/irpman +source \${QMCCHEM_PATH}/EZFIO/Bash/ezfio.sh +EOF + +cd - +rm -f _build/qmcchemrc.log +exit 0 diff --git a/install/scripts/install_zmq.sh b/install/scripts/install_zmq.sh new file mode 100755 index 0000000..58a160c --- /dev/null +++ b/install/scripts/install_zmq.sh @@ -0,0 +1,28 @@ +#!/bin/bash -x + +TARGET=zmq +function _install() +{ + LIBVERSION=4 + set +u + export C_INCLUDE_PATH="${C_INCLUDE_PATH}":./ + set -e + set -u + cd "${BUILD}" + ./configure --without-libsodium + make -j 8 + cd - + rm -f -- ../lib/libzmq.a ../lib/libzmq.so ../lib/libzmq.so.$LIBVERSION +# cp "${BUILD}"/.libs/libzmq.a ../lib/ +# cp "${BUILD}"/.libs/libzmq.so ../lib/libzmq.so.$LIBVERSION + cp "${BUILD}"/src/.libs/libzmq.a ../lib/ + cp "${BUILD}"/src/.libs/libzmq.so ../lib/libzmq.so.$LIBVERSION + cp "${BUILD}"/include/{zmq,zmq_utils}.h ../lib/ + cd ../lib + ln libzmq.so.$LIBVERSION libzmq.so || cp libzmq.so.$LIBVERSION libzmq.so + cd - + return 0 +} + +source scripts/build.sh +