diff --git a/scripts/qp_test b/scripts/qp_test index d1e1afde..bf71776d 100755 --- a/scripts/qp_test +++ b/scripts/qp_test @@ -58,11 +58,16 @@ def main(arguments): print "Running tests for %s"%(bats_file) print "" if arguments["-v"]: - p1 = subprocess.Popen(["python2", "bats_to_sh.py", bats_file], \ - stdout=subprocess.PIPE, env=os.environ) - p2 = subprocess.Popen(["bash"], stdin=p1.stdout, env=os.environ) - _, _ = os.waitpid(p2.pid,0) - _, _ = os.waitpid(p1.pid,0) + p = None + if arguments["TEST"]: + TEST="export TEST=%s\n"%arguments["TEST"] + else: + TEST="" + script = TEST+(subprocess.check_output(["python2", "bats_to_sh.py", bats_file]) ) + try: + p = subprocess.check_call(script, shell=True, env=os.environ) + except: + if p: p.terminate() else: subprocess.check_call(["bats", bats_file], env=os.environ) diff --git a/src/cipsi/pt2_stoch_routines.irp.f b/src/cipsi/pt2_stoch_routines.irp.f index d100fc36..8fc780a7 100644 --- a/src/cipsi/pt2_stoch_routines.irp.f +++ b/src/cipsi/pt2_stoch_routines.irp.f @@ -311,7 +311,7 @@ subroutine pt2_collector(zmq_socket_pull, E, relative_error, pt2, error, & double precision, external :: omp_get_wtime double precision :: v, x, x2, x3, avg, avg2, avg3, eqt, E0, v0, n0 - double precision :: time, time0 + double precision :: time, time1, time0 integer, allocatable :: f(:) logical, allocatable :: d(:) @@ -363,7 +363,8 @@ subroutine pt2_collector(zmq_socket_pull, E, relative_error, pt2, error, & v0 = 0.d0 n0 = 0.d0 more = 1 - time0 = omp_get_wtime() + call wall_time(time0) + time1 = time0 do_exit = .false. do while (n <= N_det_generators) @@ -421,7 +422,8 @@ subroutine pt2_collector(zmq_socket_pull, E, relative_error, pt2, error, & eqt = dabs((S2(t) / c) - (S(t)/c)**2) ! dabs for numerical stability eqt = sqrt(eqt / (dble(c) - 1.5d0)) error(pt2_stoch_istate) = eqt - if(mod(c,10)==0 .or. n==N_det_generators) then + if ((time - time1 > 1.d0) .or. (n==N_det_generators)) then + time1 = time print '(G10.3, 2X, F16.10, 2X, G10.3, 2X, F14.10, 2X, F14.10, 2X, F10.4, A10)', c, avg+E, eqt, avg2, avg3, time-time0, '' if(do_exit .and. (dabs(error(pt2_stoch_istate)) / (1.d-20 + dabs(pt2(pt2_stoch_istate)) ) <= relative_error)) then if (zmq_abort(zmq_to_qp_run_socket) == -1) then @@ -433,7 +435,7 @@ subroutine pt2_collector(zmq_socket_pull, E, relative_error, pt2, error, & endif endif endif - time = omp_get_wtime() + call wall_time(time) end if n += 1 else if(more == 0) then diff --git a/src/fci/40.fci.bats b/src/fci/40.fci.bats new file mode 100644 index 00000000..50631777 --- /dev/null +++ b/src/fci/40.fci.bats @@ -0,0 +1,140 @@ +#!/usr/bin/env bats + +source $QP_ROOT/tests/bats/common.bats.sh + +function run() { + thresh=$3 + test_exe fci || skip + qp_edit -c $1 + ezfio set_file $1 + ezfio set determinants n_det_max 8000 + ezfio set determinants n_states 1 + ezfio set davidson threshold_davidson 1.e-10 + ezfio set davidson n_states_diag 8 + qp_run fci $1 + energy1="$(ezfio get fci energy_pt2 | tr '[]' ' ' | cut -d ',' -f 1)" + eq $energy1 $2 $thresh +} + + + + +@test "NH3" { # 10.6657s + qp_set_mo_class nh3.ezfio -core "[1-4]" -act "[5-72]" + run nh3.ezfio -56.2447484821590 1.e-8 +} + +@test "DHNO" { # 11.4721s + qp_set_mo_class dhno.ezfio -core "[1-7]" -act "[8-64]" + run dhno.ezfio -130.459030395165 1.e-8 +} + +@test "HCO" { # 12.2868s + run hco.ezfio -113.311549734862 1.444e-05 +} + +@test "H2O2" { # 12.9214s + qp_set_mo_class h2o2.ezfio -core "[1-2]" -act "[3-24]" -del "[25-38]" + run h2o2.ezfio -151.024844964871 0.00011948 +} + +@test "HBO" { # 13.3144s + run hbo.ezfio -100.221374036381 1.36e-05 +} + +@test "H2O" { # 11.3727s + run h2o.ezfio -76.2412334158826 1.988e-05 +} + +@test "ClO" { # 13.3755s + run clo.ezfio -534.572693465448 0.00019344 +} + +@test "SO" { # 13.4952s + run so.ezfio -26.0465405831268 0.00014494 +} + +@test "H2S" { # 13.6745s + [[ -n $TRAVIS ]] && skip + run h2s.ezfio -398.865096897874 8.46e-06 +} + +@test "OH" { # 13.865s + [[ -n $TRAVIS ]] && skip + run oh.ezfio -75.6188293682445 1.744e-05 +} + +@test "SiH2_3B1" { # 13.938ss + [[ -n $TRAVIS ]] && skip + run sih2_3b1.ezfio -290.017547995946 1.e-8 +} + +@test "H3COH" { # 14.7299s + [[ -n $TRAVIS ]] && skip + run h3coh.ezfio -115.223624478701 0.00018132 +} + +@test "SiH3" { # 15.99s + [[ -n $TRAVIS ]] && skip + run sih3.ezfio -5.57759237300615 1.116e-05 +} + +@test "CH4" { # 16.1612s + [[ -n $TRAVIS ]] && skip + qp_set_mo_class ch4.ezfio -core "[1]" -act "[2-30]" -del "[31-59]" + run ch4.ezfio -40.2418916955354 3.02e-06 +} + +@test "ClF" { # 16.8864s + [[ -n $TRAVIS ]] && skip + run clf.ezfio -559.19410640102 0.00021062 +} + +@test "SO2" { # 17.5645s + [[ -n $TRAVIS ]] && skip + qp_set_mo_class so2.ezfio -core "[1-8]" -act "[9-87]" + run so2.ezfio -41.5746738710646 1.e-8 +} + +@test "C2H2" { # 17.6827s + [[ -n $TRAVIS ]] && skip + qp_set_mo_class c2h2.ezfio -act "[1-30]" -del "[31-36]" + run c2h2.ezfio -12.3844530031717 9.402e-05 +} + +@test "N2" { # 18.0198s + [[ -n $TRAVIS ]] && skip + qp_set_mo_class n2.ezfio -core "[1,2]" -act "[3-40]" -del "[41-60]" + run n2.ezfio -109.312048711981 0.00010052 +} + +@test "N2H4" { # 18.5006s + [[ -n $TRAVIS ]] && skip + qp_set_mo_class n2h4.ezfio -core "[1-2]" -act "[3-24]" -del "[25-48]" + run n2h4.ezfio -111.382145310854 0.00010255 +} + +@test "CO2" { # 21.1748s + [[ -n $TRAVIS ]] && skip + qp_set_mo_class co2.ezfio -core "[1,2]" -act "[3-30]" -del "[31-42]" + run co2.ezfio -188.002445507874 0.00028902 +} + +@test "F2" { # 21.331s + [[ -n $TRAVIS ]] && skip + qp_set_mo_class f2.ezfio -core "[1,2]" -act "[3-30]" -del "[31-62]" + run f2.ezfio -199.084484583825 0.00014534 +} + +@test "[Cu(NH3)4]2+" { # 25.0417s + [[ -n $TRAVIS ]] && skip + qp_set_mo_class cu_nh3_4_2plus.ezfio -core "[1-24]" -act "[25-45]" -del "[46-87]" + run cu_nh3_4_2plus.ezfio -1862.98649500346 5.e-07 +} + +@test "HCN" { # 20.3273s + [[ -n $TRAVIS ]] && skip + qp_set_mo_class hcn.ezfio -core "[1,2]" -act "[3-40]" -del "[41-55]" + run hcn.ezfio -93.0959693071658 0.00016522 +} + diff --git a/tests/bats/common.bats.sh b/tests/bats/common.bats.sh index f2f35357..10b8c5ad 100644 --- a/tests/bats/common.bats.sh +++ b/tests/bats/common.bats.sh @@ -45,13 +45,18 @@ function test_exe() { } run_only_test() { - if [[ "$BATS_TEST_DESCRIPTION" != "$1" ]] && [[ "$BATS_TEST_NUMBER" -ne "$1" ]]; then - skip + if [[ "$BATS_TEST_DESCRIPTION" != "$1" ]] && [[ "$BATS_TEST_NUMBER" != "$1" ]]; then + if [[ -z $BATS_TEST_FILENAME ]] ; then + exit 0 + else + skip + fi fi + sleep 3 } setup() { if [[ -n $TEST ]] ; then - run_only_test $TEST + run_only_test $TEST || exit 0 fi } diff --git a/tests/bats_to_sh.py b/tests/bats_to_sh.py index 30a21114..b4753417 100755 --- a/tests/bats_to_sh.py +++ b/tests/bats_to_sh.py @@ -13,17 +13,19 @@ for i in raw_data: if i == "@": inside = True elif i == "{" and inside and level == 0: - new_i = "\nsetup\n" + new_i = "\n( setup\n" elif i == "}" and inside and level == 1: inside = False - new_i = "" + new_i = ") || exit 1" if i == "{": level += 1 elif i == "}": level -= 1 output.append(new_i) -print "".join(output).replace("@test","echo").replace("|| skip","|| return") +print "".join(output).replace("@test ", +"""[[ -z $BATS_TEST_NUMBER ]] && BATS_TEST_NUMBER=0 || ((++BATS_TEST_NUMBER)) ; +export BATS_TEST_DESCRIPTION=""").replace("skip","return")