Statistics
| Revision:

chimie4psmn / submit / gaussian / sub_gaussian16.sh @ 55

History | View | Annotate | Download (3.2 kB)

1
#!/bin/bash
2
#$ -S /bin/bash
3
#$ -N test
4
#$ -o $JOB_NAME.batch-log
5
#$ -j y
6
#$ -cwd
7
#$ -V
8
#$ -q E5*
9
##$ -pe gaussian8 8
10
#$ -pe openmp8 8
11

    
12
# Version: $Id$
13

    
14
# trace script (debug purpose, not mandatory)
15
set -x
16
# set globals
17
job=structure11
18
ExtIn=com
19
ExtOut=log
20

    
21
# Environment setting for gaussian 
22
module use /home/tjiang/modules/lmod
23
module load gaussian/g16-avx
24
#module load gaussian/g16-avx2
25
source $g16root/g16/bsd/g16.profile
26
export Gaussian=$g16root/g16/g16
27
#export LD_LIBRARY_PATH=/softs/acml/acml2.7.0/pathscale64/lib:/softs/fftw/2.1.5/ps-ib/lib:$LD_LIBRARY_PATH:/usr/lib
28

    
29
cd ${SGE_O_WORKDIR}
30

    
31
echo "########## debut env##################"
32
env
33
echo "########## fin env ##################"
34

    
35
echo "########## Hostname ##################"
36
hostname
37

    
38
HOMEDIR=${SGE_O_WORKDIR}
39
cd ${HOMEDIR}
40

    
41
# Replace 'home' by 'scratch', from SGE_O_WORKDIR, store to SCRATCHDIR
42
SCRATCHDIR=/scratch/$USER/$JOB_ID/
43
# check if scratch exist, create or complain
44
if [[ -d "/scratch" ]]
45
then
46
    mkdir -p ${SCRATCHDIR}
47
else
48
    echo "/scratch not found, cannot create ${SCRATCHDIR}"
49
fi
50

    
51
# check if scratchdir is OK
52
echo "ok" >  ${SCRATCHDIR}/toto
53
Ok=$(cat  ${SCRATCHDIR}/toto)
54
if [[ "${Ok}" != "ok" ]]
55
then
56
    # if scratch is unavailable, fallback to home
57
    CalcDir="${SGE_O_WORKDIR}/scratch"_${job}
58
    mkdir -p ${CalcDir}
59
else
60
    CalcDir=${SCRATCHDIR}
61
fi
62
#mkdir -p ${CalcDir}
63

    
64
# Gaussian specific ScratchDir
65
export GAUSS_SCRDIR=${CalcDir}
66

    
67
Machine=$(hostname)
68

    
69
# check if there is a chk or chk.gz
70
# TODO/FIXME there's a problem here, watching the trace: if no chk, it create a .chk.chk
71
NChk=` grep -i "chk" ${job}.${ExtIn} | head -1 | sed 's/=/ /g' | awk '{print $2}'`
72
if [ "$NChk" != "" ]
73
then
74
NChk=` basename $NChk .chk`.chk
75
fi
76
if [[ -s ${HOMEDIR}/${NChk} ]]
77
then
78
    cp ${HOMEDIR}/${NChk} ${CalcDir}/${NChk}
79
fi
80
if [[ -s ${HOMEDIR}/${NChk}.gz ]]
81
then
82
    cp ${HOMEDIR}/${NChk}.gz ${CalcDir}/${NChk}.gz
83
    gunzip ${CalcDir}/${NChk}.gz
84
fi
85

    
86
cp ${HOMEDIR}/${job}.${ExtIn} ${CalcDir}/
87

    
88
# prepare postprocess script
89
# TODO/FIXME is this still usefull ?
90
# - compress .chk
91
# - copy chk from $SCRATCHDIR to $HOMEDIR
92
# - cleanup $SCRATCHDIR
93
# add exec mode on script
94
#echo "ssh ${SGE_O_LOGNAME}@${Machine} gzip ${CalcDir}/*.chk " > ${HOMEDIR}/${job}_${Machine}_CLEAN.${ExtOut}
95
#echo "scp ${SGE_O_LOGNAME}@${Machine}:${CalcDir}/* ." > ${HOMEDIR}/${job}_${Machine}_CLEAN.${ExtOut}
96
#echo "ssh ${SGE_O_LOGNAME}@${Machine} rm -fr ${CalcDir}" >> ${HOMEDIR}/${job}_${Machine}_CLEAN.${ExtOut}
97
#echo "rm ${job}_${Machine}_CLEAN.${ExtOut}" >> ${HOMEDIR}/${job}_${Machine}_CLEAN.${ExtOut}
98
#chmod u+x ${HOMEDIR}/${job}_${Machine}_CLEAN.${ExtOut}
99

    
100
# logrotate old logs
101
if [[ -s ${HOMEDIR}/${job}.${ExtOut} ]]
102
then
103
    Ext=1
104
    while [[ -s ${HOMEDIR}/${job}.${ExtOut}_${Ext} ]]
105
    do
106
        let Ext=Ext+1
107
    done
108
    mv ${HOMEDIR}/${job}.${ExtOut} ${HOMEDIR}/${job}.${ExtOut}_${Ext}
109
fi
110

    
111
cd ${CalcDir}
112
echo ${CalcDir}
113
ls -al
114

    
115
echo "time ${Gaussian} < ${job}.${ExtIn} > ${HOMEDIR}/${job}.${ExtOut}"
116

    
117
#/usr/bin/time ${Gaussian} < ${job}.${ExtIn} > ${HOMEDIR}/${job}.${ExtOut}
118
${Gaussian} < ${job}.${ExtIn} > ${HOMEDIR}/${job}.${ExtOut}
119

    
120
cp * ${HOMEDIR}/
121

    
122
if [[ -s ${NChk} ]]
123
then
124
    gzip -9 ${NChk}
125
    cp ${NChk}.gz ${HOMEDIR}/
126
fi
127

    
128
# final cleanup (commented during debug)
129
#rm -r ${GAUSS_SCRDIR}
130
#rm -r ${CalcDir}