From fd7824144b34577bf60a37fbcf6c208d2095569e Mon Sep 17 00:00:00 2001
From: Philipp Ruessmann <p.ruessmann@fz-juelich.de>
Date: Mon, 4 Jul 2022 16:12:17 +0200
Subject: [PATCH] Minor cleanup

---
 source/KKRhost/main0.F90                   |  2 +-
 source/KKRhost/rhovalnew.F90               |  7 ++-----
 source/KKRhost/tmat_newsolver.F90          | 13 -------------
 tests/KKRhost/tools/test_verify_BdG.py     |  7 ++++++-
 tests/KKRhost/tools/test_verify_results.py | 10 ++++++++--
 5 files changed, 17 insertions(+), 22 deletions(-)

diff --git a/source/KKRhost/main0.F90 b/source/KKRhost/main0.F90
index d3cf0f8cf..78fe51298 100644
--- a/source/KKRhost/main0.F90
+++ b/source/KKRhost/main0.F90
@@ -1547,7 +1547,7 @@ contains
 
     write (iunit, '(1A)') '     Screened Korringa-Kohn-Rostoker Electronic Structure Code'
     write (iunit, '(1A)') '                      for Bulk and Interfaces'
-    write (iunit, '(1A)') '                    Juelich-Munich 2001 - 2021'
+    write (iunit, '(1A)') '                    Juelich-Munich 2001 - 2022'
     write (iunit, '(1A)') ''
     write (iunit, '(2A)') '  Code version: ', trim(version1)
     write (iunit, '(6A)') '  Compile options: ', trim(version2), ' ', trim(version3), ' ', trim(version4)
diff --git a/source/KKRhost/rhovalnew.F90 b/source/KKRhost/rhovalnew.F90
index e50b3fa45..3ed968dbd 100644
--- a/source/KKRhost/rhovalnew.F90
+++ b/source/KKRhost/rhovalnew.F90
@@ -539,9 +539,6 @@ contains
           call rllsll(rpan_intervall, rnew, vnspll(:,:,:,ith), rllleft(:,:,:,ith), sllleft(:,:,:,ith), tmattemp, ncheb, npan_tot, &
             lmmaxd*(1+kBdG), nvec*lmmaxd*(1+kBdG), nsra*(1+korbit)*(lmax+1)*(1+kBdG), irmdnew, nsra, &
             jlk_index, hlk2(:,:,ith), jlk2(:,:,ith), hlk(:,:,ith), jlk(:,:,ith), gmatprefactor, use_sratrick, alphall, calcrll, calcsll, calctmat)
-            ! ! testing
-            ! ull(lmmaxd*(1+kBdG)+1:nvec*lmmaxd*(1+kBdG), :, :, ith) = rllleft(lmmaxd*(1+kBdG)+1:nvec*lmmaxd*(1+kBdG), :, :, ith)
-            ! ull(lmmaxd*(1+kBdG)+1:nvec*lmmaxd*(1+kBdG), :, :, ith) = ull(lmmaxd*(1+kBdG)+1:nvec*lmmaxd*(1+kBdG), :, :, ith)/cvlight
         end if
         if (nsra==2) then
           ullleft(lmmaxd*(1+kBdG)+1:nvec*lmmaxd*(1+kBdG), :, :, ith) = ullleft(lmmaxd*(1+kBdG)+1:nvec*lmmaxd*(1+kBdG), :, :, ith)/cvlight
@@ -1067,7 +1064,7 @@ contains
         moment(1) = aimag(rho2int(3)+rho2int(4))
         moment(2) = -real(rho2int(3)-rho2int(4))
         moment(3) = aimag(-rho2int(1)+rho2int(2))
-        
+
         totmoment = sqrt(moment(1)**2+moment(2)**2+moment(3)**2)
         totxymoment = sqrt(moment(1)**2+moment(2)**2)
 
@@ -1108,7 +1105,7 @@ contains
 
 #ifdef CPP_MPI
     end if                         ! (myrank==master)
-    
+
     ! communicate den_out to all processors with the same atom number
     idim = (lmax+2)*ielast*nspin/(nspin-korbit)*(1+kBdG)**2
     call mpi_bcast(den_out, idim, mpi_double_complex, master, t_mpi_c_grid%mympi_comm_at, ierr)
diff --git a/source/KKRhost/tmat_newsolver.F90 b/source/KKRhost/tmat_newsolver.F90
index 52ca490a3..dddc1923e 100644
--- a/source/KKRhost/tmat_newsolver.F90
+++ b/source/KKRhost/tmat_newsolver.F90
@@ -1204,18 +1204,6 @@ contains
     else
       use_fullgmat = 1
     end if
