From f44815573485396bc6360ed6bac6d77e35a7dc97 Mon Sep 17 00:00:00 2001
From: Philippe WAUTELET <philippe.wautelet@aero.obs-mip.fr>
Date: Thu, 14 Jan 2021 15:26:59 +0100
Subject: [PATCH] Philippe 14/01/2021: change xbusurf type to integer (+ rename
 it to nbusurf)

---
 src/MNH/ini_budget.f90   |  6 +++---
 src/MNH/modd_budget.f90  |  5 +++--
 src/MNH/set_mask.f90     | 15 +++++----------
 src/MNH/set_msk.f90      | 10 +++-------
 src/MNH/write_budget.f90 |  8 ++++----
 5 files changed, 18 insertions(+), 26 deletions(-)

diff --git a/src/MNH/ini_budget.f90 b/src/MNH/ini_budget.f90
index e2b443fef..c55b18f58 100644
--- a/src/MNH/ini_budget.f90
+++ b/src/MNH/ini_budget.f90
@@ -161,7 +161,7 @@ end subroutine Budget_preallocate
 !!      N. Asencio      18/06/99  // MASK case : delete KIMAX and KJMAX arguments,
 !!                                GET_DIM_EXT_ll initializes the dimensions of the
 !!                                extended local domain.
-!!                                LBU_MASK and XBUSURF are allocated on the extended
+!!                                LBU_MASK and NBUSURF are allocated on the extended
 !!                                local domain.
 !!                                add 3 local variables IBUDIM1,IBUDIM2,IBUDIM3
 !!                                to define the dimensions of the budget arrays
@@ -408,8 +408,8 @@ ELSEIF (CBUTYPE=='MASK') THEN          ! mask case only
   CALL GET_DIM_EXT_ll ('B', IIU,IJU)
   ALLOCATE( LBU_MASK( IIU ,IJU, NBUMASK) )
   LBU_MASK(:,:,:)=.FALSE.
-  ALLOCATE( XBUSURF( IIU, IJU, NBUMASK, nbusubwrite) )
-  XBUSURF(:,:,:,:) = 0.
+  ALLOCATE( NBUSURF( IIU, IJU, NBUMASK, nbusubwrite) )
+  NBUSURF(:,:,:,:) = 0
 !
 ! three first dimensions of budget arrays in mask case
 !  the order of the dimensions are the order expected in WRITE_DIACHRO routine:
diff --git a/src/MNH/modd_budget.f90 b/src/MNH/modd_budget.f90
index df5876d80..a0674b171 100644
--- a/src/MNH/modd_budget.f90
+++ b/src/MNH/modd_budget.f90
@@ -58,6 +58,7 @@
 !  P. Wautelet 08/10/2020: add clessource in tbudgetdata datatype
 !  P. Wautelet 08/12/2020: add nbusubwrite and nbutotwrite
 !  P. Wautelet 11/01/2021: remove nbuwrnb (replaced by nbusubwrite)
+!  P. Wautelet 14/01/2021: change xbusurf type to integer (+ rename it to nbusurf)
 !-------------------------------------------------------------------------------
 !
 !*       0.   DECLARATIONS
@@ -178,8 +179,8 @@ INTEGER, SAVE :: NBUMASK                   ! number of MASK zones for which
 LOGICAL, SAVE, DIMENSION(:,:,:),         & ! define the zone where the MASK 
            ALLOCATABLE :: LBU_MASK         ! is True 
 !                                          
-REAL, SAVE, DIMENSION(:,:,:,:),          & ! surface for each mask at each   
-           ALLOCATABLE :: XBUSURF          ! budget step   
+INTEGER, SAVE, DIMENSION(:,:,:,:),       & ! surface for each mask at each
+           ALLOCATABLE :: NBUSURF          ! budget step
 !             
 INTEGER, SAVE :: NBUTIME                   ! number of budget time periods
 !
diff --git a/src/MNH/set_mask.f90 b/src/MNH/set_mask.f90
index 81f58e13a..36300b07e 100644
--- a/src/MNH/set_mask.f90
+++ b/src/MNH/set_mask.f90
@@ -1,13 +1,8 @@
-!MNH_LIC Copyright 1994-2014 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.
 !-----------------------------------------------------------------
-!--------------- special set of characters for RCS information
-!-----------------------------------------------------------------
-! $Source: /home/cvsroot/MNH-VX-Y-Z/src/MNH/set_mask.f90,v $ $Revision: 1.2.2.1.2.1.18.2 $
-! MASDEV4_7 budget 2006/09/08 10:35:15
-!-----------------------------------------------------------------
 !     ###################
       SUBROUTINE SET_MASK
 !     ###################
@@ -26,7 +21,7 @@
 !!      According to each criterion associated to one zone, the mask is
 !!    set to TRUE at each point where the criterion is confirmed, at each 
 !!    time step of the model. Finally, The number of occurence of this criteria is 
-!!    increased by 1 and stored in the array XBUSURF. 
+!!    increased by 1 and stored in the array NBUSURF.
 !!    Caution : The mask is defined on the inner domain.
 !!      
 !!
