From 4604aaf566804f761d0d8cbcc5f8544d239a3c88 Mon Sep 17 00:00:00 2001
From: Philippe WAUTELET <philippe.wautelet@aero.obs-mip.fr>
Date: Wed, 17 Mar 2021 15:07:16 +0100
Subject: [PATCH] Philippe 17/03/2021: bugfix: move verification after
 initialization of some used variables

---
 src/MNH/write_diachro.f90 | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/MNH/write_diachro.f90 b/src/MNH/write_diachro.f90
index 5bde039e5..50d7f1e44 100644
--- a/src/MNH/write_diachro.f90
+++ b/src/MNH/write_diachro.f90
@@ -698,13 +698,6 @@ type(tfiledata)      :: tzfile
 
 ytype = Trim( tpbudiachro%ctype )
 
-if ( trim ( ytype ) == 'CART' .or. trim ( ytype ) == 'MASK' .or. trim ( ytype ) == 'SPXY') then
-    if ( iil < 0 .or. iih < 0 .or. ijl < 0 .or. ijh < 0 .or. ikl < 0 .or. ikh < 0 ) then
-      call Print_msg( NVERB_FATAL, 'IO', 'Write_diachro_nc4', &
-                      'nil, nih, njl, njh, nkl or nkh not set in tpbudiachro for variable ' // Trim( tpfields(1)%cmnhname ) )
-    end if
-end if
-
 tzfile = tpdiafile
 
 !Write only in netCDF files
@@ -719,6 +712,13 @@ ijh = tpbudiachro%njh
 ikl = tpbudiachro%nkl
 ikh = tpbudiachro%nkh
 
+if ( trim ( ytype ) == 'CART' .or. trim ( ytype ) == 'MASK' .or. trim ( ytype ) == 'SPXY') then
+    if ( iil < 0 .or. iih < 0 .or. ijl < 0 .or. ijh < 0 .or. ikl < 0 .or. ikh < 0 ) then
+      call Print_msg( NVERB_FATAL, 'IO', 'Write_diachro_nc4', &
+                      'nil, nih, njl, njh, nkl or nkh not set in tpbudiachro for variable ' // Trim( tpfields(1)%cmnhname ) )
+    end if
+end if
+
 if ( Trim( ytype ) == 'CART' .and. .not. tpbudiachro%licompress .and. .not. tpbudiachro%ljcompress ) then
   gdistributed = .true.
 else
-- 
GitLab