Statistics
| Revision:

chimie4psmn / submit / gaussian / sub_gaussian09.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
g09root=/home/tjiang/softs/gaussian/g09d01
23
source $g09root/g09/bsd/g09.profile
24
export Gaussian=$g09root/g09/g09
25

    
26
export RSHCOMMAND=ssh
27
export P4_RSHCOMMAND=ssh
28

    
29
#export LD_LIBRARY_PATH=/softs/acml/acml2.7.0/pathscale64/lib:/softs/fftw/2.1.5/ps-ib/lib:$LD_LIBRARY_PATH:/usr/lib
30

    
31
cd ${SGE_O_WORKDIR}
32

    
33
echo "########## debut env##################"
34
env
35
echo "########## fin env ##################"
36

    
37
echo "########## Hostname ##################"
38
hostname
39

    
40
HOMEDIR=${SGE_O_WORKDIR}
41
cd ${HOMEDIR}
42

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

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

    
66
# Gaussian specific ScratchDir
67
#export GAUSS_SCRDIR=${CalcDir}
68

    
69
Machine=$(hostname)
70

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

    
88
cp ${HOMEDIR}/${job}.${ExtIn} ${CalcDir}/
89

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

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

    
113
cd ${CalcDir}
114
echo ${CalcDir}
115
ls -al
116

    
117
echo "time ${Gaussian} < ${job}.${ExtIn} > ${HOMEDIR}/${job}.${ExtOut}"
118

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

    
122
cp * ${HOMEDIR}/
123

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

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