Brian,
I am perplexed. I have a HDS data structure looking like this:
SMU_JIG_INDEX(60) <_INTEGER> *,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,
*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*
and I want to read it as a _WORD. Currently I can't do it because I get this error:
!! Error converting from _INTEGER to _WORD
! A total of 60 data conversion error(s) occurred.
! DAT_MAP: Error mapping an HDS primitive: 'SMU_JIG_INDEX'
! Application exit status DAT__CONER, Conversion error
because the code to do the conversion in daucnv.c looks like this:
case DAT__W:
{
_INTEGER *src = (_INTEGER *) imp->body;
_WORD *des = (_WORD *) exp->body;
for (n = 0; n < nval; n++)
{
des[n] = (_UWORD) src[n];
if (des[n] != src[n])
{
(*nbad)++;
des[n] = dat_gl_ndr[ DAT__W ].bad.W;
hds_gl_status = DAT__CONER;
}
}
break;
What I don't understand is why the conversion code does not test for the bad value. Something like this:
case DAT__W:
{
_INTEGER *src = (_INTEGER *) imp->body;
_WORD *des = (_WORD *) exp->body;
for (n = 0; n < nval; n++)
{
des[n] = (_WORD) src[n];
if (des[n] != src[n])
{
des[n] = dat_gl_ndr[ DAT__W ].bad.W;
if (src[n] != dat_gl_ndr[ DAT__I ].bad.I )
{
(*nbad)++;
hds_gl_status = DAT__CONER;
}
}
}
Seems to fix the problem. It doesn't look like incoming bads are checked anywhere. If I have a _WORD array and I map as _INTEGER it seems that the bad values don't get retained as bad either. Can you explain the logic to me please? I'm prepared to jump in to fix these conversions (my main motivation being that I have shrunk some of our data arrays in JCMT data from _INTEGER to _WORD but I still need to read old data files preferably with out having to special case them at the application layer).
--
Tim Jenness
Joint Astronomy Centre
|