Skip to content
Snippets Groups Projects
Commit 218c706d authored by WAUTELET Philippe's avatar WAUTELET Philippe
Browse files

Philippe 20/09/2024: IO: set NOFILL by default for netCDF files

parent 5f4fe673
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
......@@ -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 )
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment