From dcb0d16af0206e6f288a476b06971de521a8b316 Mon Sep 17 00:00:00 2001
From: VIE Benoit <vie@sxphynh>
Date: Mon, 30 Jan 2023 14:07:39 +0100
Subject: [PATCH] start mesonh compilation debugging

---
 src/mesonh/aux/sources_neg_correct.f90 |  2 +-
 src/mesonh/ext/default_desfmn.f90      |  9 ++-------
 src/mesonh/ext/resolved_cloud.f90      |  6 +++---
 src/mesonh/micro/lima_cold.f90         | 12 ++++++------
 src/mesonh/micro/lima_notadjust.f90    |  8 ++++----
 src/mesonh/micro/set_conc_lima.f90     |  2 +-
 tools/check_commit_mesonh.sh           |  2 +-
 7 files changed, 18 insertions(+), 23 deletions(-)

diff --git a/src/mesonh/aux/sources_neg_correct.f90 b/src/mesonh/aux/sources_neg_correct.f90
index a1e832734..030283940 100644
--- a/src/mesonh/aux/sources_neg_correct.f90
+++ b/src/mesonh/aux/sources_neg_correct.f90
@@ -53,7 +53,7 @@ use modd_budget,     only: lbudget_th, lbudget_rv, lbudget_rc, lbudget_rr, lbudg
 use modd_cst,        only: xci, xcl, xcpd, xcpv, xlstt, xlvtt, xp00, xrd, xtt
 use modd_nsv,        only: nsv_c2r2beg, nsv_c2r2end, nsv_lima_beg, nsv_lima_end, nsv_lima_nc, nsv_lima_nr,&
                            nsv_lima_ni, nsv_lima_ns, nsv_lima_ng, nsv_lima_nh
-use modd_param_lima, only: lcold_lima => lcold, lrain_lima => lrain, lspro_lima => lspro, lwarm_lima => lwarm, &
+use modd_param_lima, only: lspro_lima => lspro, &
                            xctmin_lima => xctmin, xrtmin_lima => xrtmin
 
 use mode_budget,         only: Budget_store_init, Budget_store_end
diff --git a/src/mesonh/ext/default_desfmn.f90 b/src/mesonh/ext/default_desfmn.f90
index 0597b379c..e9cbb0eae 100644
--- a/src/mesonh/ext/default_desfmn.f90
+++ b/src/mesonh/ext/default_desfmn.f90
@@ -278,13 +278,13 @@ USE MODD_ALLPROFILER_n
 USE MODD_ALLSTATION_n
 !
 !
-USE MODD_PARAM_LIMA, ONLY : LCOLD, LNUCL, LSEDI, LHHONI, LSNOW, LHAIL, LMEYERS,         &
+USE MODD_PARAM_LIMA, ONLY : LNUCL, LSEDI, LHHONI, LMEYERS,                              &
                             NMOM_I, NMOM_S, NMOM_G, NMOM_H,                             &
                             NMOD_IFN, XIFN_CONC, LIFN_HOM, CIFN_SPECIES,                &
                             CINT_MIXING, NMOD_IMM, NIND_SPECIE, LMURAKAMI,              &
                             YSNOW_T=>LSNOW_T, CPRISTINE_ICE_LIMA, CHEVRIMED_ICE_LIMA,   &
                             XFACTNUC_DEP, XFACTNUC_CON,                                 &
-                            OWARM=>LWARM, LACTI, ORAIN=>LRAIN, OSEDC=>LSEDC,            &
+                            LACTI, OSEDC=>LSEDC,                                        &
                             OACTIT=>LACTIT, LBOUND, LSPRO, LADJ, LKHKO, NMOM_C, NMOM_R, &
                             NMOD_CCN, XCCN_CONC, LKESSLERAC,                            &
                             LCCN_HOM, CCCN_MODES,                                       &
@@ -1009,9 +1009,7 @@ IF (KMI == 1) THEN
    YNUR    = 2.0
    YALPHAR = 1.0
 !
-   OWARM  = .TRUE.
    LACTI  = .TRUE.
-   ORAIN  = .TRUE.
    OSEDC  = .TRUE.
    OACTIT = .FALSE.
    LADJ   = .TRUE.
@@ -1049,11 +1047,8 @@ IF (KMI == 1) THEN
    XCCN_CONC(:)=300.
 !
    LHHONI = .FALSE.
