From 04b4d48d397d116c37bfedfca89f1b9850a02a5d Mon Sep 17 00:00:00 2001
From: Grzegorz Kowal <grzegorz@amuncode.org>
Date: Sun, 27 Dec 2020 23:15:49 -0300
Subject: [PATCH] INTEGRALS: Reorder the reconnection rate terms.

Signed-off-by: Grzegorz Kowal <grzegorz@amuncode.org>
---
 sources/integrals.F90 | 41 +++++++++++++++++++----------------------
 1 file changed, 19 insertions(+), 22 deletions(-)

diff --git a/sources/integrals.F90 b/sources/integrals.F90
index a0bc451..3e6bcf3 100644
--- a/sources/integrals.F90
+++ b/sources/integrals.F90
@@ -333,12 +333,11 @@ module integrals
 !
       write(runit,'("#",a8,20a25)')                                            &
           'step', 'time', '|Bx| int', '|Bx| inf'                               &
-                    , '|Bx| y-adv', '|Bx| y-shr', '|Bx| y-dif'                 &
-                    , '|Bx| z-adv', '|Bx| z-shr', '|Bx| z-dif'                 &
-                    , 'Vin lower' , 'Vin upper'                                &
-                    , 'Emag', 'Emag(inf)'                                      &
-                    , 'Emag(x-adv)', 'Emag(y-adv)', 'Emag(z-adv)'              &
-                    , 'Emag(x-dif)', 'Emag(y-dif)', 'Emag(z-dif)'
+                    , '|Bx| y-adv', '|Bx| z-adv', '|Bx| y-shr', '|Bx| z-shr'   &
+                    , '|Bx| y-dif', '|Bx| z-dif', 'Vin lower' , 'Vin upper'    &
+                    , 'Emag', 'Emag inf'                                       &
+                    , 'Emag x-adv', 'Emag y-adv', 'Emag z-adv'                 &
+                    , 'Emag x-dif', 'Emag y-dif', 'Emag z-dif'
       write(runit,"('#')")
 
     end if ! store
@@ -871,12 +870,12 @@ module integrals
 ! shear of By along X
 !
 #if NDIMS == 3
-          inarr(14) = inarr(14)                                                &
+          inarr(15) = inarr(15)                                                &
                     - sum(sign(pdata%q(iby,nb:ne,nbl:nb,nb:ne)                 &
                              * pdata%q(ivx,nb:ne,nbl:nb,nb:ne),                &
                                pdata%q(ibx,nb:ne,nbl:nb,nb:ne))) * dxz
 #else /* NDIMS == 3 */
-          inarr(14) = inarr(14)                                                &
+          inarr(15) = inarr(15)                                                &
                     - sum(sign(pdata%q(iby,nb:ne,nbl:nb,  :  )                 &
                              * pdata%q(ivx,nb:ne,nbl:nb,  :  ),                &
                                pdata%q(ibx,nb:ne,nbl:nb,  :  ))) * dxz
@@ -931,7 +930,7 @@ module integrals
 
 ! diffusion of Bx through the lower Y boundary
 !
