From d426b6f353d8bc4a219c0472799733464b0a36db Mon Sep 17 00:00:00 2001 From: Philippe WAUTELET <philippe.wautelet@cnrs.fr> Date: Tue, 3 Sep 2024 14:36:14 +0200 Subject: [PATCH] Philippe 03/09/2024: CBULIST_*: deallocate them when not enabled --- src/MNH/ini_budget.f90 | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/src/MNH/ini_budget.f90 b/src/MNH/ini_budget.f90 index d7cd249e0..a08b79dae 100644 --- a/src/MNH/ini_budget.f90 +++ b/src/MNH/ini_budget.f90 @@ -1,4 +1,4 @@ -!MNH_LIC Copyright 1995-2023 CNRS, Meteo-France and Universite Paul Sabatier +!MNH_LIC Copyright 1995-2024 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. @@ -4521,19 +4521,19 @@ end do SV_BUDGETS call Ini_budget_groups( tbudgets, ibudim1, ibudim2, ibudim3 ) -if ( tbudgets(NBUDGET_U) %lenabled ) call Sourcelist_nml_compact( tbudgets(NBUDGET_U), cbulist_ru ) -if ( tbudgets(NBUDGET_V) %lenabled ) call Sourcelist_nml_compact( tbudgets(NBUDGET_V), cbulist_rv ) -if ( tbudgets(NBUDGET_W) %lenabled ) call Sourcelist_nml_compact( tbudgets(NBUDGET_W), cbulist_rw ) -if ( tbudgets(NBUDGET_TH) %lenabled ) call Sourcelist_nml_compact( tbudgets(NBUDGET_TH), cbulist_rth ) -if ( tbudgets(NBUDGET_TKE)%lenabled ) call Sourcelist_nml_compact( tbudgets(NBUDGET_TKE), cbulist_rtke ) -if ( tbudgets(NBUDGET_RV) %lenabled ) call Sourcelist_nml_compact( tbudgets(NBUDGET_RV), cbulist_rrv ) -if ( tbudgets(NBUDGET_RC) %lenabled ) call Sourcelist_nml_compact( tbudgets(NBUDGET_RC), cbulist_rrc ) -if ( tbudgets(NBUDGET_RR) %lenabled ) call Sourcelist_nml_compact( tbudgets(NBUDGET_RR), cbulist_rrr ) -if ( tbudgets(NBUDGET_RI) %lenabled ) call Sourcelist_nml_compact( tbudgets(NBUDGET_RI), cbulist_rri ) -if ( tbudgets(NBUDGET_RS) %lenabled ) call Sourcelist_nml_compact( tbudgets(NBUDGET_RS), cbulist_rrs ) -if ( tbudgets(NBUDGET_RG) %lenabled ) call Sourcelist_nml_compact( tbudgets(NBUDGET_RG), cbulist_rrg ) -if ( tbudgets(NBUDGET_RH) %lenabled ) call Sourcelist_nml_compact( tbudgets(NBUDGET_RH), cbulist_rrh ) -if ( lbu_rsv ) call Sourcelist_sv_nml_compact( cbulist_rsv ) +call Sourcelist_nml_compact( tbudgets(NBUDGET_U), cbulist_ru ) +call Sourcelist_nml_compact( tbudgets(NBUDGET_V), cbulist_rv ) +call Sourcelist_nml_compact( tbudgets(NBUDGET_W), cbulist_rw ) +call Sourcelist_nml_compact( tbudgets(NBUDGET_TH), cbulist_rth ) +call Sourcelist_nml_compact( tbudgets(NBUDGET_TKE), cbulist_rtke ) +call Sourcelist_nml_compact( tbudgets(NBUDGET_RV), cbulist_rrv ) +call Sourcelist_nml_compact( tbudgets(NBUDGET_RC), cbulist_rrc ) +call Sourcelist_nml_compact( tbudgets(NBUDGET_RR), cbulist_rrr ) +call Sourcelist_nml_compact( tbudgets(NBUDGET_RI), cbulist_rri ) +call Sourcelist_nml_compact( tbudgets(NBUDGET_RS), cbulist_rrs ) +call Sourcelist_nml_compact( tbudgets(NBUDGET_RG), cbulist_rrg ) +call Sourcelist_nml_compact( tbudgets(NBUDGET_RH), cbulist_rrh ) +call Sourcelist_sv_nml_compact( lbu_rsv, cbulist_rsv ) end subroutine Ini_budget @@ -5031,6 +5031,8 @@ subroutine Sourcelist_nml_compact( tpbudget, hbulist ) if ( Allocated( hbulist ) ) Deallocate( hbulist ) + if ( .not. tpbudget%lenabled ) return + if ( tpbudget%ngroups < 3 ) then call Print_msg( NVERB_ERROR, 'BUD', 'Sourcelist_nml_compact', 'ngroups is too small' ) return @@ -5066,18 +5068,24 @@ subroutine Sourcelist_nml_compact( tpbudget, hbulist ) end subroutine Sourcelist_nml_compact -subroutine Sourcelist_sv_nml_compact( hbulist ) +subroutine Sourcelist_sv_nml_compact( oenabled, hbulist ) !This subroutine reduce the size of the hbulist !For SV variables the reduction is simpler than for other variables !because it is too complex to do this cleanly (the enabled source terms are different for each scalar variable) use modd_budget, only: NBULISTMAXLEN, tbudgetdata + logical, intent(in) :: oenabled character(len=*), dimension(:), allocatable, intent(inout) :: hbulist character(len=NBULISTMAXLEN), dimension(:), allocatable :: ybulist_new integer :: ilines integer :: ji + if ( .not. oenabled ) then + if ( allocated( hbulist ) ) deallocate( hbulist ) + return + end if + ilines = 0 do ji = 1, Size( hbulist ) if ( Len_trim(hbulist(ji)) > 0 ) ilines = ilines + 1 -- GitLab