From ee23f391953243017f930bffce60adde00d77885 Mon Sep 17 00:00:00 2001
From: Nicolas Essing <n.essing@fz-juelich.de>
Date: Thu, 28 Oct 2021 10:00:42 +0200
Subject: [PATCH] Bugfix concerning nonco bfield data.

The bfields are now always allocated, as they are passed around to
some subroutines even if they are not used. The types are small if
they are not initialized, so that doesn't matter.
Actually, I never got an error from this bug, but I think this
might depend on the compiler.
---
 source/KKRnano/source/CalculationData_mod.F90 | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/source/KKRnano/source/CalculationData_mod.F90 b/source/KKRnano/source/CalculationData_mod.F90
index 51b0fe716..7c2e39df9 100644
--- a/source/KKRnano/source/CalculationData_mod.F90
+++ b/source/KKRnano/source/CalculationData_mod.F90
@@ -138,11 +138,10 @@ module CalculationData_mod
     allocate(self%madelung_sum_a(num_local_atoms)) ! only visible to this module and MadelungPotential_mod.F90
     allocate(self%jij_data_a(num_local_atoms)) 
     if(num_local_atoms > 1 .and. params%Jij) warn(6, "Jij work with max. 1 atom so far!") 
-    
-    ! Allocate bfields only if used
-    if (params%noncobfield) then
-      allocate(self%bfields(num_local_atoms))
-    end if
+
+    ! Always allocate bfields, they are small objects and are passed around to
+    ! some subroutines even if they are not used.
+    allocate(self%bfields(num_local_atoms))
 
     allocate(self%atom_ids(num_local_atoms))
 
-- 
GitLab