-   LCOLD  = .TRUE.
    LNUCL  = .TRUE.
    LSEDI  = .TRUE.
-   LSNOW  = .TRUE.
-   LHAIL  = .FALSE.
    YSNOW_T = .FALSE.
    LMURAKAMI = .TRUE.
    CPRISTINE_ICE_LIMA = 'PLAT'
diff --git a/src/mesonh/ext/resolved_cloud.f90 b/src/mesonh/ext/resolved_cloud.f90
index 2ab08f041..0f6967c35 100644
--- a/src/mesonh/ext/resolved_cloud.f90
+++ b/src/mesonh/ext/resolved_cloud.f90
@@ -303,7 +303,7 @@ USE MODD_PARAM_C2R2,     ONLY: LSUPSAT
 USE MODD_PARAMETERS,     ONLY: JPHEXT, JPVEXT
 USE MODD_PARAM_ICE,      ONLY: CSEDIM, LADJ_BEFORE, LADJ_AFTER, CFRAC_ICE_ADJUST, LRED, &
                                PARAM_ICE
-USE MODD_PARAM_LIMA,     ONLY: LADJ, LCOLD, LPTSPLIT, LSPRO, NMOD_CCN, NMOD_IFN, NMOD_IMM
+USE MODD_PARAM_LIMA,     ONLY: LADJ, LPTSPLIT, LSPRO, NMOD_CCN, NMOD_IFN, NMOD_IMM, NMOM_I
 USE MODD_RAIN_ICE_DESCR, ONLY: XRTMIN, RAIN_ICE_DESCR
 USE MODD_RAIN_ICE_PARAM, ONLY: RAIN_ICE_PARAM
 USE MODD_SALT,           ONLY: LSALT
@@ -1010,14 +1010,14 @@ SELECT CASE ( HCLOUD )
                                   PTHS, PRS, PSVS(:,:,:,NSV_LIMA_BEG:NSV_LIMA_END), &
                                   PINPRC, PINPRR, PINDEP, PINPRR3D, PEVAP3D         )
 !
