From ced271b095bd7a77efe48bb457309658e79e379c Mon Sep 17 00:00:00 2001
From: Quentin Rodier <quentin.rodier@meteo.fr>
Date: Tue, 28 Nov 2023 17:24:22 +0100
Subject: [PATCH] Quentin 28/11/2023: bugfix merge of ELEC to PHYEX
 contributions

---
 src/PHYEX/micro/ini_rain_ice_elec.f90 | 6 ------
 src/PHYEX/micro/mode_ice4_pack.f90    | 2 +-
 src/PHYEX/micro/rain_ice.f90          | 4 +---
 3 files changed, 2 insertions(+), 10 deletions(-)

diff --git a/src/PHYEX/micro/ini_rain_ice_elec.f90 b/src/PHYEX/micro/ini_rain_ice_elec.f90
index 3a0279455..1a7fa798b 100644
--- a/src/PHYEX/micro/ini_rain_ice_elec.f90
+++ b/src/PHYEX/micro/ini_rain_ice_elec.f90
@@ -208,12 +208,6 @@ IF (CSEDIM == 'SPLI') THEN
   END DO SPLIT
 END IF
 !
-IF (HCLOUD == 'ICE4') THEN
-  CALL RAIN_ICE_DESCR_ALLOCATE(7)
-ELSE IF (HCLOUD == 'ICE3') THEN
-  CALL RAIN_ICE_DESCR_ALLOCATE(6)
-END IF
-!
 XRTMIN(1) = 1.0E-20
 XRTMIN(2) = 1.0E-20
 XRTMIN(3) = 1.0E-20
diff --git a/src/PHYEX/micro/mode_ice4_pack.f90 b/src/PHYEX/micro/mode_ice4_pack.f90
index 8c334e752..75e770993 100644
--- a/src/PHYEX/micro/mode_ice4_pack.f90
+++ b/src/PHYEX/micro/mode_ice4_pack.f90
@@ -299,7 +299,7 @@ IF(PARAMI%LPACK_MICRO) THEN
               ! Save indices for later usages:
               I1(IC) = JIJ
               I2(IC) = JK
-              IF(BUCONF%LBU_ENABLE) THEN
+              IF(BUCONF%LBU_ENABLE .OR. OSAVE_MICRO) THEN
                 I1TOT(JMICRO+IC-1)=JIJ
                 I2TOT(JMICRO+IC-1)=JK
               ENDIF
diff --git a/src/PHYEX/micro/rain_ice.f90 b/src/PHYEX/micro/rain_ice.f90
index 0eebb9cc0..8c000324b 100644
--- a/src/PHYEX/micro/rain_ice.f90
+++ b/src/PHYEX/micro/rain_ice.f90
@@ -364,7 +364,7 @@ LOGICAL, DIMENSION(D%NIJT,D%NKT) :: LLW3D
 REAL, DIMENSION(KRR) :: ZRSMIN
 INTEGER :: ISIZE, IPROMA, IGPBLKS, ISIZE2
 !
-LOGICAL :: LSAVE_MICRO ! if true, microphysical tendencies are saved for cloud electricity
+LOGICAL :: LSAVE_MICRO = .FALSE. ! if true, microphysical tendencies are saved for cloud electricity
 REAL, DIMENSION(MERGE(D%NIJT,0,OELEC),MERGE(D%NKT,0,OELEC),MERGE(IBUNUM-IBUNUM_EXTRA,0,OELEC)) :: &
            ZMICRO_TEND ! Total mixing ratio change, used for electric charge tendencies
 LOGICAL, DIMENSION(MERGE(D%NIJT,0,OELEC),MERGE(D%NKT,0,OELEC)) :: GMASK_ELEC
@@ -530,8 +530,6 @@ ENDIF
 IF (OELEC) THEN
   LSAVE_MICRO = .TRUE.
   ZMICRO_TEND(:,:,:) = 0.
-ELSE
-  LSAVE_MICRO = .FALSE.
 END IF
 !
 !This part is put in another routine to separate pack/unpack operations from computations
-- 
GitLab