From c39393731aaeb0854b0ef6881f0e87bfdc577d13 Mon Sep 17 00:00:00 2001
From: ruess <p.ruessmann@fz-juelich.de>
Date: Tue, 3 Aug 2021 15:57:34 +0200
Subject: [PATCH] Activate potential writeout with '<write_BdG_tests>= T' input

---
 source/KKRhost/rhovalnew.F90      |  4 ++--
 source/KKRhost/tmat_newsolver.F90 | 21 +++++++++------------
 2 files changed, 11 insertions(+), 14 deletions(-)

diff --git a/source/KKRhost/rhovalnew.F90 b/source/KKRhost/rhovalnew.F90
index 6ebde86ad..c905ee550 100644
--- a/source/KKRhost/rhovalnew.F90
+++ b/source/KKRhost/rhovalnew.F90
@@ -602,8 +602,8 @@ contains
         alphall = czero
         ! faster calculation of RLLLEFT and SLLLEFT.
         if (.not.set_cheby_nospeedup .and. .not. (calc_exchange_couplings .or. write_pkkr_operators)) then
-          call rll_global_solutions(rpan_intervall, rnew, vnspll(:,:,:,ith),ullleft(:,:,:,ith), rllleft(:,:,:,ith), tmattemp, ncheb, npan_tot, lmmaxd, nvec*lmmaxd, nsra*(1+korbit)*(lmax+1), irmdnew, nsra, &
-            jlk_index, hlk2(:,:,ith), jlk2(:,:,ith), hlk(:,:,ith), jlk(:,:,ith), gmatprefactor, '1', use_sratrick,               alphall)
+          call rll_global_solutions(rpan_intervall, rnew, vnspll(:,:,:,ith), ullleft(:,:,:,ith), rllleft(:,:,:,ith), tmattemp, ncheb, npan_tot, lmmaxd, nvec*lmmaxd, nsra*(1+korbit)*(lmax+1), irmdnew, nsra, &
+            jlk_index, hlk2(:,:,ith), jlk2(:,:,ith), hlk(:,:,ith), jlk(:,:,ith), gmatprefactor, '1', use_sratrick, alphall)
           call sll_global_solutions(rpan_intervall, rnew, vnspll(:,:,:,ith), sllleft(:,:,:,ith), ncheb, npan_tot, lmmaxd, nvec*lmmaxd, nsra*(1+korbit)*(lmax+1), irmdnew, nsra, jlk_index, &
             hlk2(:,:,ith), jlk2(:,:,ith), hlk(:,:,ith), jlk(:,:,ith), gmatprefactor, '1', use_sratrick)
         else
diff --git a/source/KKRhost/tmat_newsolver.F90 b/source/KKRhost/tmat_newsolver.F90
index 5927d9523..25e34fcb0 100644
--- a/source/KKRhost/tmat_newsolver.F90
+++ b/source/KKRhost/tmat_newsolver.F90
@@ -214,15 +214,14 @@ contains
 
     ! set up the non-spherical ll' matrix for potential VLL' (done in VLLMAT)
     call vllmat(1, nrmaxd, irmdnew, lmmax0d, lmmaxd, vnspll0, vins, lmpot, cleb, icleb, iend, nspin/(nspin-korbit), zat, rnew, use_sratrick, ncleb)
-#ifdef CPP_BdG
     ! test writeout of VNSPLL1
     if (write_BdG_tests) then
-      open (7352834, file='vnspll.txt', form='formatted')
+      write (filename, '(A,I0.3,A)') 'vnspll_', i1, '.txt'
+      open (7352834, file=trim(filename), form='formatted')
       write (7352834, '(A,3I9)') '# lmmaxd,lmmaxd,IRMDNEW=', lmmaxd, lmmaxd, irmdnew
-      write (7352834, '(2ES25.16)') vnspll0(:, :, :)
+      write (7352834, '(2ES25.9)') vnspll0(:, :, :)
       close (7352834)
     end if
-#endif
     ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
     ! LDAU
     ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@@ -356,15 +355,14 @@ contains
 #ifdef CPP_OMP
         !$omp critical
 #endif
-#ifdef CPP_BdG
         ! test writeout of VNSPLL1
         if (write_BdG_tests) then
-          open (7352834, file='vnspll_SOC.txt', form='formatted')
+          write (filename, '(A,I0.3,A,I0.3,A)') 'vnspll_SOC_', i1, '_energ_', ie, '.txt'
+          open (7352834, file=trim(filename), form='formatted')
           write (7352834, '(A,3I9)') '# lmmaxd,lmmaxd,IRMDNEW=', lmmaxd, lmmaxd, irmdnew
-          write (7352834, '(2ES25.16)') vnspll1(:, :, :, ith)
+          write (7352834, '(2ES25.9)') vnspll1(:, :, :, ith)
           close (7352834)
         end if
-#endif
 #ifdef CPP_OMP
         !$omp end critical
 #endif
@@ -387,19 +385,18 @@ contains
 #ifdef CPP_OMP
         !$omp critical
 #endif
-#ifdef CPP_BdG
         ! test writeout of VNPSLL
         if (write_BdG_tests) then
-          open (7352834, file='vnspll_sra.txt', form='formatted')
+          write (filename, '(A,I0.3,A,I0.3,A)') 'vnspll_sra_', i1, '_energ_', ie, '.txt'
+          open (7352834, file=trim(filename), form='formatted')
           if (nsra==2) then
             write (7352834, '(A,3I9)') '# 2*lmmaxd,2*lmmaxd,IRMDNEW=', 2*lmmaxd, 2*lmmaxd, irmdnew
           else
             write (7352834, '(A,3I9)') '# lmmaxd,lmmaxd,IRMDNEW=', lmmaxd, lmmaxd, irmdnew
           end if
-          write (7352834, '(2ES25.16)') vnspll(:, :, :, ith)
+          write (7352834, '(2ES25.9)') vnspll(:, :, :, ith)
           close (7352834)
         end if
-#endif
 #ifdef CPP_OMP
         !$omp end critical
 #endif
-- 
GitLab