From 472ecc32fff39c1281cfe7dbe4ccacecb8324f15 Mon Sep 17 00:00:00 2001
From: Philippe WAUTELET <philippe.wautelet@aero.obs-mip.fr>
Date: Fri, 12 Apr 2024 11:23:38 +0200
Subject: [PATCH] Philippe 12/04/2024: add IO_Field_partial_write_nc4_N1
 subroutine

---
 src/LIB/SURCOUCHE/src/mode_io_write_nc4.f90 | 41 ++++++++++++++++++++-
 1 file changed, 39 insertions(+), 2 deletions(-)

diff --git a/src/LIB/SURCOUCHE/src/mode_io_write_nc4.f90 b/src/LIB/SURCOUCHE/src/mode_io_write_nc4.f90
index b6707b7ca..adb43c00a 100644
--- a/src/LIB/SURCOUCHE/src/mode_io_write_nc4.f90
+++ b/src/LIB/SURCOUCHE/src/mode_io_write_nc4.f90
@@ -76,8 +76,8 @@ END INTERFACE IO_Field_write_nc4
 interface IO_Field_partial_write_nc4
    module procedure IO_Field_partial_write_nc4_X1, IO_Field_partial_write_nc4_X2, &
                     IO_Field_partial_write_nc4_X3, IO_Field_partial_write_nc4_X4, &
-                    IO_Field_partial_write_nc4_N2, IO_Field_partial_write_nc4_N3, &
-                    IO_Field_partial_write_nc4_N4
+                    IO_Field_partial_write_nc4_N1, IO_Field_partial_write_nc4_N2, &
+                    IO_Field_partial_write_nc4_N3, IO_Field_partial_write_nc4_N4
 end interface IO_Field_partial_write_nc4
 
 integer,parameter :: NSTRINGCHUNKSIZE = 16 !Dimension of the chunks of strings
@@ -1299,6 +1299,43 @@ end if
 end subroutine IO_Field_partial_write_nc4_X4
 
 
+subroutine IO_Field_partial_write_nc4_N1( tpfile, tpfield, kfield, koffset, kresp )
+
+type(tfiledata),                intent(in)  :: tpfile
+class(tfieldmetadata),          intent(in)  :: tpfield
+integer,          dimension(:), intent(in)  :: kfield   ! array containing the data field
+integer,          dimension(1), intent(in)  :: koffset
+integer,                        intent(out) :: kresp
+
+character(len=NMNHNAMELGTMAX)      :: yvarname
+integer(kind=CDFINT)               :: istatus
+integer(kind=CDFINT)               :: ivarid
+integer(kind=CDFINT), dimension(1) :: istarts
+
+call Print_msg( NVERB_DEBUG, 'IO', 'IO_Field_partial_write_nc4_N1',&
+                Trim( tpfile%cname ) // ': writing ' // Trim( tpfield%cmnhname ) )
+
+kresp = 0
+
+call IO_Mnhname_clean( tpfield%cmnhname, yvarname )
+
+istatus = NF90_INQ_VARID( tpfile%nncid, yvarname, ivarid )
+if ( istatus /= NF90_NOERR ) then
+  call Print_msg( NVERB_FATAL, 'IO', 'IO_Field_partial_write_nc4_N1', 'variable ' // Trim( yvarname ) &
+                  // ' not yet created (IO_Field_create not yet called?)' )
+end if
+
+! Write the data
+if ( Size( kfield ) > 0 ) then
+  istarts(:) = koffset(:) + 1
+  istatus = NF90_PUT_VAR( tpfile%nncid, ivarid, kfield(:), start = istarts(:), count = Int( Shape( kfield ), kind = CDFINT ) )
+  if (istatus /= NF90_NOERR) &
+    call IO_Err_handle_nc4( istatus, 'IO_Field_partial_write_nc4_N1', 'NF90_PUT_VAR', Trim( tpfield%cmnhname ), kresp )
+end if
+
+end subroutine IO_Field_partial_write_nc4_N1
+
+
 subroutine IO_Field_partial_write_nc4_N2( tpfile, tpfield, kfield, koffset, kresp, kvertlevel, kzfile )
 
 type(tfiledata),                  intent(in)  :: tpfile
-- 
GitLab