@@ -39,7 +34,7 @@
 !!       Module MODD_BUDGET
 !!         LBU_MASK   : logical array mask defining the zones
 !!         NBUTIME    : number of the budget step
-!!         XBUSURF    : mask tracer array (surface array) 
+!!         NBUSURF    : mask tracer array (surface array)
 !!
 !!    REFERENCE
 !!    ---------
@@ -106,7 +101,7 @@ IF (NBUMASK>=2) &
 !               -------------------------
 !
 WHERE (LBU_MASK(:,:,:))
-  XBUSURF(:,:,:,NBUTIME)=XBUSURF(:,:,:,NBUTIME)+1.
+  NBUSURF(:,:,:,NBUTIME) = NBUSURF(:,:,:,NBUTIME) + 1
 END WHERE
 !
 !-------------------------------------------------------------------------------
diff --git a/src/MNH/set_msk.f90 b/src/MNH/set_msk.f90
index 6f381239c..0e6a7d353 100644
--- a/src/MNH/set_msk.f90
+++ b/src/MNH/set_msk.f90
@@ -1,4 +1,4 @@
-!MNH_LIC Copyright 1995-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 for details. version 1.
@@ -38,9 +38,8 @@ END MODULE MODI_SET_MSK
 !!    ------
 !!      According to each criterion associated to one zone, the mask is
 !!    set to TRUE at each point where the criterion is confirmed, at each 
-!!    time step of the model. Finally, The number of occurence of this criteria is 
-!!    increased by 1 and stored in the array XBUSURF. 
-!!      
+!!    time step of the model.
+!!
 !!
 !!    EXTERNAL
 !!    --------
@@ -48,8 +47,6 @@ END MODULE MODI_SET_MSK
 !!
 !!    IMPLICIT ARGUMENTS
 !!    ------------------
-!!       Module MODD_BUDGET
-!!         XBUSURF    : mask tracer array (surface array) 
 !!
 !!    REFERENCE
 !!    ---------
@@ -74,7 +71,6 @@ END MODULE MODI_SET_MSK
 !*       0.    DECLARATIONS
 !              ------------
 !
-USE MODD_BUDGET
 USE MODD_FIELD_n
 USE MODD_RAIN_ICE_PARAM , ONLY : XFSEDR,XEXSEDR
 USE MODD_RAIN_ICE_DESCR , ONLY : XCEXVT
diff --git a/src/MNH/write_budget.f90 b/src/MNH/write_budget.f90
index 7cbca7eee..f160bdf9b 100644
--- a/src/MNH/write_budget.f90
+++ b/src/MNH/write_budget.f90
@@ -94,7 +94,7 @@ subroutine Write_budget( tpdiafile, tpdtcur, ptstep, ksv )
 !!
 !-------------------------------------------------------------------------------
 
-  use modd_budget,         only: cbutype, nbumask, nbutshift, nbustep, nbusubwrite, xbulen, xbusurf,                              &
+  use modd_budget,         only: cbutype, nbumask, nbusurf, nbutshift, nbustep, nbusubwrite, xbulen,                              &
                                  lbu_icp, lbu_jcp,                                                                                &
                                  lbu_ru, lbu_rv, lbu_rw, lbu_rth, lbu_rtke, lbu_rrv, lbu_rrc, lbu_rrr,                            &
                                  lbu_rri, lbu_rrs, lbu_rrg, lbu_rrh, lbu_rsv,                                                     &
@@ -230,11 +230,11 @@ subroutine Write_budget( tpdiafile, tpdtcur, ptstep, ksv )
   !
 #ifdef MNH_IOLFI
       if ( Trim( tpdiafile%cformat ) == 'LFI' .or. Trim( tpdiafile%cformat ) == 'LFICDF4' ) then
-        Allocate( zworkmask(Size( xbusurf, 1 ), Size( xbusurf, 2 ), 1, nbusubwrite, nbumask,1) )
+        Allocate( zworkmask(Size( nbusurf, 1 ), Size( nbusurf, 2 ), 1, nbusubwrite, nbumask,1) )
         ! local array
         do jmask = 1, nbumask
           do jt = 1, nbusubwrite
-            zworkmask(:, :, 1, jt, jmask, 1) = xbusurf(:, :, jmask, jt)
+            zworkmask(:, :, 1, jt, jmask, 1) = Real( nbusurf(:, :, jmask, jt), kind = Kind( zworkmask ) )
           end do
         end do
 
@@ -290,7 +290,7 @@ subroutine Write_budget( tpdiafile, tpdtcur, ptstep, ksv )
         if ( nbutshift == 1 ) call IO_Field_create( tzfile, tzfield )
 
         !Write the data (partial write of the field with the given offset)
-        call IO_Field_write( tzfile, tzfield, xbusurf(:,:,:,:), koffset= [ 0, 0, 0, ( nbutshift - 1 ) * nbusubwrite ] )
+        call IO_Field_write( tzfile, tzfield, nbusurf(:,:,:,:), koffset= [ 0, 0, 0, ( nbutshift - 1 ) * nbusubwrite ] )
 
         if ( nbutshift == 1 ) call Menu_diachro( tzfile, 'MASKS' )
       end if
-- 
GitLab