From 1fb7dd03100fe04e5f23ba789488c1a50b67d652 Mon Sep 17 00:00:00 2001
From: Philippe WAUTELET <philippe.wautelet@cnrs.fr>
Date: Mon, 7 Oct 2024 13:32:41 +0200
Subject: [PATCH] Philippe 07/10/2024: LFI2CDF / IO: small fixes to allow
 LFI2CDF runs

---
 src/LIB/SURCOUCHE/src/mode_io_file.f90     | 2 +-
 src/LIB/SURCOUCHE/src/mode_io_file_nc4.f90 | 4 ++++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/LIB/SURCOUCHE/src/mode_io_file.f90 b/src/LIB/SURCOUCHE/src/mode_io_file.f90
index 2ae121fe4..74e1e4e81 100644
--- a/src/LIB/SURCOUCHE/src/mode_io_file.f90
+++ b/src/LIB/SURCOUCHE/src/mode_io_file.f90
@@ -565,7 +565,7 @@ SELECT CASE(TPFILE%CTYPE)
   CASE ('MNH', 'MNHBACKUP', 'MNHDIACHRONIC', 'MNHDIAG', 'MNHOUTPUT', 'PGD')
     !Try to close '.des' file only if it should exist
     IF ( ( TPFILE%CTYPE=='MNH' .OR. TPFILE%CTYPE=='MNHBACKUP' .OR. TPFILE%CTYPE=='MNHDIACHRONIC' ) &
-         .and. .not.associated(tpfile%tmainfile)                                                   ) THEN
+         .and. .not.associated(tpfile%tmainfile) .and. cprogram /= 'LFICDF'                        ) THEN
       IF ( .NOT.ASSOCIATED(TPFILE%TDESFILE) ) THEN
         CALL PRINT_MSG( NVERB_ERROR, 'IO', 'IO_File_close','DES file for '//TRIM(TPFILE%CNAME)//' not associated' )
       ELSE
diff --git a/src/LIB/SURCOUCHE/src/mode_io_file_nc4.f90 b/src/LIB/SURCOUCHE/src/mode_io_file_nc4.f90
index ba3cffa8d..9129167d3 100644
--- a/src/LIB/SURCOUCHE/src/mode_io_file_nc4.f90
+++ b/src/LIB/SURCOUCHE/src/mode_io_file_nc4.f90
@@ -465,6 +465,10 @@ subroutine IO_Subfile_check_nc4( tpfile )
       else if (tpfile%nsubfiles_ioz == 0 .and. iatt == 0 ) then
         ! Nothing to do: no subfiles
         !call Print_msg( NVERB_DEBUG, 'IO', 'IO_Subfile_check_nc4', trim(tpfile%cname)//': no subfiles detected', olocal = .true. )
+      else if (tpfile%nsubfiles_ioz == iatt ) then
+        ! Nothing to do: number of subfiles is as expected
+        !call Print_msg( NVERB_DEBUG, 'IO', 'IO_Subfile_check_nc4', trim(tpfile%cname)//&
+        !                ': number of subfiles is as expected', olocal = .true. )
       else
         ! Unknown error
         call Print_msg( NVERB_ERROR, 'IO', 'IO_Subfile_check_nc4', trim(tpfile%cname)//': unexpected situation', olocal = .true. )
-- 
GitLab