-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsubg09
304 lines (244 loc) · 7.72 KB
/
subg09
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
#!/bin/csh
# Gaussian 09 Interactive Job Submission on TAIWANIA cluster, NCHC, Taiwan
#
# Updated 20180622 Rangsiman Ketkaew [email protected]
# https://github.com/rangsimanketkaew/QM-on-TAIWANIA/
##############################################################
set G09_DIR = "/pkg/gaussian/g09/g09"
set G09_EXE = "$G09_DIR/g09"
##############################################################
set NBO_BIN = "/pkg/gaussian/nbo6/bin"
##############################################################
set PROJ_ID_FILE = "$HOME/.proj_id"
##############################################################
onintr inter
#Check if help is requested.
if ( "$1" == "-help" || "$1" == "--help" || "$1" == "-h" || "$1" == "help" ) goto help
if ( $#argv == 0) then
echo ""
echo " Gaussian 09 R. E01 Interactive Job Submission on TAIWANIA, NCHC, Taiwan"
echo " -----------------------------------------------------------------------"
echo ""
echo " Usage: subg09 input[.com] [output[.out]] [-help]"
echo ""
echo " Example: subg09 water_hf"
echo " subg09 water_hf.com water_hf_4cores.out"
echo ""
exit 0
else
set INPUTFILE = "$1"
endif
#Check if Gaussian directory exists
if (! -e $G09_DIR) then
echo "Error: Unable to locate Gaussian 09 directory, $G09_DIR."
echo "Please set the suitable path of Gaussian 09 at the beginning lines of this program source code."
exit 1
endif
if (! -e $G09_EXE) then
echo "Error: Unable to locate g09 executable, please check again."
exit 1
endif
set INPUTNAME = `basename $INPUTFILE .com`
set REALNAME_INP = "$INPUTNAME".com
set REALPATH = `realpath $REALNAME_INP`
set DIR_PATH = `dirname $REALPATH`
set INPUTFILE = "$DIR_PATH/$INPUTNAME".com
if (! -f $INPUTFILE) then
echo "Error: Unable to locate $INPUTFILE"
exit 1
endif
if ("null$2" == "null") then
set OUTPUTNAME = "$INPUTNAME"
set OUTPUTFILE = "$DIR_PATH/$INPUTNAME".out
set REALNAME_OUT = "$INPUTNAME".out
else
set OUTPUTNAME = `basename $2 .out`
set OUTPUTFILE = "$DIR_PATH/$OUTPUTNAME".out
set REALNAME_OUT = "$OUTPUTNAME".out
endif
set JOBNAME = "$OUTPUTNAME"
if ( `grep -ic '%gpucpu' $INPUTFILE` == 1 ) then
echo "Error: GPU accelerator is not supported in Gaussian 09, please use Gaussian 16 instead."
exit 1
else
if ( `grep -ic '\-\-link1\-\-' $INPUTFILE` >= 1 ) then
@ NUMJOB = ( `grep -ic '\-\-link1\-\-' $INPUTFILE` + 1 )
echo ""
echo "Warning: $INPUTNAME.com contains $NUMJOB calculations"
endif
if ( `grep -ic '%nprocshared' $INPUTFILE` >= 1 ) then
set GREPPAT = "%nprocshared"
else if ( `grep -ic '%nprocs' $INPUTFILE` >= 1 ) then
set GREPPAT = "%nprocs"
else
echo 'Warning: No %NProcShared specified in input file. Hence, number of CPU cores will be set to 1.'
set NPROCS = 1
set JOBQUEUE = serial
goto set_node
endif
set NPROCS_LIST = ( `grep -i "$GREPPAT" $INPUTFILE | cut -d= -f2` )
set NPROCS = "$NPROCS_LIST[1]"
if ( `echo $NPROCS | grep -c '[a-z][A-Z]'` == 1 ) then
echo "Error: Number of $GREPPAT specified in input must be positive integer from 1 to 40."
exit 1
endif
if ( $NPROCS >= 41 ) then
echo "Warning: Value of $GREPPAT is over 40. So $GREPPAT will be set to 40."
set NPROCS = 40
endif
if ( $NPROCS == 1 ) then
set JOBQUEUE = serial
goto set_node
endif
check_queue:
echo ""
echo "Optimal job queues: "
echo " [1] ctest"
echo " [2] cf40"
echo ""
echo -n "Enter job queue [2]: "
set INPQUEUE = "$<"
if ( "null$INPQUEUE" == "null" || $INPQUEUE == 2 ) then
set JOBQUEUE = cf40
else if ( $INPQUEUE == 1 ) then
set JOBQUEUE = ctest
else
echo "Error: Your choice is incorrect."
goto check_queue
endif
set_node:
set NODES = 1
set THREADS = "$NPROCS"
set LISTID = ( `get_su_balance | awk -F, '{print $2}' | xargs` )
if ( "$LISTID" == "" ) then
echo "Error: No available Project ID."
exit 1
else if ( $#LISTID == 1 ) then
set PROJ_ID = "$LISTID[1]"
goto jobinfo
endif
if ( -f $PROJ_ID_FILE ) then
set PROJID_1 = `head -1 $PROJ_ID_FILE`
if ( `get_su_balance | grep -wc "$PROJID_1"` == 0 ) then
echo "Error: Project ID specified in first line of $PROJ_ID_FILE is not correct."
exit 1
endif
set PROJ_ID = "$PROJID_1"
goto jobinfo
endif
set BALANCE = ( `get_su_balance | awk -F, '{print $1}' | xargs` )
echo ""
echo " Your available Project ID & SU Balance:"
@ i = 1
while ( $i <= $#LISTID )
echo " [$i] $LISTID[$i] $BALANCE[$i]"
set PROJ_ID = "$LISTID[1]"
@ i++
end
echo ""
ask_id_choice:
echo -n "Enter Project ID [1]: "
set PROJINP = "$<"
if ( "null$PROJINP" == "null" ) then
set PROJ_ID = "$LISTID[1]"
goto jobinfo
endif
if ( `echo $PROJINP | grep -c '[a-z][A-Z]*'` == 1 ) then
echo "Error: Please assign choice as positive integer."
goto ask_id_choice
endif
if ( $PROJINP > $#LISTID || $PROJINP <= 0 ) then
echo "Error: Choice you selected is out of range."
goto ask_id_choice
else
set PROJ_ID = "$LISTID[$PROJINP]"
endif
jobinfo:
#####################################################
# Show all info before submitting job
#####################################################
echo ""
echo " =========================== $ Job Information $ =========================="
echo " Run on `date` by `whoami`"
echo ""
echo " Gaussian 09 = $G09_EXE"
echo " Working directory = $DIR_PATH"
echo ""
echo " Input file = $REALNAME_INP"
echo " Output file = $REALNAME_OUT"
echo ""
echo " Compute node = $NODES"
echo " CPU cores = $NPROCS"
echo " OMP Threads = $THREADS"
echo " Job Name = $OUTPUTNAME"
echo " Job Queue = $JOBQUEUE"
echo " Project ID = $PROJ_ID"
echo " =========================== $ Job Information $ =========================="
echo ""
echo -n "Submit your job now ? [yes]: "
set SUBMIT = "$<"
if ("null$SUBMIT" == "null" || "null$SUBMIT" == "nully" || "null$SUBMIT" == "nullyes") then
goto submit
else
echo "...Quit..."
exit 0
endif
submit:
set PBS_SCRIPT = "$DIR_PATH/submit.G09.$OUTPUTNAME.sh"
cat <<EOF > $PBS_SCRIPT
#!/bin/bash
#PBS -l select=${NODES}:ncpus=${NPROCS}:ompthreads=${THREADS}
#PBS -q $JOBQUEUE
#PBS -N $JOBNAME
#PBS -P $PROJ_ID
#############################################################
#### This PBS Pro script was generated by subg09 program ####
#############################################################
module purge
cd \$PBS_O_WORKDIR
export SCRATCH_DIR=/work1/$USER/SCRATCH/g09/g09.pbs\${PBS_JOBID/\.srvc1/}
if [ ! -d \$SCRATCH_DIR ]; then mkdir -p \$SCRATCH_DIR; fi
export g09root="$G09_DIR"
. \$g09root/bsd/g09.profile
export PATH="${NBO_BIN}:\$PATH"
export GAUSS_SCRDIR="\$SCRATCH_DIR"
export GAUSS_EXEDIR="\$g09root/"
export GAUSS_EXECUT="\$g09root/g09"
export DIR_PATH="$DIR_PATH"
\$GAUSS_EXECUT < \
\$DIR_PATH/$REALNAME_INP > \
\$DIR_PATH/$REALNAME_OUT
EOF
qsub $PBS_SCRIPT
#echo "Your job has been submitted."
exit 0
help:
clear
cat << EOF | less
--------------------------------------
Gaussian 09 Interactive Job Submission
--------------------------------------
======
subg09
======
subg09 is used to submit shared-memory Gaussian 09 calculation on a single node.
subg09 determines the number of OMP threads by the value of %nprocs line in input file.
Sensible value of %nprocs are: 1, 2, 4, 8, 12, 16, 24, 32, and 36.
TAIWANIA Policy: Max value of %nprocs is 40.
If %nprocs is set to 1, G09 job will be submitted in serial queue.
If %nprocs is 2 through 40, G09 job will be submitted in cf40 queue.
======
AUTHOR
======
Rangsiman Ketkaew (MSc student)
E-mail: [email protected]
Computational Chemistry Research Unit
Department of Chemistry
Faculty of Science and Technology
Thammasat University, Thailand
EOF
inter:
echo ""
echo "Error: you pressed Ctrl+C ...Quit..."
echo ""
exit 1