-            inarr(15) = inarr(15) + sum(sign(tmp(:,1,:),                       &
+            inarr(17) = inarr(17) + sum(sign(tmp(:,1,:),                       &
                                         pdata%q(ibx,nb:ne,nb,nb:ne))) * dxz
 
 ! diffusion of magnetic energy through the lower Y boundary
@@ -954,7 +953,7 @@ module integrals
 
 ! diffusion of Bx through the lower Y boundary
 !
-            inarr(15) = inarr(15) + sum(sign(tmp(:,1,:),                       &
+            inarr(17) = inarr(17) + sum(sign(tmp(:,1,:),                       &
                                         pdata%q(ibx,nb:ne,nb ,  :  ))) * dxz
 
 ! diffusion of magnetic energy through the lower Y boundary
@@ -993,12 +992,12 @@ module integrals
 ! shear of By along X
 !
 #if NDIMS == 3
-          inarr(14) = inarr(14)                                                &
+          inarr(15) = inarr(15)                                                &
                     + sum(sign(pdata%q(iby,nb:ne,ne:neu,nb:ne)                 &
                              * pdata%q(ivx,nb:ne,ne:neu,nb:ne),                &
                                pdata%q(ibx,nb:ne,ne:neu,nb:ne))) * dxz
 #else /* NDIMS == 3 */
-          inarr(14) = inarr(14)                                                &
+          inarr(15) = inarr(15)                                                &
                     + sum(sign(pdata%q(iby,nb:ne,ne:neu,  :  )                 &
                              * pdata%q(ivx,nb:ne,ne:neu,  :  ),                &
                                pdata%q(ibx,nb:ne,ne:neu,  :  ))) * dxz
@@ -1053,7 +1052,7 @@ module integrals
 
 ! diffusion of Bx through the upper Y boundary
 !
-            inarr(15) = inarr(15) - sum(sign(tmp(:,1,:),                       &
+            inarr(17) = inarr(17) - sum(sign(tmp(:,1,:),                       &
                                         pdata%q(ibx,nb:ne,ne,nb:ne))) * dxz
 
 ! diffusion of magnetic energy through the upper Y boundary
@@ -1076,7 +1075,7 @@ module integrals
 
 ! diffusion of Bx through the upper Y boundary
 !
-            inarr(15) = inarr(15) - sum(sign(tmp(:,1,:),                       &
+            inarr(17) = inarr(17) - sum(sign(tmp(:,1,:),                       &
                                         pdata%q(ibx,nb:ne,ne,  :  ))) * dxz
 
 ! diffusion of magnetic energy through the upper Y boundary
@@ -1101,12 +1100,12 @@ module integrals
 
 ! advection of Bx along Z
 !
-            inarr(16) = inarr(16) + sum(abs(pdata%q(ibx,nb:ne,nb:ne,nbl:nb))   &
+            inarr(14) = inarr(14) + sum(abs(pdata%q(ibx,nb:ne,nb:ne,nbl:nb))   &
                                       * pdata%q(ivz,nb:ne,nb:ne,nbl:nb)) * dxy
 
 ! shear of Bz along X
 !
-            inarr(17) = inarr(17) - sum(sign(pdata%q(ibz,nb:ne,nb:ne,nbl:nb)   &
+            inarr(16) = inarr(16) - sum(sign(pdata%q(ibz,nb:ne,nb:ne,nbl:nb)   &
                                       * pdata%q(ivx,nb:ne,nb:ne,nbl:nb),       &
                                         pdata%q(ibx,nb:ne,nb:ne,nbl:nb))) * dxy
 
@@ -1158,12 +1157,12 @@ module integrals
 
 ! advection of Bx along Z
 !
-            inarr(16) = inarr(16) - sum(abs(pdata%q(ibx,nb:ne,nb:ne,ne:neu))   &
+            inarr(14) = inarr(14) - sum(abs(pdata%q(ibx,nb:ne,nb:ne,ne:neu))   &
                                       * pdata%q(ivz,nb:ne,nb:ne,ne:neu)) * dxy
 
 ! shear of Bz along X
 !
-            inarr(17) = inarr(17) + sum(sign(pdata%q(ibz,nb:ne,nb:ne,ne:neu)   &
+            inarr(16) = inarr(16) + sum(sign(pdata%q(ibz,nb:ne,nb:ne,ne:neu)   &
                                       * pdata%q(ivx,nb:ne,nb:ne,ne:neu),       &
                                         pdata%q(ibx,nb:ne,nb:ne,ne:neu))) * dxy
 
@@ -1260,10 +1259,8 @@ module integrals
 ! apply factors to the reconnection rate terms
 !
     inarr(12)    = 5.0d-01 * inarr(12) / yarea
-    inarr(13:14) = 5.0d-01 * inarr(13:14)
-    inarr(15)    = resistivity * inarr(15)
-    inarr(16:17) = 5.0d-01 * inarr(16:17)
-    inarr(18)    = resistivity * inarr(18)
+    inarr(13:16) = 5.0d-01 * inarr(13:16)
+    inarr(17:18) = resistivity * inarr(17:18)
     inarr(22)    = 2.5d-01 * inarr(22) / yarea
     inarr(23:25) = 5.0d-01 * inarr(23:25)
     inarr(26:28) = resistivity * inarr(26:28)