16 ROUTINE VARIANTS FOR LARGE ARRAYS

The HDS routines described in the reference section of this document all use 4 byte integers arguments (i.e. a basic Fortran INTEGER) to store array dimensions, pixel indices and pixel counts. This restricts their usefulness to arrays that have no more than 2147483647 pixels (the largest positive number that can be stored in an INTEGER). Using these functions with larger arrays will cause overflow and undefined behaviour. However, for each routine that includes one or more such arguments, there is a variant of the routine that uses INTEGER*8 arguments for all array dimensions, pixel indices and pixel counts. Each variant routine has the same name as the corresponding basic routine but with the digit “8” (as in “INTEGER*8”) appended to the end of the name. The available variant routines are listed below:

DAT_ALTER8, DAT_BASIC8, DAT_CELL8, DAT_GET8, DAT_GETx8, DAT_GET1x8, DAT_GETVx8, DAT_MAP8, DAT_MAPx8, DAT_MAPN8, DAT_MAPV8, DAT_MOULD8, DAT_NEW8, DAT_NEWC8, ??, DAT_NEW1x8, DAT_PUTx8, DAT_PUT8, DAT_PUT1x8, DAT_PUTVx8, DAT_SHAPE8, DAT_SIZE8, DAT_SLICE8, DAT_TEMP8, HDS_NEW8

Each variant routine has the same argument list as the corresponding basic routine except that any INTEGER argument used to pass array dimensions, pixel indices or pixel counts is changed to INTEGER*8.

Note, when changing code from using basic to using variant routines, remember that if a literal integer constant is passed to a subroutine, it’s kind must match that expected by the the subroutine. So if the old code was:

        INTEGER ACTVAL
        INTEGER STATUS
        DOUBLE PRECISION VALUES( 5 )
        ...
        CALL DAT_GET1D( LOC, 5, VALUES, ACTVAL, STATUS )
        ...

the new code should be

        INTEGER*8 ACTVAL
        INTEGER STATUS
        DOUBLE PRECISION VALUES( 5 )
        ...
        CALL DAT_GET1D8( LOC, 5_8, VALUES, ACTVAL, STATUS )
        ...

The literal constant “5_8” indicates a 8 byte integer constant with the value 5. If the old literal constant “5” was left unchanged, spurious behaviour such as a segmentation fault is likely to occur.