1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157
|
#!/bin/sh
#***********************************************************************
# This file is part of OpenMolcas. *
# *
# OpenMolcas is free software; you can redistribute it and/or modify *
# it under the terms of the GNU Lesser General Public License, v. 2.1. *
# OpenMolcas is distributed in the hope that it will be useful, but it *
# is provided "as is" and without any express or implied warranties. *
# For more details see the full text of the license in the file *
# LICENSE or in <http://www.gnu.org/licenses/>. *
#***********************************************************************
# Tinker version to which the QM/MM patch can be applied
TINKERVERSION='tinker-6.3.3'
PATCH=patch_$TINKERVERSION.diff
usage() {
echo "Usage:" get_tinker [OPTIONS]
echo "Download, patch and compile $TINKERVERSION for QM/MM calculations"
echo "Available options:"
echo " -h this help"
echo " -d download tinker and exit"
}
do_skip=0
#manif [ $# -eq 0 ]; then usage; exit 2; fi
while getopts ":hd" opt ; do
case $opt in
d)
do_skip=1
;;
h)
usage
exit 0
;;
\?)
echo "Invalid option: -$OPTARG"
exit 2
;;
:)
echo "Option -$OPTARG requires an argument."
exit 2
;;
esac
done
# Check the MOLCAS env
if [ -f .molcashome ] ; then
MOLCAS=`pwd`
elif [ -f ../.molcashome ] ; then
MOLCAS=`cd ..; pwd`
elif [ -f ../../.molcashome ] ; then
MOLCAS=`cd ../..; pwd`
elif [ -f ../../../.molcashome ] ; then
MOLCAS=`cd ../../..; pwd`
fi
if [ -z "$MOLCAS" ]; then
echo "MOLCAS is not set."
exit 2
fi
echo "Tinker will be downloaded to $MOLCAS"
echo "Is this OK? [Y/n]"
while true; do
read answer
case "${answer}_" in
[Yy]*|_ )
break ;;
[Nn]* )
exit 0
break ;;
* ) echo "Please answer yes or no"
esac
done
DIR=`( cd \`dirname -- "$0"\` ; pwd )`
cd $MOLCAS
# Download Tinker
if [ -d $TINKERVERSION ]; then
echo "Original $TINKERVERSION already installed."
else
if [ -h tinker ]; then
rm -f tinker
elif [ -d tinker ]; then
echo "Existing tinker directory."
echo "Please rename it before running get_tinker again."
exit 2
elif [ -e tinker ]; then
echo "Existing tinker."
echo "Cannot determine what kind of file it is."
echo "Please correct it manually before running get_tinker again."
exit 2
else
echo "Downloading $TINKERVERSION"
fi
wget http://dasher.wustl.edu/tinker/downloads/$TINKERVERSION.tar.gz
gzip -d $TINKERVERSION.tar.gz
tar -xf $TINKERVERSION.tar
if [ $? != 0 ]; then
echo "Unpacking Tinker failed."
exit 2
fi
mv -f tinker $TINKERVERSION
ln -fs $TINKERVERSION tinker
echo "The tinker symbolic link has been set to $TINKERVERSION"
fi
# Exit here if the QM/MM patch does not interest you
if [ $do_skip -eq 1 ]; then
echo "Tinker has not been patched for QM/MM."
echo "Please finish the install."
exit 0
fi
# Test if tinker has been already patched. If so, revert the patch.
cd $MOLCAS/tinker/source
if [ -f QMMM_patched ]; then
echo "$TINKERVERSION already patched. Version:"
cat QMMM_patched
echo "Reverting this old patch."
if [ -f $PATCH ]; then
mv Makefile.orig Makefile
patch -R <$PATCH
else
echo "Cannot revert. Please proceed with a fresh install."
exit 2
fi
fi
# Apply the last available patch, found in Tools/patch2tinker.
if [ -f "$DIR/$PATCH" ]; then
cp -f "$DIR/$PATCH" .
patch <$PATCH
if [ $? != 0 ]; then
echo "Patching failed. Check that you have patch installed."
exit 2
else
date "+%D" > $MOLCAS/tinker/source/QMMM_patched
fi
else
echo "$DIR/$PATCH not found."
exit 2
fi
# Adaptation of the Makefile is required
echo "Modifying Tinker Makefile."
mv Makefile Makefile.orig
sed -e "/^TINKERDIR/s#.*#TINKERDIR = $MOLCAS\/tinker#" Makefile.orig > Makefile
if [ ! -d ../bin ]; then
mkdir ../bin
fi
# Tinker compilation
echo "Now relax during the compilation."
make clean || exit 3
make all || exit 3
make rename || exit 3
echo "Tinker compilation completed."
|