From eee2aad6d78d0e835c73f40f0785a52a3309265e Mon Sep 17 00:00:00 2001
From: Rudolf Zeller <ru.zeller@fz-juelich.de>
Date: Wed, 13 Jan 2021 21:36:38 +0100
Subject: [PATCH] Format of atomic potentials is changed by writing always a
 one to mark the end

---
 .../KKRnano/source/PotentialConverter_mod.F90  | 18 +++++++-----------
 source/KKRnano/source/read_formatted_mod.F90   |  4 ++--
 2 files changed, 9 insertions(+), 13 deletions(-)

diff --git a/source/KKRnano/source/PotentialConverter_mod.F90 b/source/KKRnano/source/PotentialConverter_mod.F90
index 546a3ca06..9fbdf6329 100644
--- a/source/KKRnano/source/PotentialConverter_mod.F90
+++ b/source/KKRnano/source/PotentialConverter_mod.F90
@@ -1,8 +1,3 @@
-!--------------------------------------------------------------------------------
-! Copyright (c) 2018 Forschungszentrum Juelich GmbH, Juelich, Germany
-! This file is part of KKRnano and available as free software under the conditions
-! of the MIT license as expressed in the LICENSE file in more detail.
-!--------------------------------------------------------------------------------
 module PotentialConverter_mod
 !-------------------------------------------------------------------------------
 !> Summary: Converts unformatted potential file to the KKRhost formatted potential file format
@@ -52,10 +47,10 @@ module PotentialConverter_mod
       call associateBasisAtomMesh(atomdata, mesh)
 
       ! show data on stdout
-      call represent(mesh, str)
-      write(*, '(A)') str
-      call represent(atomdata%potential, str)
-      write(*, '(A)') str
+!     call represent(mesh, str)
+!     write(*, '(A)') str
+!     call represent(atomdata%potential, str)
+!     write(*, '(A)') str
 
       call writeFormattedPotential(Efermi, ALAT, VBC, KXC, atomdata)
 
@@ -190,7 +185,7 @@ module PotentialConverter_mod
 
     double precision :: rv, sm
     integer :: ic, ir, irmin, is, lm, lmnr, lmpot, nr
-    integer, parameter :: isave = 1, inew = 1
+    integer, parameter :: isave = 1, inew = 2
     double precision, parameter :: qbound = 1.d-10
     character(len=24), parameter :: txc(0:3) = [' Morruzi,Janak,Williams', ' von Barth,Hedin       ', ' Vosko,Wilk,Nusair     ', ' GGA PW91              ']
     character(len=*), parameter :: F9000 = "(7a4,6x,'  exc:',a24,3x,a10)", &
@@ -236,7 +231,8 @@ module PotentialConverter_mod
         enddo ! lm
 
 !--->     write a one to mark the end
-        if (lmnr < lmpot) write(ifile, fmt=F9060) isave
+!       if (lmnr < lmpot) write(ifile, fmt=F9060) isave
+        write(ifile, fmt=F9060) isave
       endif
     enddo ! is
 
diff --git a/source/KKRnano/source/read_formatted_mod.F90 b/source/KKRnano/source/read_formatted_mod.F90
index 9071135bf..aef3af8e8 100644
--- a/source/KKRnano/source/read_formatted_mod.F90
+++ b/source/KKRnano/source/read_formatted_mod.F90
@@ -179,7 +179,7 @@ module read_formatted_mod
     blocks%vins = 0.d0
 
     lm1 = 2
-    do lm = 2, sb%lmpot
+    do lm = 2, sb%lmpot + 1
       if (lm1 /= 1) then
 
         if (sb%isave == 1) then
@@ -192,7 +192,7 @@ module read_formatted_mod
         if (lm1 > 1) then
 
           if (lm1 < 1)        die_here("potential file is not formatted correctly, lm ="+lm1+"out of range! Atom#"-atom_id)
-          if (lm1 > sb%lmpot) die_here("potential file is not formatted correctly, lm ="+lm1-", but lmpot ="+sb%lmpot+" for Atom#"-atom_id)
+!         if (lm1 > sb%lmpot) die_here("potential file is not formatted correctly, lm ="+lm1-", but lmpot ="+sb%lmpot+" for Atom#"-atom_id)
 
           read(unit, fmt="(1p,4d20.13)", iostat=ios) blocks%vins(irmin:sb%irt1p,lm1)
           if (ios /= 0) die_here("failed to read non-spherical potential array vins(:,"-lm1-")! Atom#"-atom_id)
-- 
GitLab