From 6f23d4388a0e51db46a434f3c0dbd7adcfc52b44 Mon Sep 17 00:00:00 2001 From: Dave Allured Date: Fri, 15 May 2026 15:50:21 -0600 Subject: [PATCH] Fix size() for large variables >= 2^31 values --- fortran/netcdf4_eightbyte.F90 | 28 ++++++++++++++-------------- fortran/netcdf_eightbyte.F90 | 14 +++++++------- fortran/netcdf_expanded.F90 | 14 +++++++------- 3 files changed, 28 insertions(+), 28 deletions(-) diff --git a/fortran/netcdf4_eightbyte.F90 b/fortran/netcdf4_eightbyte.F90 index 0da6e91a..da74d3ff 100644 --- a/fortran/netcdf4_eightbyte.F90 +++ b/fortran/netcdf4_eightbyte.F90 @@ -396,7 +396,7 @@ function nf90_get_var_1D_EightByteInt(ncid, varid, values, start, count, stride, if (nf90_get_var_1D_EightByteInt .eq. nf90_noerr) then if (format_num .eq. nf90_format_netcdf4 .OR. & format_num .eq. nf90_format_cdf5) then - allocate(defaultInt8Array(size(values))) + allocate(defaultInt8Array(size(values,kind=EightByteInt))) if(present(map)) then localMap (:size(map)) = map(:) nf90_get_var_1D_EightByteInt = & @@ -411,7 +411,7 @@ function nf90_get_var_1D_EightByteInt(ncid, varid, values, start, count, stride, values(:) = reshape(defaultInt8Array(:), shapeValues) if (allocated(defaultInt8Array)) deallocate(defaultInt8Array) else - allocate(defaultIntArray(size(values))) + allocate(defaultIntArray(size(values,kind=EightByteInt))) if(present(map)) then localMap (:size(map)) = map(:) nf90_get_var_1D_EightByteInt = & @@ -458,7 +458,7 @@ function nf90_get_var_2D_EightByteInt(ncid, varid, values, start, count, stride, if (nf90_get_var_2D_EightByteInt .eq. nf90_noerr) then if (format_num .eq. nf90_format_netcdf4 .OR. & format_num .eq. nf90_format_cdf5) then - allocate(defaultInt8Array(size(values))) + allocate(defaultInt8Array(size(values,kind=EightByteInt))) if(present(map)) then localMap (:size(map)) = map(:) nf90_get_var_2D_EightByteInt = & @@ -473,7 +473,7 @@ function nf90_get_var_2D_EightByteInt(ncid, varid, values, start, count, stride, values(:, :) = reshape(defaultInt8Array(:), shapeValues) if (allocated(defaultInt8Array)) deallocate(defaultInt8Array) else - allocate(defaultIntArray(size(values))) + allocate(defaultIntArray(size(values,kind=EightByteInt))) if(present(map)) then localMap (:size(map)) = map(:) nf90_get_var_2D_EightByteInt = & @@ -520,7 +520,7 @@ function nf90_get_var_3D_EightByteInt(ncid, varid, values, start, count, stride, if (nf90_get_var_3D_EightByteInt .eq. nf90_noerr) then if (format_num .eq. nf90_format_netcdf4 .OR. & format_num .eq. nf90_format_cdf5) then - allocate(defaultInt8Array(size(values))) + allocate(defaultInt8Array(size(values,kind=EightByteInt))) if(present(map)) then localMap (:size(map)) = map(:) nf90_get_var_3D_EightByteInt = & @@ -535,7 +535,7 @@ function nf90_get_var_3D_EightByteInt(ncid, varid, values, start, count, stride, values(:, :, :) = reshape(defaultInt8Array(:), shapeValues) if (allocated(defaultInt8Array)) deallocate(defaultInt8Array) else - allocate(defaultIntArray(size(values))) + allocate(defaultIntArray(size(values,kind=EightByteInt))) if(present(map)) then localMap (:size(map)) = map(:) nf90_get_var_3D_EightByteInt = & @@ -582,7 +582,7 @@ function nf90_get_var_4D_EightByteInt(ncid, varid, values, start, count, stride, if (nf90_get_var_4D_EightByteInt .eq. nf90_noerr) then if (format_num .eq. nf90_format_netcdf4 .OR. & format_num .eq. nf90_format_cdf5) then - allocate(defaultInt8Array(size(values))) + allocate(defaultInt8Array(size(values,kind=EightByteInt))) if(present(map)) then localMap (:size(map)) = map(:) nf90_get_var_4D_EightByteInt = & @@ -597,7 +597,7 @@ function nf90_get_var_4D_EightByteInt(ncid, varid, values, start, count, stride, values(:, :, :, :) = reshape(defaultInt8Array(:), shapeValues) if (allocated(defaultInt8Array)) deallocate(defaultInt8Array) else - allocate(defaultIntArray(size(values))) + allocate(defaultIntArray(size(values,kind=EightByteInt))) if(present(map)) then localMap (:size(map)) = map(:) nf90_get_var_4D_EightByteInt = & @@ -644,7 +644,7 @@ function nf90_get_var_5D_EightByteInt(ncid, varid, values, start, count, stride, if (nf90_get_var_5D_EightByteInt .eq. nf90_noerr) then if (format_num .eq. nf90_format_netcdf4 .OR. & format_num .eq. nf90_format_cdf5) then - allocate(defaultInt8Array(size(values))) + allocate(defaultInt8Array(size(values,kind=EightByteInt))) if(present(map)) then localMap (:size(map)) = map(:) nf90_get_var_5D_EightByteInt = & @@ -659,7 +659,7 @@ function nf90_get_var_5D_EightByteInt(ncid, varid, values, start, count, stride, values(:, :, :, :, :) = reshape(defaultInt8Array(:), shapeValues) if (allocated(defaultInt8Array)) deallocate(defaultInt8Array) else - allocate(defaultIntArray(size(values))) + allocate(defaultIntArray(size(values,kind=EightByteInt))) if(present(map)) then localMap (:size(map)) = map(:) nf90_get_var_5D_EightByteInt = & @@ -706,7 +706,7 @@ function nf90_get_var_6D_EightByteInt(ncid, varid, values, start, count, stride, if (nf90_get_var_6D_EightByteInt .eq. nf90_noerr) then if (format_num .eq. nf90_format_netcdf4 .OR. & format_num .eq. nf90_format_cdf5) then - allocate(defaultInt8Array(size(values))) + allocate(defaultInt8Array(size(values,kind=EightByteInt))) if(present(map)) then localMap (:size(map)) = map(:) nf90_get_var_6D_EightByteInt = & @@ -721,7 +721,7 @@ function nf90_get_var_6D_EightByteInt(ncid, varid, values, start, count, stride, values(:, :, :, :, :, :) = reshape(defaultInt8Array(:), shapeValues) if (allocated(defaultInt8Array)) deallocate(defaultInt8Array) else - allocate(defaultIntArray(size(values))) + allocate(defaultIntArray(size(values,kind=EightByteInt))) if(present(map)) then localMap (:size(map)) = map(:) nf90_get_var_6D_EightByteInt = & @@ -768,7 +768,7 @@ function nf90_get_var_7D_EightByteInt(ncid, varid, values, start, count, stride, if (nf90_get_var_7D_EightByteInt .eq. nf90_noerr) then if (format_num .eq. nf90_format_netcdf4 .OR. & format_num .eq. nf90_format_cdf5) then - allocate(defaultInt8Array(size(values))) + allocate(defaultInt8Array(size(values,kind=EightByteInt))) if(present(map)) then localMap (:size(map)) = map(:) nf90_get_var_7D_EightByteInt = & @@ -783,7 +783,7 @@ function nf90_get_var_7D_EightByteInt(ncid, varid, values, start, count, stride, values(:, :, :, :, :, :, :) = reshape(defaultInt8Array(:), shapeValues) if (allocated(defaultInt8Array)) deallocate(defaultInt8Array) else - allocate(defaultIntArray(size(values))) + allocate(defaultIntArray(size(values,kind=EightByteInt))) if(present(map)) then localMap (:size(map)) = map(:) nf90_get_var_7D_EightByteInt = & diff --git a/fortran/netcdf_eightbyte.F90 b/fortran/netcdf_eightbyte.F90 index a80a1967..04ff794b 100644 --- a/fortran/netcdf_eightbyte.F90 +++ b/fortran/netcdf_eightbyte.F90 @@ -254,7 +254,7 @@ function nf90_get_var_1D_EightByteInt(ncid, varid, values, start, count, stride, integer :: numDims, counter, shapeValues(1) integer, dimension(:), allocatable :: defaultIntArray - allocate(defaultIntArray(size(values))) + allocate(defaultIntArray(size(values,kind=EightByteInt))) ! Set local arguments to default values shapeValues = shape(values) @@ -295,7 +295,7 @@ function nf90_get_var_2D_EightByteInt(ncid, varid, values, start, count, stride, integer :: numDims, counter, shapeValues(2) integer, dimension(:), allocatable :: defaultIntArray - allocate(defaultIntArray(size(values))) + allocate(defaultIntArray(size(values,kind=EightByteInt))) ! Set local arguments to default values shapeValues = shape(values) @@ -336,7 +336,7 @@ function nf90_get_var_3D_EightByteInt(ncid, varid, values, start, count, stride, integer :: numDims, counter, shapeValues(3) integer, dimension(:), allocatable :: defaultIntArray - allocate(defaultIntArray(size(values))) + allocate(defaultIntArray(size(values,kind=EightByteInt))) ! Set local arguments to default values shapeValues = shape(values) @@ -377,7 +377,7 @@ function nf90_get_var_4D_EightByteInt(ncid, varid, values, start, count, stride, integer :: numDims, counter, shapeValues(4) integer, dimension(:), allocatable :: defaultIntArray - allocate(defaultIntArray(size(values))) + allocate(defaultIntArray(size(values,kind=EightByteInt))) ! Set local arguments to default values shapeValues = shape(values) @@ -418,7 +418,7 @@ function nf90_get_var_5D_EightByteInt(ncid, varid, values, start, count, stride, integer :: numDims, counter, shapeValues(5) integer, dimension(:), allocatable :: defaultIntArray - allocate(defaultIntArray(size(values))) + allocate(defaultIntArray(size(values,kind=EightByteInt))) ! Set local arguments to default values shapeValues = shape(values) @@ -459,7 +459,7 @@ function nf90_get_var_6D_EightByteInt(ncid, varid, values, start, count, stride, integer :: numDims, counter, shapeValues(6) integer, dimension(:), allocatable :: defaultIntArray - allocate(defaultIntArray(size(values))) + allocate(defaultIntArray(size(values,kind=EightByteInt))) ! Set local arguments to default values shapeValues = shape(values) @@ -500,7 +500,7 @@ function nf90_get_var_7D_EightByteInt(ncid, varid, values, start, count, stride, integer :: numDims, counter, shapeValues(7) integer, dimension(:), allocatable :: defaultIntArray - allocate(defaultIntArray(size(values))) + allocate(defaultIntArray(size(values,kind=EightByteInt))) ! Set local arguments to default values shapeValues = shape(values) diff --git a/fortran/netcdf_expanded.F90 b/fortran/netcdf_expanded.F90 index 9caf6e45..8fab3994 100644 --- a/fortran/netcdf_expanded.F90 +++ b/fortran/netcdf_expanded.F90 @@ -1888,7 +1888,7 @@ function nf90_get_var_1D_FourByteInt(ncid, varid, values, start, count, stride, integer :: numDims, counter, shapeValues(1) integer, dimension(:), allocatable :: defaultIntArray - allocate(defaultIntArray(size(values))) + allocate(defaultIntArray(size(values,kind=EightByteInt))) ! Set local arguments to default values shapeValues = shape(values) @@ -1929,7 +1929,7 @@ function nf90_get_var_2D_FourByteInt(ncid, varid, values, start, count, stride, integer :: numDims, counter, shapeValues(2) integer, dimension(:), allocatable :: defaultIntArray - allocate(defaultIntArray(size(values))) + allocate(defaultIntArray(size(values,kind=EightByteInt))) ! Set local arguments to default values shapeValues = shape(values) @@ -1970,7 +1970,7 @@ function nf90_get_var_3D_FourByteInt(ncid, varid, values, start, count, stride, integer :: numDims, counter, shapeValues(3) integer, dimension(:), allocatable :: defaultIntArray - allocate(defaultIntArray(size(values))) + allocate(defaultIntArray(size(values,kind=EightByteInt))) ! Set local arguments to default values shapeValues = shape(values) @@ -2011,7 +2011,7 @@ function nf90_get_var_4D_FourByteInt(ncid, varid, values, start, count, stride, integer :: numDims, counter, shapeValues(4) integer, dimension(:), allocatable :: defaultIntArray - allocate(defaultIntArray(size(values))) + allocate(defaultIntArray(size(values,kind=EightByteInt))) ! Set local arguments to default values shapeValues = shape(values) @@ -2052,7 +2052,7 @@ function nf90_get_var_5D_FourByteInt(ncid, varid, values, start, count, stride, integer :: numDims, counter, shapeValues(5) integer, dimension(:), allocatable :: defaultIntArray - allocate(defaultIntArray(size(values))) + allocate(defaultIntArray(size(values,kind=EightByteInt))) ! Set local arguments to default values shapeValues = shape(values) @@ -2093,7 +2093,7 @@ function nf90_get_var_6D_FourByteInt(ncid, varid, values, start, count, stride, integer :: numDims, counter, shapeValues(6) integer, dimension(:), allocatable :: defaultIntArray - allocate(defaultIntArray(size(values))) + allocate(defaultIntArray(size(values,kind=EightByteInt))) ! Set local arguments to default values shapeValues = shape(values) @@ -2134,7 +2134,7 @@ function nf90_get_var_7D_FourByteInt(ncid, varid, values, start, count, stride, integer :: numDims, counter, shapeValues(7) integer, dimension(:), allocatable :: defaultIntArray - allocate(defaultIntArray(size(values))) + allocate(defaultIntArray(size(values,kind=EightByteInt))) ! Set local arguments to default values shapeValues = shape(values)