Skip to content

Commit 53e3994

Browse files
author
David Berry
committed
Change to use signed 64 bit ints for HDS dimensions
This needs to be done since the main point of the move to HDS-V5 is to allow starlink apps to process arrays with more than 2^32 pixels. Since the ARY library standardly vectorises each N-D arrray and then accesses it as a 1D array, individual axis dimensions can also be greater than 2^32. They need to be signed since hdsdim will also be used for ARY/NDF bounds, which can be negative.
1 parent 49be15e commit 53e3994

6 files changed

+21
-8
lines changed

Makefile.am

+1
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ dat1CreateStructureCell.c \
145145
dat1CvtChar.c \
146146
dat1CvtLogical.c \
147147
dat1DumpLoc.c \
148+
dat1emsSetHdsdim.c \
148149
dat1EncodeSubscript.c \
149150
dat1EraseHandle.c \
150151
dat1ExportDims.c \

dat1ImportFloc.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
* len = int (Given)
2121
* Size of Fortran character buffer. Sanity check.
2222
* status = int * (Given and Returned)
23-
* Inherited status. Attempts to execute even if status is not DAT__OK
23+
* Inherited status. Attempts to execute even if status is not SAI__OK
2424
* on entry.
2525
2626
* Returned Value:

hds1.h

+8
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,12 @@
1313
#define MEM_REALLOC starRealloc
1414
#define MEM_CALLOC starCalloc
1515

16+
/* EMS wrapper routines:*/
17+
/* =====================*/
18+
#include "hds_types.h"
19+
void dat1emsSetHdsdim( const char * token, hdsdim value );
20+
21+
22+
23+
1624
#endif

hds1_types.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ typedef uint64_t hdsu64_t;
4444

4545
/* Private types and sizes relating to dimensions */
4646
typedef int FORTRAN_INDEX_TYPE;
47-
#define SIZEOF_HDSDIM 4
47+
#define SIZEOF_HDSDIM 8
4848
#define HDSDIM_IS_UNSIGNED 0
4949

5050
/* Decide whether Fortran dims should be copied element by element */
51-
#define HDS_COPY_FORTRAN_DIMS 0
51+
#define HDS_COPY_FORTRAN_DIMS 1
5252

5353
#endif /* _INCLUDED */
5454

hds_fortran.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ hdsDimF2C( int ndim, const F77_INTEGER_TYPE fdims[],
8585
#define HDSDIM2INT( subname, cint, fint, status ) \
8686
if ( cint > (hdsdim)INT_MAX ) { \
8787
fint = 0; \
88-
if (*status == DAT__OK) { \
88+
if (*status == SAI__OK) { \
8989
*status = DAT__DTRNC; \
9090
dat1emsSetHdsdim( "DIM", cint ); \
9191
emsRep( " ", \

make-hds-types.c

+8-4
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@
4444
* Use inttypes.h in preference to stdint.h.
4545
* 2006-Jul-25 (PWD):
4646
* More fixes for MINGW handling of "long long" printfs.
47+
* 2017-Sep-12 (DSB):
48+
* Switch HDS dimensiosn to signed 64 bit integers. They need to be
49+
* signed since they will also be used for ARY/NDF array bounds, which
50+
* can be nagative.
4751
4852
* Copyright:
4953
* Copyright (C) 2005 Particle Physics and Astronomy Research Council.
@@ -138,12 +142,12 @@ error unable to find an 8 byte integer type
138142
/* We also state whether this is unsigned so that we can compare with
139143
the fortran type and also define the size. The last bit is a bit of
140144
a kluge to prevent sizeof("uint64_t") coming up with 9 */
141-
#define BIGDIM 0 /* set to 1 if testing 64 bit dims */
145+
#define BIGDIM 1 /* set to 1 if testing 64 bit dims */
142146
#if BIGDIM
143-
#define DIM_TYPE UINT_BIG
147+
#define DIM_TYPE INT_BIG
144148
#define SIZEOF_DIM 8
145-
#define DIM_FORMAT INT_BIG_U
146-
#define DIM_IS_UNSIGNED 1
149+
#define DIM_FORMAT INT_BIG_S
150+
#define DIM_IS_UNSIGNED 0
147151
#else
148152
#define DIM_TYPE STD_INT
149153
#define SIZEOF_DIM 4

0 commit comments

Comments
 (0)