2 ##########################SYSTEM SPECIFIC VARIBLES######################
3 ##########please change to suit your local setup. ######################
7 # First, lets define all system specific variables
9 # The location of this file and the executable.
10 set mopacdir = /usr/users/stewart/mopac6
12 # The name of the "normal" mopac executable. (commonly the small version)
13 set smallmopac = MOPAC
15 # The name of the "alternate" mopac executable. (the larger version)
16 set bigmopac = MOPACBIG
19 #########################END OF SYSTEM SPECIFIC DEFINITIONS#############
21 # This is actually a compilation of several individual .csh files into
22 # a single larger .csh file. Before, each of the files would be called
23 # in turn. Now, the name of the individual .csh files is simply the
24 # first argument in the call to this master file. The job name has
25 # been slipped to the second argument. This has been done to ease
26 # installation and periodic updates by reducing the number of separate
27 # files to change to a single one. This also reduces the number of
28 # files that must be updated to just one since all the variables defined
29 # once at the top and then used throughout the rest of the script.
30 # NOTE: If you wish to split this file into the smaller .csh files, it
31 # will require substanital altering of the code. It is not an easy
32 # process. FJSRL will support the present form only.
34 # To activate this .csh file, add the line
35 # " source csh mopac.csh "
36 # to your .cshrc file.
40 #-------------------------------------------------------------------------
42 # This script was written at the US Air Force Academy, Frank J. Seiler
43 # Research Laboratory for use on a DECStation 3100. It is a generic
44 # ULTRIX/UNIX csh script that should be easily adapted to other UNIX
45 # systems. For assistance please contact:
47 # Dr. Michael B. Coolidge
52 # ARPA net address: Coolidge@usafa.af.mil
54 #-------------------------------------------------------------------------
56 # Now, lets get the two possible arguments that can be specified assigned.
60 # Now, to go to the correct section of code as determined by the first\
61 # argument given. Note: if no argument is given, assume it should
64 if ( a$type == asubmit ) goto submit
65 if ( a$type == aqueue ) goto queue
66 if ( a$type == acleanup ) goto cleanup
67 if ( a$type == aimopac ) goto imopac
68 if ( a$type == armopac ) goto rmopac
69 if ( a$type == achkmopac ) goto chkmopac
70 if ( a$type == ashut ) goto shut
71 if ( a$type == a ) goto setupmopac
72 if ( a$type == asetupmopac ) goto setupmopac
74 echo Warning, your first argument is not a valid choice
78 #---------------------start of setupmopac.csh---------------------------
80 # This portion will take care of all aliases needed in order to run MOPAC.
82 #-------------------------------------------------------------------------
84 # Use the next command to run a job in background 'mopac filename'
85 alias mopac '$mopacdir/mopac.csh imopac \!*'
87 # The next command allows you to stop a currently running mopac job.
88 # Once in the same directory as the running job, type: 'shut filename'
90 alias shut '$mopacdir/mopac.csh shut'
92 # This commands gives a directory of all output files
93 alias dout 'ls -tl *.out | more '
95 # The next series of commands are for a pseudo batch queue. This queue
96 # system uses the four portions of this file, 'submit', 'queue', 'cleanup',
97 # and 'chkmopac' and creates or uses three more '.qlock', '.qdone',
98 # and '.qjobs'. The queue is managed by queue.csh. Jobs are placed
99 # onto the queue by submit by adding the current path, username,
100 # and filename to the end of .qjobs. After a single job is completed,
101 # cleanup compares the list of files to do, .qjobs, with the list
102 # of files that have completed, .qdone, and deletes all finished jobs
103 # from both lists. The function of chkmopac is to check the system
104 # for a currently running queue. If that queue does not exist, then
105 # chkmopac will start it. If it does, then do not start a second one.
106 # The file .qlock contains the name of the currently executing file.
107 # If the name listed is 'waiting', then there is not a job current running.
108 # The queue is waiting for a new job to be submitted. Once a job is
109 # submitted, then the queue will be restarted.
111 # To submit a job to the queue, type: 'submit filename'
112 alias submit 'csh $mopacdir/mopac.csh submit \!*'
114 # To restart the queue after a crash, type: 'startmopac'
115 alias startmopac 'csh $mopacdir/mopac.csh chkmopac'
117 # To check what is currently running, type: 'doing'
118 alias doing 'more $mopacdir/.qlock'
120 # To check what is currently on the queue, type: 'todo'
121 alias todo 'more $mopacdir/.qjobs'
123 # Note: The order jobs are executed on the queue can be changed at
124 # anytime by simply editing the file $mopacdir/.qjobs. The only
125 # job that cannot be affected is the currently executing one.
127 #----------------------------end of setupmopac.csh----------------------
129 #----------------------------start of submit.csh------------------------
131 # This will setup a pseudo batch queue. By typing submit 'jobname',
132 # that job will be entered into a holding file along with the current
133 # path name. Before the job is entered though, it will be checked to
134 # see that it is valid.
135 # This will also check to see if the batch queue has been started. If not,
136 # the queue will be started.
140 # Check to see if the queue is presently running. If not, start it.
141 csh $mopacdir/mopac.csh chkmopac &
143 # Now, parse the job name and store it in the correct format in .qjobs
149 if !(-e $rname.dat) goto warn
150 echo $pname/$owner/$rname >> $mopacdir/.qjobs
154 # The input file did not exist. Warn the user.
155 echo The file $rname.dat did not exist. Your job is not submitted
157 #------------------------------end of submit.csh------------------------
159 #----------------------------start of queue.csh-------------------------
161 #----------------------------------------------------------
163 # code to establish a pseudo batch queue ...
165 #----------------------------------------------------------
166 # don't go on if there's already a job executing
167 #----------------------------------------------------------
168 if -e $mopacdir/.qlock goto doing
170 # entry point to start a new run
172 echo queue is running >> $mopacdir/.qlock
175 csh $mopacdir/mopac.csh cleanup
177 # Now, setup the rest of the needed variables
180 #----------------------------------------------------------
181 # loop over the jobs in qjobs and start the first one that
182 # has not completed yet. upon completion, jobs copy the job
183 # name into file qdone
184 #----------------------------------------------------------
185 set njobs = `wc -l < $mopacdir/.qjobs`
188 if "$nleft" == 0 then
189 echo waiting >> $mopacdir/.qlock
191 # if this queue should now wait, then put it to sleep. Otherwise
192 # exit. (uncomment the desired option)
195 if -e $mopacdir/.qlock rm $mopacdir/.qlock
200 set njob = `expr $njobs - $nleft + 1`
202 # every tenth job, do a cleanup
203 if "$njob" == 10 csh $mopacdir/mopac.csh cleanup
205 set job = `sed -n "$njob"p $mopacdir/.qjobs`
206 if "$job" == quit then
207 if -e $mopacdir/.qlock rm $mopacdir/.qlock
210 if "$job" == done then
212 # if this queue should now wait, then put it to sleep. Otherwise
213 # exit. (uncomment the desired option)
218 # now, to separate the job name from the path name
225 if ( $job == $pname ) set pname = "."
228 set idone = `grep $job.is $mopacdir/.qdone | wc -l`
229 if "$idone" != 0 goto nogoodq
233 echo $job >> $mopacdir/.qlock
235 # Now, execute the mopac job
240 # Next, see if job.dat exists. If not, goto helpmessage
241 if -z $job.dat goto helpmessageq
243 # Check $job.dat to see if this is a nextrun job.
244 set restart = `head -3 $job.dat | grep -i " restart" | wc -l`
245 if ($restart != 0) then
246 foreach file (res den)
247 if !(-e $job.$file) goto norestartq
250 foreach file (res den)
251 if -e $job.$file mv $job.$file $job.$file.$$
255 # Check that prior copies of files do not exist
256 foreach file (out log arc end)
257 if -e $job.$file mv $job.$file $job.$file.$$
260 # Now, make all the necessary assignments
261 setenv FOR005 $job.dat
262 setenv FOR006 $job.out
263 setenv FOR009 $job.res
264 setenv FOR010 $job.den
265 setenv FOR011 $job.log
266 setenv FOR012 $job.arc
267 setenv FOR013 $job.gpt
268 setenv FOR016 $job.syb
269 setenv FOR020 $job.ump
270 setenv SETUP SETUP.DAT
271 setenv SHUTDOWN $job.end
273 if -e fort.2 rm fort.2
274 if -e fort.16 rm fort.16
275 nice -8 $mopacdir/$smallmopac >> $job.log
276 set iok1 = `tail -1 "$job.out" | grep "IN SYSTEM" | wc -l`
277 set iok2 = `tail -1 "$job.out" | grep "ATOMS ALLOWED" | wc -l`
278 set iok3 = `tail -1 "$job.out" | grep "MAXIMUM ALLOWED" | wc -l`
279 set iok = `expr "$iok1" + "$iok2" + "$iok3" `
281 set idone2 = `grep "== MOPAC DONE ==" "$job.out" | wc -l`
284 set nobig = `ps ax | grep "$mopacdir" | grep "/$bigmopac" | wc -l`
285 if $nobig != 0 sleep 300
286 if $nobig != 0 goto check
289 time $mopacdir/$bigmopac >> $job.log
293 echo $job is done >> $mopacdir/.qdone
295 if -e fort.2 rm fort.2
296 if -e fort.16 rm fort.16
297 # this job has completed normally
299 if -e SHUTDOWN rm SHUTDOWN
300 if -e $job.end rm $job.end
304 # the file specified on the command line either did not exist or has
306 echo 'Your file either does not exist or has zero length'
307 echo $job is not done >> $mopacdir/.qdone
312 # A nextrun has been specified but the .res or .den files do not exist
313 echo 'I cannot find either "$job".den or "$job".res. Please help'
314 echo $job is not done >> $mopacdir/.qdone
320 if -e $mopacdir/.qlock rm $mopacdir/.qlock
322 set nleft = `expr $nleft - $nleft + 1`
325 set nleft = `expr $nleft - 1`
327 # now to cleanup the todo and done lists
328 csh $mopacdir/mopac.csh cleanup
330 if -e $mopacdir/.qlock rm $mopacdir/.qlock
331 echo waiting >> $mopacdir/.qlock
332 if -e $mopacdir/.qlock rm $mopacdir/.qlock
335 # now, to do the next one
340 echo there is presently a job running
342 #--------------------------------------------------------------
344 #--------------------------------------------------------------
345 #------------------------------end of queue.csh-------------------------
347 #----------------------------start of cleanup.csh-----------------------
349 #----------------------------------------------------------
353 # code to look after jobs in the batch queues ...
354 # this file automatically cleans up the input list and
355 # zero's out the output list.
356 #----------------------------------------------------------
358 set njobs = `wc -l < $mopacdir/.qjobs`
360 if -e $mopacdir/.qjobs2 rm $mopacdir/.qjobs2
362 if "$nleft" == 0 exit
365 set njob = `expr $njobs - $nleft + 1`
366 set job = `sed -n "$njob"p $mopacdir/.qjobs`
367 # now, to separate the job name from the path name
372 if ( $job == $pname ) set pname = "."
375 set idone = `grep $job.is $mopacdir/.qdone | wc -l`
376 if "$idone" != 0 goto nogoodm
379 echo $pname/$job >> $mopacdir/.qjobs2
383 set nleft = `expr $nleft - 1`
386 # now, to do the next one
389 if -e $mopacdir/.qjobs rm $mopacdir/.qjobs
390 if !(-e $mopacdir/.qjobs2) echo > $mopacdir/.qjobs
391 if -e $mopacdir/.qjobs2 mv $mopacdir/.qjobs2 $mopacdir/.qjobs
392 if -e $mopacdir/.qdone rm $mopacdir/.qdone
393 echo this file has been cleaned > $mopacdir/.qdone
394 chmod +w $mopacdir/.qjobs
395 chmod +w $mopacdir/.qdone
397 #------------------------------end of cleanup.csh-----------------------
399 #----------------------------start of mopac.csh-------------------------
402 # A csh file that will assign all the necessary variables to run MOPAC
406 # If filename is missing, or are the names 'help' or 'h', then
407 # the help facility will be invoked.
409 #-------------------------------------------------------------------------
411 # First, set the job to be executed to the variable 'job'
415 if (null$ext == null) set ext = dat
416 if (null$ext == null$full) set ext = dat
418 # Next, see if job is blank, h, or help
419 if (null$job == null) goto help
420 if (null$job == nullh) goto help
421 if (null$job == nullhelp) goto help
422 # Next, see if job.dat exists. If not, goto helpmessage
423 if ( $ext != dat ) goto datmessage
425 if !(-e $job.dat) goto helpmessagem
426 if -z $job.dat goto helpmessagem
428 # Check $job.dat to see if this is a restart job.
429 set restart = `head -3 $job.dat | grep -i " restart" | wc -l`
430 if ($restart != 0) then
431 foreach file (res den)
432 if !(-e $job.$file) goto norestartm
435 foreach file (res den)
436 if -e $job.$file mv $job.$file $job.$file.$$
440 # Now, to execute MOPAC
441 csh $mopacdir/mopac.csh rmopac $job &
445 # run the help program since either no filename was given, or the file name
446 # given was h or help
454 # the extension given was not .dat
455 echo 'Your filename did not have a .dat extension'
456 echo ' but a ' $ext ' extension'
461 # the file specified on the command line either did not exist or has
463 echo 'Your file either does not exist or has zero length'
468 # A restart has been specified but the .res or .den files do not exist
469 echo 'I cannot find either "$job".den or "$job".res. Please help'
473 #------------------------------end of imopac.csh-------------------------
475 #----------------------------start of rmopac.csh------------------------
482 # Check that prior copies of files do not exist
483 foreach file (out log arc end)
484 if -e $job.$file mv $job.$file $job.$file.$$
487 # Now, make all the necessary assignments
489 setenv FOR005 $job.dat
490 setenv FOR006 $job.out
491 setenv FOR009 $job.res
492 setenv FOR010 $job.den
493 setenv FOR011 $job.log
494 setenv FOR012 $job.arc
495 setenv FOR013 $job.gpt
496 setenv FOR016 $job.syb
497 setenv FOR020 $job.ump
498 setenv SETUP SETUP.DAT
499 setenv SHUTDOWN $job.end
501 if -e fort.2 rm fort.2
502 if -e fort.16 rm fort.16
503 time $mopacdir/$smallmopac >> $job.log
504 set iok1 = `tail -1 "$job.out" | grep "IN SYSTEM" | wc -l`
505 set iok2 = `tail -1 "$job.out" | grep "ATOMS ALLOWED" | wc -l`
506 set iok3 = `tail -1 "$job.out" | grep "MAXIMUM ALLOWED" | wc -l`
507 set iok = `expr "$iok1" + "$iok2" + "$iok3" `
509 set idone2 = `grep "== MOPAC DONE ==" "$job.out" | wc -l`
511 set nobig = `ps ax | grep "$mopacdir" | grep "/$bigmopac" | wc -l`
515 time $mopacdir/$bigmopac >> $job.log
519 echo $job must be submitted to batch queue since there is
520 echo currently a big job running.
524 echo job $job is finished
527 if -e fort.2 rm fort.2
528 if -e fort.16 rm fort.16
529 # this job has completed normally
531 if -e SHUTDOWN rm SHUTDOWN
532 if -e $job.end rm $job.end
536 #------------------------------end of rmopac.csh------------------------
538 #----------------------------start of chkmopac.csh----------------------
540 # This will check if a job is running. If not, startup the mopac queue.
541 # Note: It is necessary to do the two grep's in order to not get a flase
542 # hit with itself or another job of itself running in memory at the same
544 # The two grep's should together contain the path and file name of the queue
545 # handler. Neither should contain the complete name.
549 # Now, parse the job name and store it in the correct format in .qjobs
550 set hname = $mopacdir:h
551 set tname = $mopacdir:t
553 set jobs = `ps ax | grep "csh $hname/" | grep "$tname/mopac.csh queue" | wc -l`
555 if -e $mopacdir/.qlock rm $mopacdir/.qlock
556 csh $mopacdir/mopac.csh queue &
559 #------------------------------end of chkmopac.csh----------------------
561 #----------------------------start of shut.csh--------------------------
565 # Now, to parse the job name and possibly remove any extension
569 if -e $rname.dat goto shut_ok
570 echo The file $rname.dat does not exist in this directory
573 echo shutting down this job >> $rname.end
575 #------------------------------end of shut.csh--------------------------
577 #-----------------------------------------------------------------------