From c057615b4c53f342af0a59e062ed19a4e4e4fcf8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Philipp=20R=C3=BC=C3=9Fmann?= <p.ruessmann@fz-juelich.de>
Date: Mon, 25 Jul 2022 14:26:01 +0200
Subject: [PATCH] Fix a possible divide by zero in LDAU writeout

---
 source/KKRhost/initldau.f90 | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/source/KKRhost/initldau.f90 b/source/KKRhost/initldau.f90
index 7267f1f0b..01d982a5b 100644
--- a/source/KKRhost/initldau.f90
+++ b/source/KKRhost/initldau.f90
@@ -207,6 +207,13 @@ contains
         write (1337, '(12X,A,2F8.4,A,/)') 'Ueff and Jeff = ', ueff(i1), jeff(i1), ' Ry'
         write (1337, '(12X,"Scaling factor for F^n :",F10.6,/)') scl
         write (1337, '(12X,"  n   F^n calculated   F^n scaled ")')
+        
+        if (scl==0) then
+          ! to prevent division by zero
+          ! we can do this here because scl is not use anymore in the remainder
+          scl = 1.0
+        end if
+
         do lf = 2, lfmax, 2
           write (1337, '(12X,I3,2(2X,F12.8," Ry"))') lf, fclmb(lf)/scl, fclmb(lf)
         end do
-- 
GitLab