From 5ec49f266e765e76fdc5f66370076043302c60cd Mon Sep 17 00:00:00 2001 From: Alexander Barth Date: Fri, 4 Aug 2023 08:53:51 +0200 Subject: [PATCH] define unsafe_load! first --- src/variable.jl | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/variable.jl b/src/variable.jl index 6b4c1ab7..e294f9ee 100644 --- a/src/variable.jl +++ b/src/variable.jl @@ -92,6 +92,21 @@ function checkbuffer(len,data) end end +@inline function unsafe_load!(ncvar::Variable, data, indices::Union{Integer, UnitRange, StepRange, Colon}...) + sizes = size(ncvar) + normalizedindices = normalizeindexes(sizes, indices) + ind = to_indices(ncvar,normalizedindices) + + start,count,stride,jlshape = ncsub(ind) + + @boundscheck begin + checkbounds(ncvar,indices...) + checkbuffer(prod(count),data) + end + + nc_get_vars!(ncvar.ds.ncid,ncvar.varid,start,count,stride,data) +end + """ NCDatasets.load!(ncvar::Variable, data, indices) @@ -130,21 +145,6 @@ end @inline unsafe_load!(ncvar, data, indices...) end -@inline function unsafe_load!(ncvar::Variable, data, indices::Union{Integer, UnitRange, StepRange, Colon}...) - sizes = size(ncvar) - normalizedindices = normalizeindexes(sizes, indices) - ind = to_indices(ncvar,normalizedindices) - - start,count,stride,jlshape = ncsub(ind) - - @boundscheck begin - checkbounds(ncvar,indices...) - checkbuffer(prod(count),data) - end - - nc_get_vars!(ncvar.ds.ncid,ncvar.varid,start,count,stride,data) -end - @inline function load!(ncvar::Variable{T,2}, data::AbstractArray{T}, i::Colon,j::UnitRange) where T # reversed and 0-based start = [first(j)-1,0]