From 0ce79d45f783616c19bea4483a25e5bebae5fc9f Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Mon, 9 Sep 2024 21:36:16 +0000 Subject: [PATCH] #2968 Compare the DataPlane size and the variable data size --- src/libcode/vx_data2d_nc_cf/nc_cf_file.cc | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/libcode/vx_data2d_nc_cf/nc_cf_file.cc b/src/libcode/vx_data2d_nc_cf/nc_cf_file.cc index a739c5ae0d..b66c2b0aec 100644 --- a/src/libcode/vx_data2d_nc_cf/nc_cf_file.cc +++ b/src/libcode/vx_data2d_nc_cf/nc_cf_file.cc @@ -1079,6 +1079,18 @@ bool NcCfFile::getData(NcVar * v, const LongArray & a, DataPlane & plane) const const int nx = grid.nx(); const int ny = grid.ny(); + int data_size = 1; + for (int k=0; kgetDim(k).getSize(); + } + if (data_size == 1) data_size = v->getDim(x_slot).getSize() * v->getDim(y_slot).getSize(); + if (!is_eq(data_size, nx*ny)) { + mlog << Error << "\n" << method_name + << "Allocated DataPlane from Grid (" << nx*ny << ") does not match with the variable size (" + << data_size << "). Please check set_attr_grid settings if applied.\n\n"; + exit(1); + } + plane.clear(); plane.set_size(nx, ny);