From dfcc56696df7f24c61946f639c767581499f7131 Mon Sep 17 00:00:00 2001
From: Rudolf Zeller <ru.zeller@fz-juelich.de>
Date: Tue, 18 May 2021 11:05:11 +0200
Subject: [PATCH] Add output forsum of x,y,z moments in unit cell in
 noncollinear mode

---
 source/KKRnano/source/ProcessKKRresults_mod.F90 | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/source/KKRnano/source/ProcessKKRresults_mod.F90 b/source/KKRnano/source/ProcessKKRresults_mod.F90
index a9a84435d..43a67fb69 100644
--- a/source/KKRnano/source/ProcessKKRresults_mod.F90
+++ b/source/KKRnano/source/ProcessKKRresults_mod.F90
@@ -1538,6 +1538,9 @@ module ProcessKKRresults_mod
     double precision moment_x !NOCO
     double precision moment_y !NOCO
     double precision moment_z !NOCO
+    double precision sum_moment_x !NOCO
+    double precision sum_moment_y !NOCO
+    double precision sum_moment_z !NOCO
     double precision max_delta_theta !NOCO
     double precision max_delta_phi !NOCO
     double precision max_delta_angle !NOCO
@@ -1578,6 +1581,9 @@ module ProcessKKRresults_mod
       if (korbit == 1) open(14,file='nonco_moment_out.txt',form='formatted') ! NOCO
     
       ! moments output
+        sum_moment_x = 0.0d0
+        sum_moment_y = 0.0d0
+        sum_moment_z = 0.0d0
       do i1 = 1, natoms
         if (npol == 0) then 
           read(71, rec=i1) qc,catom,charge,ecore,muorb,phi_noco,theta_noco,phi_noco_old,theta_noco_old,angle_fixed, &
@@ -1619,8 +1625,14 @@ module ProcessKKRresults_mod
                       theta_noco/(2.0D0*PI)*360.0D0, &
                       phi_noco/(2.0D0*PI)*360.0D0, &
                       angle_fixed
+        sum_moment_x = sum_moment_x + moment_x
+        sum_moment_y = sum_moment_y + moment_y
+        sum_moment_z = sum_moment_z + moment_z
         endif
       enddo ! i1
+        if (korbit == 1) then ! NOCO
+          write(14,"(3f12.5)") sum_moment_x, sum_moment_y, sum_moment_z
+         endif
 
       if (korbit == 1)  close(13)
       if (korbit == 1)  close(14)
-- 
GitLab