diff options
Diffstat (limited to 'modules/codec-netcdf/c++')
-rw-r--r-- | modules/codec-netcdf/c++/netcdf.tmpl.hpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/modules/codec-netcdf/c++/netcdf.tmpl.hpp b/modules/codec-netcdf/c++/netcdf.tmpl.hpp index bf257e4..ba357a5 100644 --- a/modules/codec-netcdf/c++/netcdf.tmpl.hpp +++ b/modules/codec-netcdf/c++/netcdf.tmpl.hpp @@ -229,18 +229,18 @@ struct netcdf_decode<schema::Array<T,Dim>, ToDecode> { using Schema = schema::Array<T,Dim>; template<std::size_t Level> - static error_or<void> decode_level(data<Schema, ToDecode>& to, int from, int nc_varid, std::array<std::size_t, Dim>& index, const std::array<size_t,Dim>& count){ + static error_or<void> decode_level(data<Schema, ToDecode>& to, int from, int nc_varid, data<schema::FixedArray<schema::UInt64,Dim>, ToDecode>& index, const std::array<size_t,Dim>& count){ if constexpr ( Level == Dim ){ int rc{}; typename native_data_type<T>::type val; - rc = nc_get_vara(from, nc_varid, index.data(), count.data(), &val); + rc = nc_get_vara(from, nc_varid, convert_to_stl<schema::FixedArray<schema::UInt64,Dim>, ToDecode>{}(index).data(), count.data(), &val); if(rc != NC_NOERR){ return make_error<err::critical>(); } to.at(index).set(val); }else{ const std::size_t dim_size = to.get_dim_size(Level); - for(index[Level] = 0; index[Level] < dim_size; ++index[Level]){ + for(index.at(Level) = 0; index.at(Level).get() < dim_size; ++index.at(Level)){ auto eov = decode_level<Level+1>(to, from, nc_varid, index, count); if(eov.is_error()){ return eov; @@ -270,18 +270,20 @@ struct netcdf_decode<schema::Array<T,Dim>, ToDecode> { return make_error<err::critical>(); } - std::array<std::size_t, Dim> dims; + data<schema::FixedArray<schema::UInt64,Dim>, ToDecode> dims; std::array<size_t, Dim> count; for(std::size_t i = 0; i < Dim; ++i){ - rc = nc_inq_dim(from, nc_dimids[i], nullptr, &dims[i]); + uint64_t dim_i = dims.at({i}).get(); + rc = nc_inq_dim(from, nc_dimids[i], nullptr, &dim_i); if(rc != NC_NOERR){ return make_error<err::critical>(); } + dims.at(i).set(dim_i); count[i] = 1; } to = {dims}; - std::array<std::size_t, Dim> index; + data<schema::FixedArray<schema::UInt64,Dim>, ToDecode> index; return decode_level<0>(to, from, nc_varid, index, count); } |