Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: treatment of scalars in TdiTrans.c #2832

Open
wants to merge 1 commit into
base: alpha
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion include/mdsdescrip.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@ typedef struct descriptor_a
*
* The multipliers block has the following format:
* char *a0; Address of the element whose subscripts are
* all zero int m [DIMCT]; Addressing coefficients (multipliers)
* all zero
* int m [DIMCT]; Addressing coefficients (multipliers)
*
* The bounds block has the following format:
* struct
Expand Down
17 changes: 7 additions & 10 deletions tdishr/TdiTrans.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ int Tdi1Trans(int opcode, int narg, mdsdsc_t *list[], mdsdsc_xd_t *out_ptr)
const mdsdsc_t *pmask = &one;
mds_signal_t *psig;
signal_maxdim tmpsig;
aflags_t aflags_default = {0,1,1,0,0};
array_bounds arr, *pa, *pd;
mdsdsc_xd_t sig[3] = {EMPTY_XD}, uni[3] = {EMPTY_XD}, dat[3] = {EMPTY_XD};
struct TdiCatStruct cats[4];
Expand Down Expand Up @@ -293,13 +294,11 @@ int Tdi1Trans(int opcode, int narg, mdsdsc_t *list[], mdsdsc_xd_t *out_ptr)
/** scalar to simple vector **/
if (rank == 0) {
memcpy((char *)&arr, (char *)pa, sizeof(struct descriptor));
arr.scale = 0;
arr.digits = 0;
arr.aflags = aflags_default;
arr.dimct = 1;
arr.aflags.coeff = 0;
arr.a0 = arr.pointer;
arr.arsize = arr.length;
arr.m[0] = 1;
arr.m[1] = 1;
arr.m[dim] = ncopies;
}
/** simple and coefficient vector **/
else
Expand Down Expand Up @@ -337,13 +336,11 @@ int Tdi1Trans(int opcode, int narg, mdsdsc_t *list[], mdsdsc_xd_t *out_ptr)
/** scalar to simple vector **/
if (rank == 0) {
memcpy((char *)&arr, (char *)pa, sizeof(struct descriptor));
arr.scale = 0;
arr.digits = 0;
arr.aflags = aflags_default;
arr.dimct = 1;
arr.aflags.coeff = 0;
arr.a0 = arr.pointer;
arr.arsize = arr.length;
arr.m[0] = 1;
arr.m[1] = 1;
arr.m[dim] = ncopies;
}
else if (rank >= MAX_DIMS)
status = TdiNDIM_OVER;
Expand Down
4 changes: 4 additions & 0 deletions tditest/testing/test-tdishr.ans
Original file line number Diff line number Diff line change
Expand Up @@ -5674,8 +5674,12 @@ lastloc(_M)
Byte_Unsigned([[0,0,0,0], [0,0,0,0], [0,0,0,1], [0,0,0,0]])
lastloc(_M,0)
Byte_Unsigned([[0,0,1,0], [0,0,1,0], [0,0,0,1], [0,0,0,0]])
replicate(2,0,3)
[2,2,2]
replicate([[2,4],[3,5]],1,3)
[[2,4], [3,5], [2,4], [3,5], [2,4], [3,5]]
spread(2,0,3)
[2,2,2]
spread([2,3,4],0,3)
[[2,2,2], [3,3,3], [4,4,4]]
trim(' A B ')
Expand Down
2 changes: 2 additions & 0 deletions tditest/testing/test-tdishr.tdi
Original file line number Diff line number Diff line change
Expand Up @@ -2986,7 +2986,9 @@ firstloc(_M)
firstloc(_M,0)
lastloc(_M)
lastloc(_M,0)
replicate(2,0,3)
replicate([[2,4],[3,5]],1,3)
spread(2,0,3)
spread([2,3,4],0,3)
#
# Functions implemented in TdiTrim.c
Expand Down