-    
-    write (filename, '(A)') 'rll_source_input.dat'
-    open (888888, file=trim(filename), form='formatted')
-    write (888888, *) 'dims', nsra, nvec, eryd, rnew, irmdnew, nrmaxd, lmax, lmmaxd, use_fullgmat
-    write (888888, *) 'jlk_index', jlk_index
-    write (888888, *) 'hlk', hlk(:,:,ith)
-    write (888888, *) 'jlk', jlk(:,:,ith)
-    write (888888, *) 'hlk2', hlk2(:,:,ith)
-    write (888888, *) 'jlk2', jlk2(:,:,ith)
-    write (888888, *) 'gmatprefac', gmatprefactor
-    close (888888)
-
     call rllsllsourceterms(nsra, nvec, eryd, rnew, irmdnew, nrmaxd, lmax, lmmaxd, use_fullgmat, jlk_index, hlk(:,:,ith), jlk(:,:,ith), hlk2(:,:,ith), jlk2(:,:,ith), gmatprefactor)
     if (check_custom_testopt('gmatprefac1')) gmatprefactor(:) = (1.0_dp, 0.0_dp)
 
@@ -1243,7 +1231,6 @@ contains
       write (888888, '(A,I9,A,I9,A,2ES15.7)') '# dimension: 4*(LMAX+1)=', 4*(lmax+1)*(1+kBdG), ' IRMDNEW=', irmdnew, ' ; ERYD=', eryd
       write (888888, '(2ES21.9)') sum(hlk2(:, :, ith), 2)
       close (888888)
-      stop 'done writing rll source'
     end if
 #ifdef CPP_OMP
     !$omp end critical
diff --git a/tests/KKRhost/tools/test_verify_BdG.py b/tests/KKRhost/tools/test_verify_BdG.py
index 9aa2bc858..141a3bf78 100644
--- a/tests/KKRhost/tools/test_verify_BdG.py
+++ b/tests/KKRhost/tools/test_verify_BdG.py
@@ -6,6 +6,7 @@ from __future__ import print_function
 #import pytest
 from numpy import array, load, sum, conjugate
 from common_functions import search_string, cmp_modes
+import os
 
 
 class Test_BdG():
@@ -23,12 +24,15 @@ class Test_BdG():
         path0 = 'test_run26_hybrid_4_1/eh_symm/'
         
         print('Check if t^ee(E+i0+) == -t^hh(E+i0+) :')
-        tmat = load(path0+'tmat_atom_001_energ_001.npy')
+        assert os.path.exists(path0+'tmat_atom_001_energ_001.npy')
+        tmat = load()
         check_ehsymm(tmat)
         print('\n Check Gref:')
+        assert os.path.exists(path0+'ginp_energ_001.npy')
         gref = load(path0+'ginp_energ_001.npy')[:,:,-1]
         check_ehsymm(gref)
         print('\n Check Gmat:')
+        assert os.path.exists(path0+'gmat_001_energ_001.npy')
         gmat = load(path0+'gmat_001_energ_001.npy')
         check_ehsymm(gmat)
 
@@ -39,6 +43,7 @@ class Test_BdG():
         import numpy as np
         path0 = 'test_run27_hybrid_1_1/qdos/'
         ef = float(open(path0+'/potential').readlines()[3].split()[1])
+        assert os.path.exists(path0+'/qdos.001.1.dat')
         q = np.loadtxt(path0+'/qdos.001.1.dat')
         ne = len(set(q[:,0])); nq = len(q)//ne
         e = q[:,0].reshape(ne,nq)[:,0]; e = (e-ef)*13.6
diff --git a/tests/KKRhost/tools/test_verify_results.py b/tests/KKRhost/tools/test_verify_results.py
index d6ebaa2ef..7cc413b39 100644
--- a/tests/KKRhost/tools/test_verify_results.py
+++ b/tests/KKRhost/tools/test_verify_results.py
@@ -8,6 +8,7 @@ import pprint
 from kkrparser_functions import parse_kkr_outputfile
 from numpy import mean, std, array, loadtxt
 from common_functions import cmp_modes
+import os
 
 
 class Test_serial():
@@ -339,11 +340,15 @@ def standard_verify(path0, rms_threshold=10**-8, rms_threshold_end=10**-8, neutr
     """
     wrapper for standard tests reading output and comparins rms and charge neutrality
     """
-    # use parser function from aiida-kkr
+    # first check if the path exists
+    assert os.path.exists(path0)
+
+    # then use parser function from aiida-kkr
     success, parser_msgs, out_dict = parse_kkr_outputfile({}, path0+'out_kkr', path0+'output.0.txt', path0+'output.000.txt', path0+'out_timing.000.txt', path0+'out_potential', path0+'nonco_angle_out.dat', debug=debug)
     pprint.pprint(parser_msgs)
     pprint.pprint(out_dict)
-    # first check if parsing was successful
+
+    # check if parsing was successful
     assert success
     # check if initial iteration is still converged
     assert out_dict['convergence_group']['rms_all_iterations'][0] < rms_threshold
@@ -352,6 +357,7 @@ def standard_verify(path0, rms_threshold=10**-8, rms_threshold_end=10**-8, neutr
     # check if charge neutrality is correct
     assert abs(out_dict['convergence_group']['charge_neutrality']) <= neutr_threshold
 
+
 def read_file(path):
    """
    helper function to read in text file given in 'path'
-- 
GitLab