From 90ba4cc89ee2456213f67075578be5b212d2f6a8 Mon Sep 17 00:00:00 2001 From: Philip Davis Date: Mon, 13 Nov 2023 16:08:30 -0500 Subject: [PATCH] Update ub for dspaces_aget when data bounds constrict the result. --- bindings/python/dspaces_wrapper.c | 5 ++++- include/dspaces.h | 6 +++--- src/dspaces-client.c | 5 ++++- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/bindings/python/dspaces_wrapper.c b/bindings/python/dspaces_wrapper.c index 67c20645..1ddc6ac5 100644 --- a/bindings/python/dspaces_wrapper.c +++ b/bindings/python/dspaces_wrapper.c @@ -177,7 +177,6 @@ PyObject *wrapper_dspaces_get(PyObject *clientppy, const char *name, lb[i] = PyLong_AsLong(item); item = PyTuple_GetItem(ubt, i); ub[i] = PyLong_AsLong(item); - dims[i] = (ub[i] - lb[i]) + 1; } dspaces_aget(*clientp, name, version, ndim, lb, ub, &data, &tag, timeout); @@ -188,6 +187,10 @@ PyObject *wrapper_dspaces_get(PyObject *clientppy, const char *name, descr = PyArray_DescrNew((PyArray_Descr *)dtype); } + for(i = 0; i < ndim; i++) { + dims[i] = ((ub[i] - lb[i]) + 1); + } + arr = PyArray_NewFromDescr(&PyArray_Type, descr, ndim, dims, NULL, data, 0, NULL); diff --git a/include/dspaces.h b/include/dspaces.h index 9577cb4f..32a576de 100644 --- a/include/dspaces.h +++ b/include/dspaces.h @@ -246,10 +246,10 @@ int dspaces_get(dspaces_client_t client, const char *var_name, unsigned int ver, * array. * @param[in] ndim: the number of dimensions for the local bounding * box. - * @param[in] lb: coordinates for the lower corner of the local - * bounding box. - * @param[in] ub: coordinates for the upper corner of the local + * @param[in, out] lb: coordinates for the lower corner of the local * bounding box. + * @param[in, out] ub: coordinates for the upper corner of the local + * bounding box. Updated if truncated by data bounds. * @param[in] data: Pointer to user data buffer. * @param[out] tag: Pointer to an int buffer to store tag value. Not stored if tag is NULL. * @param[in] timeout: Timeout value: -1 is never, 0 is immediate. diff --git a/src/dspaces-client.c b/src/dspaces-client.c index 02bd5344..a5b05a55 100644 --- a/src/dspaces-client.c +++ b/src/dspaces-client.c @@ -1613,7 +1613,7 @@ int dspaces_aget(dspaces_client_t client, const char *var_name, int num_odscs; int elem_size; int num_elem = 1; - int i; + int i,j; int ret = dspaces_SUCCESS; fill_odsc(client, var_name, ver, 0, ndim, lb, ub, &odsc); @@ -1627,6 +1627,9 @@ int dspaces_aget(dspaces_client_t client, const char *var_name, if(odsc_tab[i].flags && DS_OBJ_RESIZE) { DEBUG_OUT("the result is cropped.\n"); memcpy(&odsc.bb, &odsc_tab[i].bb, sizeof(odsc_tab[i].bb)); + for(j = 0; j < odsc.bb.num_dims; j++) { + ub[j] = odsc.bb.ub.c[j]; + } } DEBUG_OUT("%s\n", obj_desc_sprint(&odsc_tab[i])); }