From 5c65123b44cd8e9761ff8c812b141a496a649019 Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Fri, 11 Apr 2025 12:54:00 +0200 Subject: Moving towards more forstio data types --- modules/codec-netcdf/c++/netcdf.tmpl.hpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'modules/codec-netcdf/c++') 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, ToDecode> { using Schema = schema::Array; template - static error_or decode_level(data& to, int from, int nc_varid, std::array& index, const std::array& count){ + static error_or decode_level(data& to, int from, int nc_varid, data, ToDecode>& index, const std::array& count){ if constexpr ( Level == Dim ){ int rc{}; typename native_data_type::type val; - rc = nc_get_vara(from, nc_varid, index.data(), count.data(), &val); + rc = nc_get_vara(from, nc_varid, convert_to_stl, ToDecode>{}(index).data(), count.data(), &val); if(rc != NC_NOERR){ return make_error(); } 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(to, from, nc_varid, index, count); if(eov.is_error()){ return eov; @@ -270,18 +270,20 @@ struct netcdf_decode, ToDecode> { return make_error(); } - std::array dims; + data, ToDecode> dims; std::array 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(); } + dims.at(i).set(dim_i); count[i] = 1; } to = {dims}; - std::array index; + data, ToDecode> index; return decode_level<0>(to, from, nc_varid, index, count); } -- cgit v1.2.3