diff --git a/src/LIB/SURCOUCHE/src/mode_io_file_nc4.f90 b/src/LIB/SURCOUCHE/src/mode_io_file_nc4.f90 index 33d30b3c475dda0003f8d0bf7f54814bf76cc8b2..784dd4e06e2794c63be4468730275a3eeba486e5 100644 --- a/src/LIB/SURCOUCHE/src/mode_io_file_nc4.f90 +++ b/src/LIB/SURCOUCHE/src/mode_io_file_nc4.f90 @@ -28,8 +28,8 @@ use modd_precision, only: CDFINT use mode_io_tools_nc4, only: IO_Err_handle_nc4, IO_Knowndims_set_nc4, IO_Iocdf_alloc_nc4 use mode_msg -use NETCDF, only: NF90_CLOBBER, NF90_GLOBAL, NF90_NETCDF4, NF90_NOERR, NF90_NOWRITE, & - NF90_CLOSE, NF90_CREATE, NF90_GET_ATT, NF90_INQUIRE, NF90_INQUIRE_ATTRIBUTE, & +use NETCDF, only: NF90_GLOBAL, NF90_NETCDF4, NF90_NOERR, NF90_NOWRITE, & + NF90_CLOSE, NF90_GET_ATT, NF90_INQUIRE, NF90_INQUIRE_ATTRIBUTE, & NF90_OPEN, NF90_PUT_ATT, NF90_STRERROR implicit none @@ -44,10 +44,13 @@ subroutine IO_File_create_nc4(tpfile,hprogram_orig) use mode_io_tools, only: IO_Filename_construct use mode_io_tools_mnhversion, only: IO_Mnhversion_set + use NETCDF, only: NF90_CLOBBER, NF90_CREATE, NF90_NOFILL, NF90_SET_FILL + type(tfiledata), intent(inout) :: tpfile character(len=*),optional, intent(in) :: hprogram_orig !to emulate a file coming from this program character(len=:),allocatable :: yfilem ! name of the file + integer(kind=CDFINT) :: ioldmode integer(kind=CDFINT) :: istatus call print_msg(NVERB_DEBUG,'IO','IO_File_create_nc4','called for '//trim(tpfile%cname)) @@ -60,6 +63,14 @@ subroutine IO_File_create_nc4(tpfile,hprogram_orig) if (istatus /= NF90_NOERR) then call print_msg(NVERB_FATAL,'IO','IO_File_create_nc4','NF90_CREATE for '//trim(yfilem)//'.nc: '//NF90_STRERROR(istatus)) end if + + ! Set pre-filling to NF90_NOFILL + ! In theory, this should give better performance + istatus = NF90_SET_FILL( tpfile%nncid, NF90_NOFILL, ioldmode ) + if (istatus /= NF90_NOERR) then + call print_msg(NVERB_FATAL,'IO','IO_File_create_nc4','NF90_CREATE for '//trim(yfilem)//'.nc: '//NF90_STRERROR(istatus)) + end if + call IO_Not_cleanly_closed_set_nc4(tpfile) call IO_Knowndims_set_nc4(tpfile, hprogram_orig=hprogram_orig) end if diff --git a/src/LIB/SURCOUCHE/src/mode_io_write_nc4.f90 b/src/LIB/SURCOUCHE/src/mode_io_write_nc4.f90 index deb8dfa689174893e9ebeb04917b8bbb22e39b45..cbde62c6aa205cf01372fe46dd72416779671f4d 100644 --- a/src/LIB/SURCOUCHE/src/mode_io_write_nc4.f90 +++ b/src/LIB/SURCOUCHE/src/mode_io_write_nc4.f90 @@ -553,6 +553,11 @@ if ( istatus /= NF90_NOERR ) then istatus = NF90_DEF_VAR( tpfile%nncid, yvarname, itype, ivdims, ivarid ) if ( istatus /= NF90_NOERR ) call IO_Err_handle_nc4( istatus, 'IO_Field_create_nc4', 'NF90_DEF_VAR', Trim( yvarname ) ) + ! Set pre-filling to NF90_NOFILL + ! Not done here because already set at creation time with NF90_SET_FILL + ! istatus = NF90_DEF_VAR_FILL( tpfile%nncid, ivarid, NF90_NOFILL, 0. ) + ! if ( istatus /= NF90_NOERR ) call IO_Err_handle_nc4( istatus, 'IO_Field_create_nc4', 'NF90_DEF_VAR_FILL', Trim( yvarname ) ) + ! Add compression if asked for if ( tpfile%lnccompress .and. tpfield%ntype == TYPEREAL .and. tpfield%ndims >= 1 ) then istatus = NF90_DEF_VAR_DEFLATE( tpfile%nncid, ivarid, SHUFFLE, DEFLATE, tpfile%nnccompress_level )