10
0
mirror of https://github.com/LCPQ/quantum_package synced 2024-12-22 20:35:19 +01:00

Changed Ocaml Installer

This commit is contained in:
Anthony Scemama 2015-03-24 16:12:51 +01:00
parent 85d611c1ba
commit c073338486
4 changed files with 40 additions and 167 deletions

12
.travis.yml Normal file
View File

@ -0,0 +1,12 @@
sudo: true
before_script:
- sudo apt-get update
- sudo apt-get install gfortran liblapack-dev zip
script:
- ./setup_environment.sh
- source ./quantum_package.rc
- cp ./src/Makefile.config.gfortran ./src/Makefile.config
- make build

View File

@ -4,6 +4,7 @@
# Thu Oct 23 21:58:40 CEST 2014
PACKAGES="core cryptokit"
OPAM_BASE=$HOME/.opam
# Check the QPACKAGE_ROOT directory
if [[ -z ${QPACKAGE_ROOT} ]]
@ -16,37 +17,48 @@ fi
cd ${QPACKAGE_ROOT}
function asksure() {
echo -n "Are you sure (Y/N)? "
return $retval
}
if [[ -f quantum_package.rc ]]
then
source quantum_package.rc
fi
make -C ocaml Qptypes.ml &> /dev/null
if [[ $? -ne 0 ]]
then
if [[ -d ${OCAMLBREW_BASE} ]]
if [[ -d ${OPAM_BASE} ]]
then
echo "Remove directory ${OCAMLBREW_BASE} ? [Y/n]"
echo "${OPAM_BASE} exists."
echo "Re-install ? [y/N]"
while read -r -n 1 -s answer; do
if [[ $answer = [YyNn] ]]; then
[[ $answer = [Yy] ]] && rm -rf -- ${HOME}/ocamlbrew
[[ $answer = [Nn] ]] && exit 1
break
if [[ $answer = [Yy] ]] ; then
echo " - Remove your directory ${OPAM_BASE}"
echo " - Restart setup"
exit 1
fi
if [[ $answer = [Nn] ]] ; then
make -C ocaml Qptypes.ml
exit 0
fi
fi
done
echo $answer
fi
scripts/fetch_from_web.py "https://raw.github.com/hcarty/ocamlbrew/master/ocamlbrew-install" ocamlbrew-install.sh
cat < ocamlbrew-install.sh | env OCAMLBREW_FLAGS="-r" bash | tee ocamlbrew_install.log
grep "source " ocamlbrew_install.log | grep "etc/ocamlbrew.bashrc" >> quantum_package.rc
source quantum_package.rc
echo Y | opam install ${PACKAGES}
fi
scripts/fetch_from_web.py "https://raw.github.com/ocaml/opam/master/shell/opam_installer.sh" opam_installer.sh
chmod +x opam_installer.sh
echo N | ./opam_installer.sh ${QPACKAGE_ROOT}/bin
if [[ ! -f ${QPACKAGE_ROOT}/bin/opam ]]; then
echo "Installation of OPAM failed"
exit 2
fi
${QPACKAGE_ROOT}/bin/opam config setup -a --dot-profile ${QPACKAGE_ROOT}/quantum_package.rc
source ${QPACKAGE_ROOT}/quantum_package.rc
echo Y | opam install ${PACKAGES}
make -C ocaml Qptypes.ml
exit 0

View File

@ -1,149 +0,0 @@
#!/bin/bash
#
# Runs the programs.
# Thu Jun 26 23:40:20 CEST 2014
# Check environment
###################
if [[ -z $QPACKAGE_ROOT ]]
then
echo "Error:"
echo "QPACKAGE_ROOT environment variable is not set."
echo "source quantum_package.rc"
exit 1
fi
# List of executables
#####################
declare -A EXECUTABLES
for EXE in $(find $QPACKAGE_ROOT/src -type f -executable | grep -e "$QPACKAGE_ROOT/src/[^/]*/[^/]*$")
do
EXECUTABLES[$(basename ${EXE})]="${EXE}"
done
function print_list()
{
echo
echo "Available programs:"
echo
for EXE in ${!EXECUTABLES[@]}
do
printf " * %-30s [ %s ]\n" $EXE ${EXECUTABLES[$EXE]}
done | sort
echo
}
# Help message
##############
function print_help()
{
cat << EOF
Usage:
qpackage -h | --help
qpackage -l | --list
qpackage run <program> <EZFIO_input>
qpackage reset <EZFIO_input>
Options:
-h --help Print help message
-l --list List executables
EOF
}
ARGS=$(getopt -o "hl" -l "help,list" -n $0 -- "$@")
[[ $? -eq 0 ]] || exit 1
eval set -- "$ARGS"
while true
do
case "$1" in
-h|--help)
print_help
exit 0
shift ;;
-l|--list)
print_list
exit 0
shift ;;
--)
shift
break;;
esac
done
# Run commands
##############
function run()
{
# run $EXE $EZFIO
# Starts the executable in one process and
# displays the output files in stdout
if [[ -z $1 ]] ; then
echo "Please specify which executable to run"
print_list
exit 1
fi
EXE=${EXECUTABLES[$1]}
EZFIO=$2
if [[ -z $EXE ]] ; then
echo "Executable $1 not found"
exit 1
fi
if [[ -z $EZFIO ]] ; then
echo "Please specify an EZFIO directory"
exit 1
fi
date
rm -rf -- ${EZFIO}/output
${QPACKAGE_ROOT}/scripts/follow_output.py ${EZFIO} &
PID=$!
${EXE} ${EZFIO}
kill -2 $PID
if [[ $(jobs | wc -l) -gt 0 ]]
then
sleep 1
kill -9 $PID
fi
wait
date
}
function reset()
{
# reset $EZFIO
EZFIO=$1
if [[ -z ${EZFIO} ]] ; then
echo "Please specify an EZFIO directory"
exit 1
fi
rm -rf -- ${EZFIO}/output/*.rst
rm -rf -- ${EZFIO}/determinants/{n_det,psi_det.gz,psi_coef.gz}
}
COMMAND=$1
shift
case "${COMMAND}" in
run)
run $1 $2
;;
reset)
reset $1
;;
*)
print_help
;;
esac

View File

@ -30,7 +30,6 @@ fi
cat << EOF > quantum_package.rc
export IRPF90="${IRPF90}"
export OCAMLBREW_BASE="${OCAMLBREW_BASE}"
export QPACKAGE_ROOT=\$( cd \$(dirname "\${BASH_SOURCE}") ; pwd -P )
export LD_LIBRARY_PATH="\${QPACKAGE_ROOT}"/lib:\${LD_LIBRARY_PATH}
export LIBRARY_PATH="\${QPACKAGE_ROOT}"/lib:\${LIBRARY_PATH}
@ -40,7 +39,6 @@ export PATH=\${PATH}:"\${QPACKAGE_ROOT}"/scripts
export PATH=\${PATH}:"\${QPACKAGE_ROOT}"/bin
export PATH=\${PATH}:"\${QPACKAGE_ROOT}"/ocaml
source "\${QPACKAGE_ROOT}"/bin/irpman &> /dev/null
source "\${OCAMLBREW_BASE}"/ocaml-4*/etc/ocamlbrew.bashrc &> /dev/null
EOF
source quantum_package.rc