1#!/bin/bash
2#########################################################################
3#
4# Shell script for running DALTON test suite
5#
6# First version by Christof Haettig and Kasper Hald, Sep. 2000
7#
8#########################################################################
9
10# Note: DALTON points to the default installation directory,
11#       in the 'configure' script. If the person installing
12#       Dalton has chosen another installation directory when
13#       he/she ran 'configure', the you should modify the
14#       DALTON definition to pint to that place.
15
16if [ -x '/usr/bin/time' ]; then
17 TIMING_OF="/usr/bin/time" #hjaaj sep07: gnu time gives more info than built-in time
18else
19 TIMING_OF="time"
20fi
21DALTON="`pwd`/../../bin/dalton"
22
23#########################################################################
24# define all the different test suites
25#########################################################################
26ESSENTIAL=""
27#
28SHORTENRGY="energy_direct energy_direct_eri energy_douglaskroll energy_nosymm energy_restart \
29energy_symm energy_zmat energy_nevpt2_gs energy_nevpt2_ex energy_hsrohf energy_hsrohf_qc"
30SHORTDFT="dft_hcth120 dft_camb3lyp dft_pbe"
31SHORTGOPT="geoopt_cartsad geoopt_cartsad2 geoopt_constrain1a \
32geoopt_constrain1b geoopt_delintsad geoopt_exci2 geoopt_numgrd \
33geoopt_preopt geoopt_prop geoopt_prop2 geoopt_redintmin geoopt_vrml"
34SHORTPROP="prop_ecd prop_or prop_exci prop_nolondon prop_spinspin prop_spinspin2 \
35prop_spinspin3 prop_spinspin4 prop_vibvcd prop_ctocd prop_soppactocd \
36prop_newtrasoppa prop_newtrasoppacc prop_newtramcscf aba_prop_file \
37prop_vibg1 prop_vibg2"
38SHORTRSP="rsp_2ndharm rsp_3rdharm \
39rsp_3rdmom rsp_dresqr rsp_ecp rsp_exci rsp_excipolar2 rsp_hyperpolar \
40rsp_lrso rsp_lrso2 rsp_mcdbterm rsp_mnf rsp_phosph rsp_polar rsp_propave \
41rsp_socorr rsp_socorr2 rsp_socorr3 rsp_socorr_dir rsp_socorr2_dir \
42rsp_socorr3_dir rsp_solvhyper rsp_soppa1excinosymm rsp_soppa1excisymm \
43rsp_soppa3excinosymm rsp_soppa3excisymm rsp_soppafcnosymm rsp_soppafcsymm \
44rsp_soppapolar rsp_soppapolarnosymm rsp_soppapolarsymm rsp_sreslrso \
45rsp_sresqr rsp_ctocdhyper prop_spinspin5 prop_nolondon_soppacc rsp_soppaccexci \
46rsp_soppaccpolar rsp_g_rohf rsp_g_rohf_dir rsp_g_cas \
47rsp_g_rohf_ecc rsp_hfc rsp_zfs rsp_zfs_mc rsp_absorp rsp_prop_file"
48SHORTWALK="walk_gradex walk_image walk_modeflw walk_polar walk_vibave walk_vibave2"
49SHORTREST="r12_sym dpt_h2s dft_qr_sym"
50AOSOPPA="prop_exci_ao prop_exci_aorpa prop_exci_aorpad prop_exci_aosoppa \
51prop_exci_aosoppcc"
52SHORTNOCC="$SHORTENRGY $SHORTDFT $SHORTGOPT $SHORTPROP $SHORTRSP $SHORTWALK $SHORTREST $AOSOPPA"
53SHORTQM3="hfmm_1 cc2mm_spc_fop \
54dftmm_1 dftmm_2 dftmm_3 dftmm_4 dftmm_5 dftmm_6 dftmm_7 dftmm_8 dftmm_9 \
55qmmm1 qmmm2 qmmm3 qmmm4 qmmm5 qmmm6 qmmm7 qmmm8"
56#
57SHORTCC="cc_rsp_alpha2 cc_rsp_beta cc_rsp_beta2 cc_rsp_betafreq \
58cc_rsp_betafreq2 cc_fop_drw2e cc_fop_prop cc_fop_prop2 cc_exgr_prop \
59cc_rsp_excipolar cc_rsp_exci cc_energy_field cc_fop_prop3 cc_fop_prop4 \
60cc_fop_freeze cc_rsp_gamma cc_rsp_gammafreq cc_rsp_gammafreq2 \
61cc_rsp_mcdbterm cc_rsp_threephot cc_energy_triples cc_energy_triplesdirect \
62cc_energy_triplesdirect2 cc_energy_triplesdirect3 cc_energy_triplet2 \
63cc_rsp_twophot cc_rsp_twophot2 cc_rsp_gamma3 \
64cc_rsp_twophot5 cc_rsp_twophotb cc_grad cc_geoopt_mp2 cc_fop_cc3 cc_rsp_ctocd \
65cc_grad_ccpt_hf cc_geopt_ccpt_hf cc_geopt_ccpt_h2o cc_prop_file"
66#
67SHORT="$SHORTNOCC $SHORTCC $SHORTQM3"
68#
69MEDIUM="energy_corehole energy_solv geoopt_cartmin geoopt_dckerr \
70geoopt_delintmin geoopt_exci geoopt_mp2froz geoopt_redintsad \
71geoopt_symbrk prop_expgrad prop_nucquad prop_roa rsp_dckerr rsp_esr \
72rsp_esr2 rsp_mnfphosph rsp_solvesr walk_polar2"
73#
74MEDIUMCC="cc_rsp_alpha cc_rsp_gamma2 cc_rsp_gammadirect cc_rsp_oddisp \
75cc_energy_triplet cc_rsp_twophotdirect cc_grad2 cc_grad3 cc_geoopt \
76cc_rsp_solv cc_energy_triplet3 cc2dc_energy cc2dc_resp cc2dc_exci cc2dc_resp_newlr \
77cc_beta_solv"
78#
79MEDIUMQM3="ccsdmm_spc_fop ccsdmm_oldtg ccsdmm_ec1_fop \
80ccsdmm_ec3_fop ccsdmm_e01_fop ccsdmm_modelmix cc2mm_exci \
81cc2mm_atmvdw ccsdmm_twopar_vdw cc2mm_lr_qr cc2mm_spc_exci ccmm_beta"
82#
83MEDIUM="$MEDIUM $MEDIUMCC $MEDIUMQM3"
84#
85LONG="geoopt_prop3 prop_vibana rsp_excipolar rsp_twophot walk_solvmag"
86#
87LONGCC="cc_geoopt2"
88#
89LONG="$LONG $LONGCC"
90#
91PARALLEL="energy_parallel geoopt_parallel prop_parallel rsp_parallel dft_parallell_properties"
92#
93DFT="dft_b3lyp_cart dft_b3lyp_nosym dft_b3lyp_sym dft_blyp_nosym \
94dft_blyp_sym dft_energy_sym dft_lda_cart dft_lda_nosym dft_lda_sym \
95dft_optimize_nosym dft_optimize_sym dft_lb94 dft_qr_sym dft_qr_nosym \
96dft_lda_molhes_nosym dft_b3lyp_molhes_nosym dft_b3lyp_magsus_nosym \
97dft_polar dft_cr_sym"
98#
99DPT="dpt_hf dpt_h2s dpt_h2s_finp dpt_hbr_finm dpt_h2s_finm \
100dpt_hbr dpt_hbr_finp dpt_h2s_ff"
101#
102MP2R12="r12_damped r12_damped_herdir \
103r12_sym r12_nosym r12_fc_sym r12_fc_nosym \
104r12_aux_sym r12_aux_nosym r12_fc_aux_sym r12_fc_aux_nosym \
105r12_prop r12_prop_n2 r12_prop_h2o r12_loc r12_stg r12_orb r12_cabs"
106#
107SHORTCCR12="cc2_r12_aux2_bh cc2_r12_aux2_bh_sym \
108cc2_r12_aux_bh_a2 cc2_r12_aux_bh_sym_a2 \
109cc2_r12_he cc2_r12_aux2_bh_a2 cc2_r12_aux2_bh_sym_a2 \
110cc2_r12_aux2_bh_lhtr cc2_r12_aux2_bh_sym_lhtr \
111cc2_r12_he_a2 ccsdr12_bh_direct ccsdr12_n2_direct \
112ccsdr12_bh ccsdr12_n2 cc2_r12_aux_ch4 cc2_r12_aux_ch4_sym \
113cc2_r12_aux_ch4_lhtr cc2_r12_aux_ch4_sym_lhtr cc2_r12_aux_nh3_sym \
114cc2_r12_aux_nh3_sym_lhtr ccsdr12pt_ne \
115cc2_r12_aux_ch4_fop cc2_r12_aux_ch4_sym_fop \
116cc2_r12_aux_h2o_fop cc2_r12_aux_h2o_sym_fop \
117cc2_r12_aux_ch4_lr cc2_r12_aux_ch4_sym_lr \
118cc2_r12_aux_ch4_sym_lr_nondir cc2_r12_aux_ch4_sym_nondir \
119cc2_r12_aux_ch4_ff cc2_r12_aux_ch4_ff2 \
120cc2_r12_aux_ch4_sym_pol cc2_r12_aux_n2_gamma cc2_r12_aux_n2_gamma2 \
121cc2_r12_aux_ne_gamma cc2_r12_aux_bh_a3 cc2_r12_aux_bh_sym_a3 \
122cc2_r12_aux_ne cc2_r12_aux_ne_gamma2 cc2_r12_aux_h2o_a2 \
123cc2_r12_aux_h2o_sym_a2 cc2_r12_aux_h2o_a3 cc2_r12_aux_h2o_sym_a3 \
124ccsdr12_n2_exc ccsdr12_n2_sym_exc ccsdr12_n2_sym_exc_lhtr \
125ccsdr12pt_ne_f12 cc2_r12_aux_ch4_sym_f12 cc2_r12_aux_ch4_sym_a3_f12 \
126ccsdr12_n2_gamma ccsdr12_n2_gamma2 ccsdr12_h2o_gamma ccsdr12_h2o_gamma2 \
127ccsdr12_be cc2_r12_aux_ch4_cbs1 cc2_r12_aux_ch4_cbs2 cc2_r12_aux_ch4_cbs3"
128#
129LONGCCR12="cc2_r12_aux_ch4_a2 cc2_r12_aux_ch4_sym_a2 \
130cc2_r12_aux_ch4_sym_a3 cc2_r12_aux_benzene_sym_fop cc3r12_n2_sym_exc \
131cc3r12_n2_sym_exc_lhtr cc2_r12_aux_ch4_cbs2a"
132#
133SRDFT="hfsrlda_sym mp2srlda_ener_nosym mcsrlda_sym mcsrpbe_sym \
134hfsrpbe_sym mp2srpbe_ener_nosym"
135#SRDFT="mp2srlda_ener_nosym"
136#
137#
138CCR12="$SHORTCCR12 $LONGCCR12"
139#
140R12="$MP2R12 $SHORTCCR12 $LONGCCR12"
141#
142QM3="$SHORTQM3 $MEDIUMQM3"
143#
144NUMDER="hfreqfromE hfreqfromg effgeom_fromE effgeom_fromE2 vibave_spinspin"
145#
146GEOOPT="cc_geoopt cc_geoopt2 cc_geoopt_mp2 geoopt_cartmin geoopt_cartsad \
147geoopt_cartsad2 geoopt_constrain1a geoopt_constrain1b geoopt_dckerr \
148geoopt_delintmin geoopt_delintsad geoopt_exci geoopt_exci2 geoopt_mp2froz \
149geoopt_numgrd geoopt_preopt geoopt_prop geoopt_prop2 geoopt_prop3 \
150geoopt_redintmin geoopt_redintsad geoopt_symbrk geoopt_vrml"
151#
152ALL="$SHORT $MEDIUM $LONG $DFT $NUMDER $R12 $DPT"
153#
154ALLCC="$SHORTCC $MEDIUMCC $LONGCC"
155#
156BENCHMARK="benchmark_eri_r12 benchmark_eri_r12xl \
157benchmark_eri_adzs benchmark_her_adzs benchmark_eri_adz benchmark_her_adz"
158run_new=0;
159#
160#########################################################################
161# function usage(): print usage information
162#########################################################################
163usage() {
164 cat <<'%EOF%'
165usage: TEST [-h|-help|--help] [-keep] [-reftest] [-bell] [-benchmark]
166            [-param "option list"] [-dalton script] [-log logfile] testcase
167
168       -h | -help | --help  : show this help description
169       -keep                : keep *.mol, *.dal, *.check and *.log files
170       -reftest             : test reference file(s); do not run any
171                              calculations
172       -bell                : sound bell each time a test fails
173       -benchmark           : print CPU time for each testcase as part of
174                              the summary
175       -param "option list" : pass "option list" to dalton-script
176       -dalton script       : use script instead of the default
177                              dalton-script "`pwd`/../dalton" (absolute path)
178       -log logfile         : write output into logfile instead of the
179                              default "TESTLOG"
180
181       and where testcase might be one of the following:
182          essential            -- run a minimal set of essential testcases
183          parallel             -- run all parallel testcases
184          allcc                -- run all coupled-cluster testcases
185          short                -- run all short testcases
186          medium               -- run all medium length testcases
187          long                 -- run all long testcases
188          dft                  -- run all DFT testcases
189          srdft                -- run all srDFT testcases
190          r12                  -- run all R12 testcases
191          ccr12                -- run all CC-R12 testcases
192          mp2r12               -- run all MP2-R12 testcases
193          shortccr12           -- run all short CC-R12 testcases
194          longccr12            -- run all long CC-R12 testcases
195          benchmark            -- run all BENCHMARK testcases
196          dpt                  -- run all DPT testcases
197          numder               -- run all numerical derivatives testcases
198          geoopt               -- run all OPTIMIZE testcases
199	  aosoppa              -- run all AOSOPPA testcases
200          pcm                  -- run all pcm testcases
201          perl                 -- run all perl-style testcases
202          all                  -- run all non-parallel testcases
203                                  (= short + medium + long)
204          <case1 [case2] ...>  -- run only the specified testcase(s)
205%EOF%
206exit 1
207}
208
209#########################################################################
210# function myprint(string): print to stdout and $listing
211#########################################################################
212myprint(){
213 echo "$1";
214 echo "$1" >> $listing;
215}
216
217#########################################################################
218#########################################################################
219# start with real work:
220#########################################################################
221#########################################################################
222
223#########################################################################
224# set defaults and evaluate parameters
225#########################################################################
226TESTparams="$0 $*"
227help=""
228keep="false"
229paramlist=""
230reftest=""
231bell=""
232benchmark=""
233listing="TESTLOG"
234perl_log="test.log"
235perl_err="test.err"
236emptystring="                                "
237answer_yes=
238keep_quiet=
239
240tmpfile=/tmp/dalton-$$.log
241touch "$tmpfile"   || { echo "cannot create temporary file. Aborting execution."; exit 1; }
242test -f "$tmpfile" || { echo "Possible security breach related to temporary file."; exit 1; }
243
244if [ `uname` = Linux ]; then
245   GREP="egrep -a"
246else
247   GREP="egrep"
248fi
249
250while echo $1 | egrep -q '^-'; do
251   case $1 in
252     "-h" | "-help" | "--help" ) help="true" ; break;;
253     "-dalton" )  shift; DALTON=$1; shift;;
254     "-log" ) shift; listing=$1; shift;;
255     "-keep" ) keep="true"; shift;;
256     -param* ) shift; paramlist="$1"; shift;;
257     "-reftest" ) reftest="true"; shift;;
258     "-bell" ) bell="true"; shift;;
259     "-y") answer_yes=true; shift;;
260     "-q") keep_quiet=true; shift;;
261     "-benchmark" ) benchmark="true"; shift;;
262     * ) echo "---> ERROR: $1 is an unknown option!"; usage;;
263   esac
264done
265if [ $help ]; then
266  usage
267fi
268
269if [ ! -x $DALTON ]; then
270   echo ' '
271   echo '----> ERROR, the "dalton" job script '
272   echo    '"'$DALTON'"'
273   echo '  does not exist or is not executable.'
274   echo 'The person who installed dalton has probably selected'
275   echo '  another place for the "dalton" job script.'
276   echo 'Please modify the DALTON variable in this script (i.e. '$0')'
277   echo '  to point to that place.    Alternatively, you may'
278   echo '  specify where the dalton script is with the -dalton option'
279   echo ' '
280#  usage
281   exit 1
282fi
283
284#########################################################################
285# set list of test cases:
286#########################################################################
287testcase=$*
288if   [ "$testcase" = "" ]; then
289  echo '    ***********************************'
290  echo '    * ERROR: No testcase(s) specified *'
291  echo '    ***********************************'
292  usage
293fi
294testcase=""
295perl_style_kwd=""
296perl_style=0
297all_perl_style=0
298while [ -n "$1" ]; do
299   case $1 in
300  "essential" )
301   testcase="$testcase $ESSENTIAL";
302   perl_style_kwd="$perl_style_kwd $1";
303   shift ;;
304  "energy" )
305   testcase="$testcase $SHORTENRGY";
306   perl_style_kwd="$perl_style_kwd $1";
307   shift ;;
308  "pcm" )
309   perl_style_kwd="$perl_style_kwd $1";
310   shift ;;
311  "short_nocc" )
312   testcase="$testcase $SHORTNOCC";
313   shift ;;
314   "shortcc" )
315   testcase="$testcase $SHORTCC";
316   shift ;;
317  "short" )
318   perl_style_kwd="$perl_style_kwd $1";
319   testcase="$testcase $SHORT";
320   shift ;;
321  "medium" )
322   perl_style_kwd="$perl_style_kwd $1";
323   testcase="$testcase $MEDIUM";
324   shift ;;
325  "long" )
326   perl_style_kwd="$perl_style_kwd $1";
327   testcase="$testcase $LONG";
328   shift ;;
329  "parallel" )
330   if [ "$paramlist" = "" ]; then
331     paramlist="-N 3"
332   fi
333   testcase="$testcase $PARALLEL";
334   shift ;;
335  "all" )
336   all_perl_style=1;
337   testcase="$testcase $ALL";
338   shift ;;
339  "perl" )
340   echo "perl"
341   all_perl_style=1;
342   shift ;;
343  "allcc" )
344   testcase="$testcase $ALLCC";
345   shift ;;
346  "dft" )
347   perl_style_kwd="$perl_style_kwd $1";
348   testcase="$testcase $SHORTDFT $DFT";
349   shift ;;
350  "srdft" )
351   perl_style_kwd="$perl_style_kwd $1";
352   testcase="$testcase $SRDFT";
353   shift ;;
354  "dpt" )
355   testcase="$testcase $DPT";
356   shift ;;
357   "r12" )
358   testcase="$testcase $R12";
359   shift ;;
360   "ccr12" )
361   testcase="$testcase $CCR12";
362   shift ;;
363   "mp2r12" )
364   testcase="$testcase $MP2R12";
365   shift ;;
366   "shortccr12" )
367   testcase="$testcase $SHORTCCR12";
368   shift ;;
369   "longccr12" )
370   testcase="$testcase $LONGCCR12";
371   shift ;;
372   "benchmark" )
373   testcase="$testcase $BENCHMARK";
374   shift ;;
375   "numder" )
376   testcase="$testcase $NUMDER";
377   shift ;;
378   "geoopt" )
379   testcase="$testcase $GEOOPT";
380   shift ;;
381   "aosoppa" )
382   testcase="$testcase $AOSOPPA";
383   shift ;;
384   "qm3" )
385   testcase="$testcase $QM3";
386   shift ;;
387   "*parallel*" )  # assume parallel test if "parallel" in name
388   if [ "$paramlist" = "" ]; then
389     paramlist="-N 3"
390   fi
391   testcase="$testcase $1";
392   shift ;;
393   * )
394   testcase="$testcase $1";
395   shift ;;
396   esac
397done
398
399if [ -n "$perl_style_kwd" -o  "$all_perl_style" -eq 1 ]; then
400    perl_style=1
401fi
402
403#########################################################################
404# create a unique directory for test output /hjaaj
405# nonportable characters in the directory name removed. /pawsa
406#########################################################################
407testdir="`date +'%Y-%m-%dT%H_%M'`-testjob-pid-$$"
408while [ -e $testdir ]; do
409    testdir=${testdir}x
410done
411mkdir $testdir
412cp functions $testdir
413cd $testdir || exit 1
414
415
416#########################################################################
417# check files for test listing:
418#########################################################################
419if [ -s $listing -a "$answer_yes" = '' ]; then
420   echo "$listing already exists... should it be deleted first? (y/n)"
421   read answer
422   if [ "$answer" = "yes"  -o  "$answer" = "y" -o "$answer" = "Y" ]; then
423       rm -f $listing
424   fi
425fi
426if [ -s $perl_log  -a "$answer_yes" = '' ]; then
427   echo "$perl_log already exists... should it be deleted first? (y/n)"
428   read answer
429   if [ "$answer" = "yes"  -o  "$answer" = "y" -o "$answer" = "Y" ]; then
430       rm -f $perl_log
431   fi
432fi
433if [ -s $perl_err  -a "$answer_yes" = '' ]; then
434   echo "$perl_err already exists... should it be deleted first? (y/n)"
435   read answer
436   if [ "$answer" = "yes"  -o  "$answer" = "y" -o "$answer" = "Y" ]; then
437       rm -f $perl_err
438   fi
439fi
440
441myprint "#####################################################################"
442myprint "                          DALTON test suite"
443myprint "#####################################################################"
444myprint "invoked with          : $TESTparams"
445myprint "date and time         : `date`"
446myprint "dalton script         : $TIMING_OF $DALTON"
447myprint "parameter list passed : $paramlist"
448myprint "test job directory    : $testdir"
449myprint "test listing          : $listing"
450myprint "test cases            : $testcase"
451
452#########################################################################
453# loop over test cases:
454#########################################################################
455passedall="ALL TESTS ENDED PROPERLY!"
456problems=""
457numresult=0
458for item in ${testcase}
459do
460  trouble=0
461  myprint "###########################################################"
462  myprint "`date`"
463  myprint "Starting now with test $item:"
464  myprint "-----------------------------------------------------------"
465  chmod +x ../$item || exit 1
466  ../$item
467# remove any directory path now the files are unpacked
468  item=`basename $item`
469  if [ -f $item.info -a "$keep_quiet" = "" ]; then
470    cat $item.info
471    cat $item.info >> $listing
472  fi
473# Check if this is a multistep job
474  numsteps=1
475  if [ -r ./$item'__'1.dal ]; then
476      multi=1
477      numsteps=`ls ./$item\_\_[0-9].dal | wc -l`
478      myprint "   This is a multi-step job consisting of $numsteps steps"
479      rm -f ./$item'__'[0-9]'_'$item.log
480      chmod +x ./$item'__'[0-9].check
481  else
482      multi=0
483      rm -f ./$item.log
484      chmod +x ./$item.check
485  fi
486# Multi-step tests loop over the different jobsteps, regular tests just
487# go through this once
488  step=1
489  while [ "$step" -le "$numsteps" ]
490  do
491      potfile=
492      if [ "$multi" -eq 1 ]; then
493          myprint "-----------------------------------------------------------"
494          myprint "  Start $item step $step of $numsteps :"
495          myprint "-----------------------------------------------------------"
496          molfile=$item
497          if [ -r $item.pot ]; then potfile=$item ; fi
498	  cp $item'__'$step'.dal' $item'.dal'
499          dalfile=$item
500          logfile=./$item'__'$step'_'$item.log
501          checkfile=./$item'__'$step.check
502          reffile=./$item'__'$step.ref
503          moldenfile=./$item'__'$step'_'$item.molden
504      else
505          molfile=$item
506          if [ -r $item.pot ]; then potfile=$item ; fi
507          dalfile=$item
508          logfile=./$item.log
509          checkfile=./$item.check
510          reffile=./$item.ref
511          moldenfile=./$item.molden
512      fi
513# If it's a reftest, no calculation is performed
514      if [ "$reftest" = "true" ]; then
515          myprint ""
516          myprint "evaluate reference output file $reffile:"
517          myprint "-----------------------------------------------------------"
518          if [ ! -r $reffile ]; then
519	      cp ../trueresult/$reffile .
520          fi
521          checkout=`$checkfile $reffile | tee -a $listing`
522          if [ "$benchmark" = "true" ]; then
523              if [ `$GREP "CPU  time used in DALTON" $reffile | wc -l` = 1 ]; then
524                  CPU_usage=`$GREP "CPU  time used in DALTON" $reffile | sed s/">>>> Total CPU  time used in DALTON\:"/""/`
525              else
526                  CPU_usage="N/A"
527              fi
528          fi
529          if [ "$checkout" = "TEST ENDED AS EXPECTED" ]; then
530              checkout="TEST ENDED PROPERLY"
531          fi
532      else
533          failed=false
534          if [ "$step" -eq "1" ]; then
535#             make sure that directory is clear before start
536              $TIMING_OF $DALTON -d $paramlist -ext log $dalfile $molfile $potfile > "$tmpfile"
537              if [ $? -ne 0 ]; then failed=true; fi
538          else
539#             copy $item.tar.gz for multistep jobs (-f option)
540              $TIMING_OF $DALTON -f $item $paramlist -ext log $dalfile $molfile $potfile > "$tmpfile"
541              if [ $? -ne 0 ]; then failed=true; fi
542          fi
543          grep -v '\*\*\*' $tmpfile | grep -v -i 'WARNING' | grep -v -i 'INFO'| \
544          grep -v 'OUTPUT FROM' | grep -v 'Version' | grep -v 'PID' | \
545          grep -v '^$' | tee -a $listing
546
547          if [ "$multi" -eq 1 ]; then
548	      cp $molfile'.log' $logfile
549          fi
550          myprint ""
551          myprint "evaluate output file $logfile:"
552          myprint "-----------------------------------------------------------"
553
554          checkout=`$checkfile $logfile | tee -a $listing`
555
556          # Successful tests report "TEST ENDED PROPERLY" unless
557          # the test is meant to return non-zero exit code.  These
558          # return "TEST ENDED AS EXPECTED".  In the latter case, we
559          # change it to "TEST ENDED PROPERLY" if the exit code was
560          # nonzero, otherwise we return "DALTON SCRIPT ERROR"
561
562          if [ "$checkout" = "TEST ENDED PROPERLY" ]; then
563              [ "$failed" = "true" ] && checkout="TEST FAILED ABNORMALLY"
564          elif [ "$checkout" = "TEST ENDED AS EXPECTED" ]; then
565              echo "checkout=$checkout, failed=$failed"
566              if [ "$failed" = "true" ]; then
567                  checkout="TEST ENDED PROPERLY"
568              else
569                  checkout="DALTON SCRIPT ERROR"
570              fi
571          fi
572          if [ "$benchmark" = "true" ]; then
573              if [ `$GREP "CPU  time used in DALTON" $logfile | wc -l` = 1 ]; then
574                  CPU_usage=`$GREP "CPU  time used in DALTON" $logfile | sed s/">>>> Total CPU  time used in DALTON\:"/""/`
575              else
576                  CPU_usage="N/A"
577              fi
578          fi
579      fi
580      if [ "$benchmark" = "true" ]; then
581          numresult=`expr $numresult \+ 1`
582          if [ $step -eq 1 ]; then
583              testlist[$numresult]="$item"
584          else
585              testlist[$numresult]="...step$step"
586          fi
587          timelist[$numresult]="$CPU_usage"
588      fi
589      echo $checkout
590      passed=`echo $checkout | grep "TEST ENDED PROPERLY"`
591      if [ -z "$passed" ]; then
592        trouble=`expr $trouble \+ 1`
593        if [ "$bell" = "true" ]; then
594          echo "\a"
595        fi
596        passedall="THERE IS A PROBLEM IN TEST CASE(S)"
597        if [ "$trouble" -eq 1 ]; then
598            problems="$problems $item"
599        fi
600      elif [ "$keep" = "false" ]; then
601          rm -f $dalfile.dal $dalfile.BAS $checkfile $logfile $item.info
602          if [ "$step" -eq "$numsteps" ]; then
603#         only delete restart files in last step of multistep test !!!
604             rm -f $dalfile.tar.gz
605          fi
606#     else everything OK and -keep defined
607      fi
608    step=`expr $step \+ 1`
609  done
610  if [ "$trouble" -eq 0 ]; then
611      if [ "$keep" = "false" ]; then
612          rm -f $molfile.mol
613          rm -f $potfile.pot
614      fi
615  fi
616done
617
618#########################################################################
619# PCM test suite
620#########################################################################
621if [ "$perl_style" -gt 0 ]; then
622    perl_log="perl_tests.log"
623    perl_err="perl_tests.err"
624    perl_fail=""
625    myprint ""
626    myprint "Now running perl-style tests..."
627    myprint ""
628    cp ../test.pl .
629    cp ../*.tst .
630    cp ../checklist .
631    options=""
632    parameters="--dalton=$DALTON --log=$perl_log --err=$perl_err"
633    if [ "$keep" = "true" ]; then
634	parameters="$parameters --keep"
635    fi
636    if [ "$reftest" = "true" ]; then
637	parameters="$parameters --checkref"
638    fi
639    if [ -n "$perl_style_kwd" ]; then
640	parameters="$parameters --keyword $perl_style_kwd"
641    else
642	parameters="$parameters --all"
643    fi
644    if [ "$paramlist" != "" ]; then
645	options="--options=$paramlist"
646    fi
647    perl_fail=""
648    myprint "Perl-style testsuite invoked with the following parameters"
649    myprint "$parameters $options"
650    ./test.pl $parameters "$options"
651    perl_exit=$?
652    if [ $perl_exit -eq 0 ]; then
653	myprint "Perl-style tests computed successfully"
654    elif [ $perl_exit -eq 1 ]; then
655        passedall="THERE IS A PROBLEM IN TEST CASE(S)"
656        perl_fail="`grep -A1 'tests have failed' $perl_log | tail -1`"
657	problems="$problems $perl_fail"
658        myprint "THERE IS A PROBLEM in perl-style tests"
659    else
660        passedall="THERE IS A PROBLEM IN TEST CASE(S)"
661	myprint ""
662	myprint "WARNING WARNING: Perl-style tests died unexpectedly!"
663    fi
664    myprint ""
665    myprint "Perl-style tests finished!"
666    rm test.pl
667    rm *.tst
668    rm checklist
669    cat $perl_log >> $listing
670fi
671
672#########################################################################
673# final result:
674#########################################################################
675
676myprint ""
677myprint "#####################################################################"
678myprint "                              Summary"
679myprint "#####################################################################"
680myprint ""
681
682if [ "$benchmark" = "true" ]; then
683    if [ "$numresult" -gt 0  ]; then
684      ind=1
685      while [ "$ind" -le "$numresult" ]; do
686        awk "END{printf \"%32s %s\\n\", \"${testlist[$ind]}\",\"${timelist[$ind]}\"}"</dev/null
687        awk "END{printf \"%32s %s\\n\", \"${testlist[$ind]}\",\"${timelist[$ind]}\"}"</dev/null >> $listing
688        ind=`expr $ind \+ 1`
689      done
690      echo
691    fi
692fi
693
694myprint "$passedall"
695myprint "$problems"
696rm "$tmpfile"
697myprint "date and time         : `date`"
698
699exit 0
700