From e2c1bc04037f27092f3b189c2a3fb12dab2717f5 Mon Sep 17 00:00:00 2001
From: Quentin Rodier <quentin.rodier@meteo.fr>
Date: Mon, 28 Jun 2021 14:06:55 +0200
Subject: [PATCH] Quentin 28/06/2021: bugfix budget key DEPI->CDEPI + abort if
 LIMA and LSUBG_COND=T with LPTSPLIT=F

---
 src/MNH/lima.f90        |  6 +++---
 src/MNH/read_exsegn.f90 | 10 +++++++++-
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/src/MNH/lima.f90 b/src/MNH/lima.f90
index cdb5a5391..1da913dc8 100644
--- a/src/MNH/lima.f90
+++ b/src/MNH/lima.f90
@@ -1648,7 +1648,7 @@ if ( lbu_enable ) then
     call Budget_store_add( tbudgets(NBUDGET_TH), 'HONC',  ztot_th_honc (:, :, :) * zrhodjontstep(:, :, :) )
     call Budget_store_add( tbudgets(NBUDGET_TH), 'HONR',  ztot_th_honr (:, :, :) * zrhodjontstep(:, :, :) )
     call Budget_store_add( tbudgets(NBUDGET_TH), 'DEPS',  ztot_th_deps (:, :, :) * zrhodjontstep(:, :, :) )
-    call Budget_store_add( tbudgets(NBUDGET_TH), 'DEPI',  ztot_th_depi (:, :, :) * zrhodjontstep(:, :, :) )
+    call Budget_store_add( tbudgets(NBUDGET_TH), 'CDEPI',  ztot_th_depi (:, :, :) * zrhodjontstep(:, :, :) )
     call Budget_store_add( tbudgets(NBUDGET_TH), 'DEPG',  ztot_th_depg (:, :, :) * zrhodjontstep(:, :, :) )
     call Budget_store_add( tbudgets(NBUDGET_TH), 'IMLT',  ztot_th_imlt (:, :, :) * zrhodjontstep(:, :, :) )
     call Budget_store_add( tbudgets(NBUDGET_TH), 'BERFI', ztot_th_berfi(:, :, :) * zrhodjontstep(:, :, :) )
@@ -1663,7 +1663,7 @@ if ( lbu_enable ) then
   if ( lbudget_rv ) then
     call Budget_store_add( tbudgets(NBUDGET_RV), 'REVA', -ztot_rr_evap (:, :, :) * zrhodjontstep(:, :, :) )
     call Budget_store_add( tbudgets(NBUDGET_RV), 'DEPS', -ztot_rs_deps (:, :, :) * zrhodjontstep(:, :, :) )
-    call Budget_store_add( tbudgets(NBUDGET_RV), 'DEPI', -ztot_ri_depi (:, :, :) * zrhodjontstep(:, :, :) )
+    call Budget_store_add( tbudgets(NBUDGET_RV), 'CDEPI', -ztot_ri_depi (:, :, :) * zrhodjontstep(:, :, :) )
     call Budget_store_add( tbudgets(NBUDGET_RV), 'DEPG', -ztot_rg_depg (:, :, :) * zrhodjontstep(:, :, :) )
     call Budget_store_add( tbudgets(NBUDGET_RV), 'CORR2', ztot_rv_corr2(:, :, :) * zrhodjontstep(:, :, :) )
   end if
@@ -1705,7 +1705,7 @@ if ( lbu_enable ) then
     call Budget_store_add( tbudgets(NBUDGET_RI), 'BERFI', -ztot_rc_berfi(:, :, :) * zrhodjontstep(:, :, :) )
     call Budget_store_add( tbudgets(NBUDGET_RI), 'HMS',    ztot_ri_hms  (:, :, :) * zrhodjontstep(:, :, :) )
     call Budget_store_add( tbudgets(NBUDGET_RI), 'CFRZ',   ztot_ri_cfrz (:, :, :) * zrhodjontstep(:, :, :) )
-    call Budget_store_add( tbudgets(NBUDGET_RI), 'DEPI',   ztot_ri_depi (:, :, :) * zrhodjontstep(:, :, :) )
+    call Budget_store_add( tbudgets(NBUDGET_RI), 'CDEPI',   ztot_ri_depi (:, :, :) * zrhodjontstep(:, :, :) )
     call Budget_store_add( tbudgets(NBUDGET_RI), 'WETG',   ztot_ri_wetg (:, :, :) * zrhodjontstep(:, :, :) )
     call Budget_store_add( tbudgets(NBUDGET_RI), 'DRYG',   ztot_ri_dryg (:, :, :) * zrhodjontstep(:, :, :) )
     call Budget_store_add( tbudgets(NBUDGET_RI), 'HMG',    ztot_ri_hmg  (:, :, :) * zrhodjontstep(:, :, :) )
diff --git a/src/MNH/read_exsegn.f90 b/src/MNH/read_exsegn.f90
index fac8e124c..9732fe407 100644
--- a/src/MNH/read_exsegn.f90
+++ b/src/MNH/read_exsegn.f90
@@ -387,7 +387,8 @@ USE MODN_PARAM_ICE
 USE MODN_PARAM_KAFR_n
 USE MODN_PARAM_LIMA, ONLY : FINI_CCN=>HINI_CCN,NAM_PARAM_LIMA,NMOD_CCN,LSCAV, &
                             CPRISTINE_ICE_LIMA, CHEVRIMED_ICE_LIMA, NMOD_IFN, &
-                            LCOLD, LACTI, LNUCL, XALPHAC, XNUC, LMEYERS, LHAIL
+                            LCOLD, LACTI, LNUCL, XALPHAC, XNUC, LMEYERS, LHAIL,&
+                            LPTSPLIT
 USE MODN_PARAM_MFSHALL_n
 USE MODN_PARAM_n    ! realized in subroutine ini_model n
 USE MODN_PARAM_RAD_n
@@ -1267,6 +1268,13 @@ SELECT CASE ( CCLOUD )
 !!$      CALL PRINT_MSG(NVERB_FATAL,'GEN','READ_EXSEG_n','')
 !!$    END IF 
 !
+    IF (CCLOUD == 'LIMA' .AND. LSUBG_COND .AND. (.NOT. LPTSPLIT)) THEN
+      WRITE(UNIT=ILUOUT,FMT=9001) KMI
+      WRITE(UNIT=ILUOUT,FMT=*) 'YOU MUST USE LPTSPLIT=T with CCLOUD=LIMA'
+      WRITE(UNIT=ILUOUT,FMT=*) 'AND LSUBG_COND '
+      CALL PRINT_MSG(NVERB_FATAL,'GEN','READ_EXSEG_n','use LPTSPLIT=T with LIMA and LSUBG_COND=T')
+    END IF
+!    
     IF ( XALPHAC /= 3.0 .OR. XNUC /= 2.0) THEN
       WRITE(UNIT=ILUOUT,FMT=9001) KMI
       WRITE(UNIT=ILUOUT,FMT=*) 'IT IS ADVISED TO USE XALPHAC=3. and XNUC=2.'
-- 
GitLab