From ca0712732dc623b16d1f89ad6a3962b117039c6b Mon Sep 17 00:00:00 2001
From: Philippe WAUTELET <philippe.wautelet@aero.obs-mip.fr>
Date: Fri, 19 Aug 2022 09:53:28 +0200
Subject: [PATCH] Philippe 19/08/2022: bugfix: IO_File_check_format_exist:
 broadcast cformat if changed

---
 src/LIB/SURCOUCHE/src/mode_io_file.f90 | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/LIB/SURCOUCHE/src/mode_io_file.f90 b/src/LIB/SURCOUCHE/src/mode_io_file.f90
index e269accf0..6ed3a03c2 100644
--- a/src/LIB/SURCOUCHE/src/mode_io_file.f90
+++ b/src/LIB/SURCOUCHE/src/mode_io_file.f90
@@ -1,4 +1,4 @@
-!MNH_LIC Copyright 1994-2021 CNRS, Meteo-France and Universite Paul Sabatier
+!MNH_LIC Copyright 1994-2022 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,6 +38,7 @@
 !  P. Wautelet 12/03/2019: simplify opening of IO split files
 !  P. Wautelet 05/09/2019: disable IO_Coordvar_write_nc4 for Z-split files
 !  P. Wautelet 01/10/2020: bugfix: add missing initializations for IRESP
+!  P. Wautelet 19/08/2022: bugfix: IO_File_check_format_exist: broadcast cformat if changed
 !-----------------------------------------------------------------
 module mode_io_file
 
@@ -666,9 +667,11 @@ end subroutine IO_Transfer_list_addto
 
 
 subroutine IO_File_check_format_exist( tpfile )
+use modd_mpif
 
 type(tfiledata), intent(inout) :: tpfile ! File structure
 
+integer :: ierr
 logical :: gexist_lfi, gexist_nc4
 
 
@@ -720,6 +723,9 @@ IF (TPFILE%LMASTER) THEN
   end if MODE
 END IF
 
+if ( tpfile%cmode == 'READ' ) &
+  call MPI_BCAST( tpfile%cformat, Len( tpfile%cformat ), MPI_CHARACTER, tpfile%nmaster_rank - 1, tpfile%nmpicomm, ierr )
+
 end subroutine IO_File_check_format_exist
 
 
-- 
GitLab