From 3d466a0deaa14663e4d48b3d821037f0589c9ded Mon Sep 17 00:00:00 2001
From: Quentin Rodier <quentin.rodier@meteo.fr>
Date: Thu, 19 Jan 2023 12:16:41 +0100
Subject: [PATCH] Quentin 19/01/2023: add budgets with LBLAZE on Rv and Th

---
 src/MNH/ground_paramn.f90 | 10 ++++++++++
 src/MNH/ini_budget.f90    | 10 ++++++++++
 2 files changed, 20 insertions(+)

diff --git a/src/MNH/ground_paramn.f90 b/src/MNH/ground_paramn.f90
index 5d872413b..1db438c04 100644
--- a/src/MNH/ground_paramn.f90
+++ b/src/MNH/ground_paramn.f90
@@ -135,6 +135,8 @@ USE MODD_DYN_n,     ONLY : DYN_MODEL
 #endif
 !
 USE MODD_LUNIT_n, ONLY: TLUOUT
+USE MODD_BUDGET,  ONLY: LBUDGET_TH, LBUDGET_RV, NBUDGET_RV, NBUDGET_TH,TBUDGETS
+USE MODE_BUDGET,  ONLY: BUDGET_STORE_INIT, BUDGET_STORE_END
 USE MODD_CST,        ONLY : XP00, XCPD, XRD, XRV,XRHOLW, XDAY, XPI, XLVTT, XMD, XAVOGADRO
 USE MODD_DIMPHYEX,   ONLY : DIMPHYEX_t
 USE MODD_PARAMETERS, ONLY : JPVEXT, XUNDEF
@@ -832,11 +834,15 @@ IF (LBLAZE) THEN
   !*       2.1.8  Compute fluxes
   !               --------------
   !
+  IF (LBUDGET_RV) CALL BUDGET_STORE_INIT(TBUDGETS(NBUDGET_RV), 'BLAZE', XRRS(:,:,:,1))
+  IF (LBUDGET_TH) CALL BUDGET_STORE_INIT(TBUDGETS(NBUDGET_TH), 'BLAZE', XRTHS(:,:,:))
+  !
   SELECT CASE (CFIRE_CPL_MODE)
   CASE('2WAYCPL','FIR2ATM')
     CALL SECOND_MNH2( ZFLUXTIME1 )
     ! 2 way coupling
     CALL FIRE_HEATFLUXES( XLSPHI, XBMAP, XFIRETAU, XTSTEP, XFLUXPARAMH, XFLUXPARAMW, XFMFLUXHDH, XFMFLUXHDW, XFMASE, XFMAWC )
+    !
     ! vertical distribution of fire heat fluxes
     CALL FIRE_VERTICALFLUXDISTRIB( XFMFLUXHDH, XFMFLUXHDW, XRTHS, XRRS, ZSFTS, XEXNREF, XRHODJ, XRT, XRHODREF )
     !
@@ -845,6 +851,10 @@ IF (LBLAZE) THEN
   CASE DEFAULT
     XFLUXPERF(:) = 0.
   END SELECT
+  !
+  IF (LBUDGET_RV) CALL BUDGET_STORE_END(TBUDGETS(NBUDGET_RV), 'BLAZE', XRRS(:,:,:,1))
+  IF (LBUDGET_TH) CALL BUDGET_STORE_END(TBUDGETS(NBUDGET_TH), 'BLAZE', XRTHS(:,:,:))
+  !
   ! get end time
   CALL SECOND_MNH2( ZFIRETIME2 )
   ! add to Blaze time
diff --git a/src/MNH/ini_budget.f90 b/src/MNH/ini_budget.f90
index e446214f0..cb8c3f2ac 100644
--- a/src/MNH/ini_budget.f90
+++ b/src/MNH/ini_budget.f90
@@ -228,6 +228,7 @@ use modd_dyn,           only: lcorio, xseglen
 use modd_dyn_n,         only: xtstep, locean
 use modd_elec_descr,    only: linductive, lrelax2fw_ion
 use modd_field,         only: TYPEREAL
+use modd_fire,          only: lblaze
 use modd_nsv,           only: csvnames,                                                                            &
                               nsv_aerbeg, nsv_aerend, nsv_aerdepbeg, nsv_aerdepend, nsv_c2r2beg, nsv_c2r2end,      &
                               nsv_chembeg, nsv_chemend, nsv_chicbeg, nsv_chicend, nsv_csbeg, nsv_csend,            &
@@ -1270,6 +1271,11 @@ if ( lbu_rth ) then
                         .and. celec == 'NONE'
   call Budget_source_add( tbudgets(NBUDGET_TH), tzsource )
 
+  tzsource%cmnhname   = 'BLAZE'
+  tzsource%clongname  = 'blaze fire model contribution'
+  tzsource%lavailable = lblaze
+  call Budget_source_add( tbudgets(NBUDGET_TH), tzsource )
+
 
   call Sourcelist_sort_compact( tbudgets(NBUDGET_TH) )
 
@@ -1593,6 +1599,10 @@ if ( tbudgets(NBUDGET_RV)%lenabled ) then
                         .and. celec == 'NONE'
   call Budget_source_add( tbudgets(NBUDGET_RV), tzsource )
 
+  tzsource%cmnhname   = 'BLAZE'
+  tzsource%clongname  = 'blaze fire model contribution'
+  tzsource%lavailable = lblaze
+  call Budget_source_add( tbudgets(NBUDGET_RV), tzsource )
 
   call Sourcelist_sort_compact( tbudgets(NBUDGET_RV) )
 
-- 
GitLab