Commit 38fde2e6 authored by Christian Meesters's avatar Christian Meesters

master script as shipped from AK Heinze to fkreuter (m2_jgu-hgi)

parents
#!/bin/bash
mkdir Submitted
mkdir Running
mkdir Input
mkdir Output
mkdir Finished
mkdir orcaplot
mkdir Transfer
read -p "Bitte ZDV Username eingeben " NAME
# unix2dos Script
echo -e '#! /bin/bash
if [ ! "$1" ] ; then
echo `basename $0` file ...
echo ' convert' files from unix to dos file format
exit 1
fi
while [ "$1" ] ; do
TMP=$1.$$
awk sub("$", "blar")blub $1 > $TMP
cp -f "$TMP" "$1"
rm -f "$TMP"
shift
done ' > unix2dos.sh
# Modules-Script
# echo " module load /cluster/modulefiles/gcc/4.8.1
# module load /cluster/modulefiles/mpi/openmpi/1.6.5/gcc_4.8.1
# module load /cluster/modulefiles/software/orca/3.0.2" > modules.sh
# Submit-Script
echo -e '#!/bin/bash
#-----------------------------------------------------------------
# Example SLURM job script to run MPI Job on Mogon.
#
# This script requests 128 cores on two node. The job
# will have access to all the memory in the nodes.
#-----------------------------------------------------------------
# Load all necessary modules if needed (these are examples)
# Loading modules in the script ensures a consistent environment.
# module load /cluster/modulefiles/gcc/4.8.1
# module load /cluster/modulefiles/mpi/openmpi/1.6.5/gcc_4.8.1
module use /cluster/easybuild/nehalem/modules/all
module load chem/ORCA/4.0.1-OpenMPI-2.0.2
inputdir="/home/benutzername/Input"
submitdir="/home/benutzername/Submitted"
outputdir="/home/benutzername/Output"
echo "Remember to use 64 cores only on nodelong and nodeshort!"
# Processor settings
read -p "Number of Processors to be used in calculation? (recommended between 4 and 32, maximum 64) " PROCS
sed -i "s/nprocs.*$/nprocs ${PROCS}/g" Input/*.gjf
# Queue Settings
read -p "long [l] or short [s] or nodelong [n] or nodeshort [t] queue? " QUEUE
QUEUE1=s
QUEUE2=l
QUEUE3=n
QUEUE4=t
QUEUE5=Max
if [ ${QUEUE} = ${QUEUE1} ]; then
echo "s was found, using short queue"
QUEUE=short
RUN=05:00:00
NODES=1
fi
if [ ${QUEUE} = ${QUEUE2} ]; then
echo "l was found, using long queue"
QUEUE=long
RUN=120:00:00
NODES=1
fi
if [ ${QUEUE} = ${QUEUE3} ]; then
echo "nodelong was found, using nodelong queue"
QUEUE=nodelong
RUN=120:00:00
NODES=1
fi
if [ ${QUEUE} = ${QUEUE4} ]; then
echo "nodeshort was found, using nodeshort queue"
QUEUE=nodeshort
RUN=05:00:00
NODES=1
fi
if [ ${QUEUE} = ${QUEUE5} ]; then
echo "You have been Maxed!!!!!"
QUEUE=short
RUN=00:00:10
NODES=1
fi
FILE=0
InPath="${inputdir}/*.gjf"
for FILE in $InPath ; do
if [ -s ${FILE} ]
then
FILENAME=${FILE##*/}
FILENAME=${FILENAME%.*}
# echo "##############################################################"
# echo $(dirname "${FILE}")
# echo ${FILE}
# echo ${FILENAME}
JOB=${FILENAME:0:5}
echo ${FILE} was submitted as ${JOB}. If you have questions ask Thomas.
mv "${inputdir}/${FILENAME}".* "${submitdir}/"
outputpath="${outputdir}/${FILENAME}.out"
# echo ${outputpath}
# Launch the executable
SubFile="${submitdir}/${FILENAME}.gjf"
sbatch -A mogon2users -p ${QUEUE} -J ${JOB} -o ${outputpath} -n ${PROCS} -t ${RUN} --mem-per-cpu=1800 --signal=B:SIGUSR2@600 -N ${NODES} ./orca.sh ${SubFile}
FILENAME=""
fi
done' > submit.sh
echo -e '#!/bin/bash
SubFile=$1
inputdir="/home/benutzername/Input"
submitdir="/home/benutzername/Submitted"
outputdir="/home/benutzername/Output"
rundir="/home/benutzername/Running"
findir="/home/benutzername/Finished"
# Store working directory to be safe
SAVEDPWD=$(pwd)
# We define a bash function to do the cleaning when the signal is caught
cleanup(){
for FILE3 in "${rundir}"/*.gjf ; do
if [ -s ${FILE3} ]
then
FILENAME=${FILE3##*/}
FILENAME=${FILENAME%.*}
rm /localscratch/${SLURM_JOB_ID}/*.tmp
cp /localscratch/${SLURM_JOB_ID}/* "${outputdir}"/
mv "${rundir}"/${FILENAME}.* "${findir}"/
echo Cleanup was working. EzPz.
exit 0
fi
done
}
# Register the cleanup function when SIGUSR2 is sent,
# ten minutes before the job gets killed
trap 'cleanup' SIGUSR2
# Copy input file
#SubFile="${submitdir}/*.gjf"
# echo ${SubFile}
for FILE2 in ${SubFile} ; do
if [ -s ${FILE2} ]
then
FILENAME=${FILE2##*/}
FILENAME=${FILENAME%.*}
# ls /localscratch/
cp "${submitdir}/${FILENAME}".* /localscratch/${SLURM_JOB_ID}
mv "${submitdir}/${FILENAME}".* "${rundir}/"
# Go to jobdir and start the program
cd /localscratch/${SLURM_JOB_ID}
set OMPI_MCA_btl=self,sm
/cluster/easybuild/nehalem/software/chem/ORCA/4.0.1-OpenMPI-2.0.2/orca ${FILENAME}.gjf &
wait
FILENAME=""
fi
done
# Call the cleanup function when everything went fine
cleanup
' > orca.sh
# Transfer-files script
echo -e '#!/bin/bash
#!/bin/bash
cp Output/* Transfer/
for FILE in "/home/benutzername/Transfer"/*.opt ; do
if [ -s ${FILE} ]
then
echo ${FILE}
/home/benutzername/unix2dos.sh ${FILE}
fi
done
for FILE in "/home/benutzername/Transfer"/*.trj ; do
if [ -s ${FILE} ]
then
echo ${FILE}
/home/benutzername/unix2dos.sh ${FILE}
fi
done
for FILE in "/home/benutzername/Transfer"/*.engrad ; do
if [ -s ${FILE} ]
then
echo ${FILE}
/home/benutzername/unix2dos.sh ${FILE}
fi
done
for FILE in "/home/benutzername/Transfer"/*.gjf ; do
if [ -s ${FILE} ]
then
echo ${FILE}
/home/benutzername/unix2dos.sh ${FILE}
fi
done
for FILE in "/home/benutzername/Transfer"/*.out ; do
if [ -s ${FILE} ]
then
echo ${FILE}
/home/benutzername/unix2dos.sh ${FILE}
fi
done
for FILE in "/home/benutzername/Transfer"/*.hess ; do
if [ -s ${FILE} ]
then
echo ${FILE}
/home/benutzername/unix2dos.sh ${FILE}
fi
done
for FILE in Transfer/*.xyz ; do
if [ -s ${FILE} ]
then
echo ${FILE}
/home/benutzername/unix2dos.sh ${FILE}
fi
done
scp Transfer/* benutzername@ftp.uni-mainz.de:Rechnungen/Orca/Fertig
rm Transfer/*
' > transfer-files.sh
chmod +x *.sh
sed -i "s/benutzername/${NAME}/g" transfer-files.sh
sed -i "s/benutzername/${NAME}/g" orca.sh
sed -i "s/benutzername/${NAME}/g" submit.sh
sed -i 's/bla/\\/g' unix2dos.sh
sed -i "s/sub/'sub/g" unix2dos.sh
sed -i "s/blub/'/g" unix2dos.sh
sed -i "s/trap cleanup SIGUSR2/trap 'cleanup' SIGUSR2/g" orca.sh
sed -i "s/span/'span/g" submit.sh
sed -i "s/ -app/' -app/g" submit.sh
echo "Directories and files have been created successfully"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment