From 571730573ec4e9d0f871c9615c49212bfd3c87d8 Mon Sep 17 00:00:00 2001
From: Philippe WAUTELET <philippe.wautelet@aero.obs-mip.fr>
Date: Mon, 25 Jan 2021 10:27:59 +0100
Subject: [PATCH] P. Wautelet 25/01/2021: bugfix: do not call Write_budget at
 the beginning of the simulation

(cherry picked from commit 58270fcfaef72e2b55b26c5a40d58787ff6feab4)
---
 src/MNH/endstep_budget.f90 | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/src/MNH/endstep_budget.f90 b/src/MNH/endstep_budget.f90
index eff9d4bfe..9d705fc99 100644
--- a/src/MNH/endstep_budget.f90
+++ b/src/MNH/endstep_budget.f90
@@ -1,6 +1,6 @@
-!MNH_LIC Copyright 1994-2018 CNRS, Meteo-France and Universite Paul Sabatier
+!MNH_LIC Copyright 1995-2021 CNRS, Meteo-France and Universite Paul Sabatier
 !MNH_LIC This is part of the Meso-NH software governed by the CeCILL-C licence
-!MNH_LIC version 1. See LICENSE, CeCILL-C_V1-en.txt and CeCILL-C_V1-fr.txt  
+!MNH_LIC version 1. See LICENSE, CeCILL-C_V1-en.txt and CeCILL-C_V1-fr.txt
 !MNH_LIC for details. version 1.
 !-----------------------------------------------------------------
 !##########################
@@ -94,8 +94,8 @@ END MODULE MODI_ENDSTEP_BUDGET
 !!      N. Asensio  22/06/99  // MASK case : delete KIU,KJU,KKU arguments
 !!                            and change the write_budget call
 !!      C.Lac       11/09/15 adaptation to FIT temporal scheme
-!  Philippe Wautelet: 05/2016-04/2018: new data structures and calls for I/O
-!!
+!  P. Wautelet: 05/2016-04/2018: new data structures and calls for I/O
+!  P. Wautelet 25/01/2021: bugfix: do not call Write_budget at the beginning of the simulation
 !-------------------------------------------------------------------------------
 !
 !*       0.    DECLARATIONS
@@ -121,15 +121,18 @@ INTEGER,           INTENT(IN) :: KSV        ! Number of Scalar Variables
 !
 !-------------------------------------------------------------------------------
 !
+!Do not call Write_budget at the beginning of the simulation (this is necessary in the case were xbulen = xtstep)
+IF ( KTCOUNT == 1 ) RETURN
+
 SELECT CASE(CBUTYPE)
 !
 !
 !*	 1.     'CART' CASE
 !               -----------
 !
-  CASE('CART','SKIP') 
+  CASE('CART','SKIP')
 !
-!*	 1.1    storage of the budget fields 
+!*	 1.1    storage of the budget fields
 !
     IF( MODULO(KTCOUNT,NBUSTEP*NBUWRNB) == 0 ) THEN  
       CALL WRITE_BUDGET(TPDIAFILE,TPDTCUR,TPDTMOD,PTSTEP, KSV )
-- 
GitLab