From c29324016ab13dcb43358ef24288981829d20e62 Mon Sep 17 00:00:00 2001 From: David A Minton Date: Fri, 8 Oct 2021 14:30:24 -0400 Subject: [PATCH] Added new chunking parameter to help speed up I/O --- src/netcdf/netcdf.f90 | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/netcdf/netcdf.f90 b/src/netcdf/netcdf.f90 index 39df30d61..146703989 100644 --- a/src/netcdf/netcdf.f90 +++ b/src/netcdf/netcdf.f90 @@ -79,6 +79,8 @@ module subroutine netcdf_initialize_output(self, param) real(SP) :: sfill logical :: fileExists character(len=STRMAX) :: errmsg + integer(I4B) :: storage, ndims, i + integer(I4B), parameter :: chunk = 2048 dfill = ieee_value(dfill, IEEE_QUIET_NAN) sfill = ieee_value(sfill, IEEE_QUIET_NAN) @@ -184,7 +186,7 @@ module subroutine netcdf_initialize_output(self, param) ! Set fill mode to NaN for all variables call check( nf90_inquire(self%ncid, nVariables=nvar) ) do varid = 1, nvar - call check( nf90_inquire_variable(self%ncid, varid, xtype=vartype) ) + call check( nf90_inquire_variable(self%ncid, varid, xtype=vartype, ndims=ndims) ) select case(vartype) case(NF90_INT) call check( nf90_def_var_fill(self%ncid, varid, 0, NF90_FILL_INT) ) @@ -195,6 +197,13 @@ module subroutine netcdf_initialize_output(self, param) case(NF90_CHAR) call check( nf90_def_var_fill(self%ncid, varid, 0, 0) ) end select + + select case(vartype) + case(NF90_CHAR) + call check( nf90_def_var_chunking(self%ncid, varid, NF90_CHUNKED, [NAMELEN, chunk]) ) + case default + call check( nf90_def_var_chunking(self%ncid, varid, NF90_CHUNKED, [(chunk, i = 1, ndims)]) ) + end select end do ! Take the file out of define mode