From d7eb19c43930613031b5c49c6e672ea4e0a49f8f Mon Sep 17 00:00:00 2001
From: Philippe WAUTELET <philippe.wautelet@aero.obs-mip.fr>
Date: Wed, 17 Mar 2021 15:32:42 +0100
Subject: [PATCH] Philippe 17/03/2021: budgets: improve error detection in
 Budget_source_id_find

---
 src/MNH/budget.f90 | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/src/MNH/budget.f90 b/src/MNH/budget.f90
index 36863e3ea..13c746c43 100644
--- a/src/MNH/budget.f90
+++ b/src/MNH/budget.f90
@@ -292,7 +292,22 @@ subroutine Budget_source_id_find( tpbudget, hsource, kid )
   if ( iid > 0 ) then
     call Print_msg( NVERB_DEBUG, 'BUD', 'Budget_source_id_find', trim( tpbudget%cname )//':'//trim( hsource )//' found' )
   else
-    call Print_msg( NVERB_ERROR, 'BUD', 'Budget_source_id_find', trim( tpbudget%cname )//':'//trim( hsource )//' not found' )
+    !Search also in the non-available source term list
+    do ji = tpbudget%nsources + 1, tpbudget%nsourcesmax
+      if ( trim( hsource ) == trim( tpbudget%tsources(ji)%cmnhname ) ) then
+        iid = ji
+        exit
+      end if
+    end do
+
+    if ( iid == 0 ) then
+      call Print_msg( NVERB_ERROR, 'BUD', 'Budget_source_id_find', trim( tpbudget%cname )//':'//trim( hsource )//' not found' )
+    else
+      cmnhmsg(1) = Trim( tpbudget%cname ) // ':' // Trim( hsource ) // ' found'
+      cmnhmsg(2) = 'in non-available source term list.'
+      cmnhmsg(3) = 'Check availability condition in Ini_budget.'
+      call Print_msg( NVERB_ERROR, 'BUD', 'Budget_source_id_find' )
+    end if
   end if
 
   kid = iid
-- 
GitLab