-        IF (LCOLD) CALL LIMA_COLD(OSEDI, OHHONI, KSPLITG, PTSTEP, KMI,               &
+        IF (NMOM_I.GE.1) CALL LIMA_COLD(OSEDI, OHHONI, KSPLITG, PTSTEP, KMI,               &
                                   KRR, PZZ, PRHODJ,                                  &
                                   PRHODREF, PEXNREF, PPABST, PW_ACT,                 &
                                   PTHT, PRT, PSVT(:,:,:,NSV_LIMA_BEG:NSV_LIMA_END),  &
                                   PTHS, PRS, PSVS(:,:,:,NSV_LIMA_BEG:NSV_LIMA_END),  &
                                   PINPRS, PINPRG, PINPRH                             )
 !
-        IF (OWARM .AND. LCOLD) CALL LIMA_MIXED(OSEDI, OHHONI, KSPLITG, PTSTEP, KMI,              &
+        IF (OWARM .AND. NMOM_I.GE.1) CALL LIMA_MIXED(OSEDI, OHHONI, KSPLITG, PTSTEP, KMI,              &
                                                KRR, PZZ, PRHODJ,                                 &
                                                PRHODREF, PEXNREF, PPABST, PW_ACT,                &
                                                PTHT, PRT, PSVT(:,:,:,NSV_LIMA_BEG:NSV_LIMA_END), &
diff --git a/src/mesonh/micro/lima_cold.f90 b/src/mesonh/micro/lima_cold.f90
index 1fda9a1db..c2277d90b 100644
--- a/src/mesonh/micro/lima_cold.f90
+++ b/src/mesonh/micro/lima_cold.f90
@@ -323,9 +323,9 @@ END IF
 !
 if ( lbu_enable ) then
   if ( lbudget_ri .and. osedi ) call Budget_store_init( tbudgets(NBUDGET_RI), 'SEDI', pris(:, :, :) * prhodj(:, :, :) )
-  if ( lbudget_rs .and. lsnow ) call Budget_store_init( tbudgets(NBUDGET_RS), 'SEDI', prss(:, :, :) * prhodj(:, :, :) )
-  if ( lbudget_rg .and. lsnow ) call Budget_store_init( tbudgets(NBUDGET_RG), 'SEDI', prgs(:, :, :) * prhodj(:, :, :) )
-  if ( lbudget_rh .and. lhail ) call Budget_store_init( tbudgets(NBUDGET_RH), 'SEDI', prhs(:, :, :) * prhodj(:, :, :) )
+  if ( lbudget_rs ) call Budget_store_init( tbudgets(NBUDGET_RS), 'SEDI', prss(:, :, :) * prhodj(:, :, :) )
+  if ( lbudget_rg ) call Budget_store_init( tbudgets(NBUDGET_RG), 'SEDI', prgs(:, :, :) * prhodj(:, :, :) )
+  if ( lbudget_rh ) call Budget_store_init( tbudgets(NBUDGET_RH), 'SEDI', prhs(:, :, :) * prhodj(:, :, :) )
   if ( lbudget_sv .and. osedi ) &
       call Budget_store_init( tbudgets(NBUDGET_SV1 - 1 + nsv_lima_ni), 'SEDI', pcis(:, :, :) * prhodj(:, :, :) )
   if (NMOM_S.GE.2) call Budget_store_init( tbudgets(NBUDGET_SV1 - 1 + nsv_lima_ns), 'SEDI', pcss(:, :, :) * prhodj(:, :, :) )
@@ -341,9 +341,9 @@ CALL LIMA_COLD_SEDIMENTATION (OSEDI, KSPLITG, PTSTEP, KMI,     &
                               PCSS=PCSS, PCGS=PCGS, PCHS=PCHS    )
 if ( lbu_enable ) then
   if ( lbudget_ri .and. osedi ) call Budget_store_end( tbudgets(NBUDGET_RI), 'SEDI', pris(:, :, :) * prhodj(:, :, :) )
-  if ( lbudget_rs .and. lsnow ) call Budget_store_end( tbudgets(NBUDGET_RS), 'SEDI', prss(:, :, :) * prhodj(:, :, :) )
-  if ( lbudget_rg .and. lsnow ) call Budget_store_end( tbudgets(NBUDGET_RG), 'SEDI', prgs(:, :, :) * prhodj(:, :, :) )
-  if ( lbudget_rh .and. lhail ) call Budget_store_end( tbudgets(NBUDGET_RH), 'SEDI', prhs(:, :, :) * prhodj(:, :, :) )
+  if ( lbudget_rs ) call Budget_store_end( tbudgets(NBUDGET_RS), 'SEDI', prss(:, :, :) * prhodj(:, :, :) )
+  if ( lbudget_rg ) call Budget_store_end( tbudgets(NBUDGET_RG), 'SEDI', prgs(:, :, :) * prhodj(:, :, :) )
+  if ( lbudget_rh ) call Budget_store_end( tbudgets(NBUDGET_RH), 'SEDI', prhs(:, :, :) * prhodj(:, :, :) )
   if ( lbudget_sv .and. osedi ) &
       call Budget_store_end( tbudgets(NBUDGET_SV1 - 1 + nsv_lima_ni), 'SEDI', pcis(:, :, :) * prhodj(:, :, :) )
   if (NMOM_S.GE.2) call Budget_store_end( tbudgets(NBUDGET_SV1 - 1 + nsv_lima_ns), 'SEDI', pcss(:, :, :) * prhodj(:, :, :) )
diff --git a/src/mesonh/micro/lima_notadjust.f90 b/src/mesonh/micro/lima_notadjust.f90
index ddd221297..59c000c9a 100644
--- a/src/mesonh/micro/lima_notadjust.f90
+++ b/src/mesonh/micro/lima_notadjust.f90
@@ -192,7 +192,7 @@ if ( nbumod == kmi .and. lbu_enable ) then
   if ( lbudget_rc ) call Budget_store_init( tbudgets(NBUDGET_RC), 'CEDS', prs(:, :, :, 2) * prhodj(:, :, :) )
   if ( lbudget_ri ) call Budget_store_init( tbudgets(NBUDGET_RI), 'CEDS', prs(:, :, :, 4) * prhodj(:, :, :) )
   if ( lbudget_sv ) then
-    if ( lwarm .and. nmom_c.ge.2) then
+    if ( nmom_c.ge.2) then
       call Budget_store_init( tbudgets(NBUDGET_SV1 - 1 + nsv_lima_nc), 'CEDS', psvs(:, :, :, nsv_lima_nc) * prhodj(:, :, :) )
       do jl = nsv_lima_ccn_free, nsv_lima_ccn_free + nmod_ccn - 1
         idx = NBUDGET_SV1 - 1 + jl
@@ -206,7 +206,7 @@ if ( nbumod == kmi .and. lbu_enable ) then
 !     if ( lscav .and. laero_mass ) &
 !       call Budget_store_init( tbudgets(NBUDGET_SV1 - 1 + nsv_lima_scavmass), 'CEDS', psvs(:, :, :, nsv_lima_scavmass) &
 !                                                                                     * prhodj(:, :, :) )
-!     if ( lcold ) then
+!     if ( nmom_i.ge.2 ) then
 !       call Budget_store_init( tbudgets(NBUDGET_SV1 - 1 + nsv_lima_ni), 'CEDS', psvs(:, :, :, nsv_lima_ni) * prhodj(:, :, :) )
 !       do jl = 1, nsv_lima_ifn_free, nsv_lima_ifn_free + nmod_ifn - 1
 !         idx = NBUDGET_SV1 - 1 + jl
@@ -611,7 +611,7 @@ if ( nbumod == kmi .and. lbu_enable ) then
   if ( lbudget_rc ) call Budget_store_end( tbudgets(NBUDGET_RC), 'CEDS', prs(:, :, :, 2) * prhodj(:, :, :) )
   if ( lbudget_ri ) call Budget_store_end( tbudgets(NBUDGET_RI), 'CEDS', prs(:, :, :, 4) * prhodj(:, :, :) )
   if ( lbudget_sv ) then
-    if ( lwarm .and. nmom_c.ge.2) then
+    if (nmom_c.ge.2) then
       call Budget_store_end( tbudgets(NBUDGET_SV1 - 1 + nsv_lima_nc), 'CEDS', psvs(:, :, :, nsv_lima_nc) * prhodj(:, :, :) )
       do jl = nsv_lima_ccn_free, nsv_lima_ccn_free + nmod_ccn - 1
         idx = NBUDGET_SV1 - 1 + jl
@@ -625,7 +625,7 @@ if ( nbumod == kmi .and. lbu_enable ) then
 !     if ( lscav .and. laero_mass ) &
 !       call Budget_store_end( tbudgets(NBUDGET_SV1 - 1 + nsv_lima_scavmass), 'CEDS', psvs(:, :, :, nsv_lima_scavmass) &
 !                                                                                     * prhodj(:, :, :) )
-!     if ( lcold ) then
+!     if ( nmom_i.ge.2 ) then
 !       call Budget_store_end( tbudgets(NBUDGET_SV1 - 1 + nsv_lima_ni), 'CEDS', psvs(:, :, :, nsv_lima_ni) * prhodj(:, :, :) )
 !       do jl = 1, nsv_lima_ifn_free, nsv_lima_ifn_free + nmod_ifn - 1
 !         idx = NBUDGET_SV1 - 1 + jl
diff --git a/src/mesonh/micro/set_conc_lima.f90 b/src/mesonh/micro/set_conc_lima.f90
index fb2c50a54..a92baca70 100644
--- a/src/mesonh/micro/set_conc_lima.f90
+++ b/src/mesonh/micro/set_conc_lima.f90
@@ -163,7 +163,7 @@ IF (NRR.GE.3 .AND. NMOM_R.GE.2) THEN
    END IF
 END IF
 !
-IF NRR.GE.4 .AND. NMOM_I.GE.2) THEN
+IF (NRR.GE.4 .AND. NMOM_I.GE.2) THEN
 !
 ! ice crystals
 !
diff --git a/tools/check_commit_mesonh.sh b/tools/check_commit_mesonh.sh
index ddfab901b..c8b7fc53d 100755
--- a/tools/check_commit_mesonh.sh
+++ b/tools/check_commit_mesonh.sh
@@ -84,7 +84,7 @@ done
 
 MNHPACK=${MNHPACK:=$HOME/MesoNH/PHYEX}
 REFDIR=${REFDIR:=$PHYEXTOOLSDIR/pack/}
-TARGZDIR=${TARGZDIR:=/home/rodierq/UBUNTU22/}
+TARGZDIR=${TARGZDIR:=/home/rodierq/UBUNTU22/PHYEX}
 if [ -z "${tests-}" ]; then
   tests=$defaultTest
 elif [ $tests == 'ALL' ]; then
-- 
GitLab