From 6472a212608ea3fe740cf485f4c140ecd2a18d27 Mon Sep 17 00:00:00 2001 From: Philippe WAUTELET <philippe.wautelet@cnrs.fr> Date: Wed, 2 Oct 2024 13:35:52 +0200 Subject: [PATCH] Philippe 02/10/2024: Philippe 02/10/2024: add netCDF attributes for subfiles --- src/LIB/SURCOUCHE/src/mode_io_write_nc4.f90 | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/LIB/SURCOUCHE/src/mode_io_write_nc4.f90 b/src/LIB/SURCOUCHE/src/mode_io_write_nc4.f90 index cbde62c6a..238b60356 100644 --- a/src/LIB/SURCOUCHE/src/mode_io_write_nc4.f90 +++ b/src/LIB/SURCOUCHE/src/mode_io_write_nc4.f90 @@ -35,6 +35,7 @@ ! P. Wautelet 14/12/2023: add lossy compression for output files ! P. Wautelet 15/02/2024: IO_Coordvar_write_nc4: add time dimension for Lagrangian trajectories ! P. Wautelet 20/03/2024: add boxes for output files +! P. Wautelet 02/10/2024: add netCDF attributes for subfiles !----------------------------------------------------------------- #ifdef MNH_IOCDF4 module mode_io_write_nc4 @@ -2871,6 +2872,24 @@ IF (TPFILE%LMASTER) THEN END IF IF ( ISTATUS /= NF90_NOERR ) CALL IO_Err_handle_nc4( istatus, 'IO_FILE_WRITE_HEADER', 'NF90_PUT_ATT', 'MNH_COMPRESS_LOSSY' ) + ! Number of subfiles (0 if no subfiles or if is a subfile) + ISTATUS = NF90_PUT_ATT( TPFILE%NNCID, NF90_GLOBAL, 'MNH_NSUBFILES', TPFILE%NSUBFILES_IOZ ) + IF ( ISTATUS /= NF90_NOERR ) CALL IO_Err_handle_nc4( istatus, 'IO_FILE_WRITE_HEADER', 'NF90_PUT_ATT', 'MNH_NSUBFILES' ) + + ! Is this file a subfile + IF ( ASSOCIATED( TPFILE%TMAINFILE ) ) THEN + ISTATUS = NF90_PUT_ATT( TPFILE%NNCID, NF90_GLOBAL, 'MNH_IS_ROOTFILE', '0' ) + ELSE + ISTATUS = NF90_PUT_ATT( TPFILE%NNCID, NF90_GLOBAL, 'MNH_IS_ROOTFILE', '1' ) + END IF + IF ( ISTATUS /= NF90_NOERR ) CALL IO_Err_handle_nc4( istatus, 'IO_FILE_WRITE_HEADER', 'NF90_PUT_ATT', 'MNH_IS_SUBFILE' ) + + ! For the moment, there is only this type: Zsplit + IF ( TPFILE%NSUBFILES_IOZ > 0 .OR. ASSOCIATED( TPFILE%TMAINFILE ) ) THEN + ISTATUS = NF90_PUT_ATT( TPFILE%NNCID, NF90_GLOBAL, 'MNH_SUBFILE_TYPE', 'Zsplit' ) + IF ( ISTATUS /= NF90_NOERR ) CALL IO_Err_handle_nc4( istatus, 'IO_FILE_WRITE_HEADER', 'NF90_PUT_ATT', 'MNH_SUBFILE_TYPE' ) + END IF + !title !history -- GitLab