#! /bin/csh

#..... collect all file names of the KS Hamiltonian

ls Gold-KS_MAT-1_0_*Log > names.dat

#...... determine the KS Hamiltonian file from the last iteration
~/bin/lastname > 0
echo 'last name found is ' `cat 0`

#...... move it to a fixed name; remove the rest of the files

mv `cat 0` Gold-KS_MAT_last.Log
rm Gold-KS_MAT-1*.Log
rm *bak*
rm cp2k*

#...... run the scripts to extract necessary files

module load python3
echo 'creating the KS matirx ..'
python3 ~/bin/ks_ham_cp2k.py
echo 'creating the eigen-vectors/values ...'
python3 ~/bin/wfn_gs.py
echo 'removing garbage ..'
rm -rf ~/bin/__py*
rm 0

#...... archive
echo '... archiving ..'
gzip *Log tot* eigen*

