#!/usr/bin/env python

import os
import sys
import shutil

sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
from runtest_dirac import Filter, TestRun
from exacorr_environment import set_exacorr_environment

set_exacorr_environment()

test = TestRun(__file__, sys.argv)

f = Filter()
f.add(from_string = 'Final CCSD energy',
      num_lines   = 7,
      rel_tolerance   = 1.0e-6)
f.add(from_string = 'SCF energy ( read )',
      num_lines   = 1,
      rel_tolerance   = 1.0e-5)
f.add(from_string = 'read active occupied spinors',
      num_lines   = 22,
      rel_tolerance   = 1.0e-5)

os.environ["OMP_STACKSIZE"] = "200M"
os.system('ulimit -s unlimited')

shutil.copyfile(r'h2o-1c.rsd_mos',r'RSD_MOS')
test.run(['cc_respect_1c.inp'], ['h2o.xyz'], f, args=' --put=RSD_MOS ')
shutil.copyfile(r'h2o-2c.rsd_mos',r'RSD_MOS')
test.run(['cc_respect_2c.inp'], ['h2o.xyz'], f, args=' --put=RSD_MOS ')
test.run(['cc_exacorr_x2cmmf.inp'], ['h2o.xyz'], f, args="--get='X2CMAT'")
test.run(['cc_exacorr_nonrel.inp'], ['h2o.xyz'], f)

#LV: deactivated this RELCCSD run as it does not test exacorr (works, but it does not belong here and takes too long)
#f1 = Filter()
#f1.add(from_string = 'Overview of calculated energies',
#      num_lines   = 7,
#      rel_tolerance   = 1.0e-6)
#
#test.run(['cc_relcc_x2cmmf.inp'], ['h2o.xyz'], f1, args="--put='X2CMAT'")

sys.exit(test.return_code)
