Skip to content

Commit

Permalink
r3.in.v5d, r3.out.v5d: Deprecate CRAY HW specific code (OSGeo#4545)
Browse files Browse the repository at this point in the history
Currently, there is no sign either from GitHub issues or grass-dev archive that many people are using CRAY code which was introduced 25 years ago. As part of fixing a bug, we found that it was hard to find reference materials related to CRAY, due to it being old and not in usage anymore. For this reason, deprecate CRAY code and corresponding complexity that comes with it.

Signed-off-by: Mohan Yelugoti <[email protected]>
  • Loading branch information
ymdatta authored Nov 8, 2024
1 parent 7fe3fa5 commit 8dced26
Show file tree
Hide file tree
Showing 8 changed files with 5 additions and 802 deletions.
312 changes: 0 additions & 312 deletions raster3d/r3.in.v5d/binio.c

Large diffs are not rendered by default.

5 changes: 0 additions & 5 deletions raster3d/r3.in.v5d/binio.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@ extern void flip4(const unsigned int *src, unsigned int *dest, int n);

extern void flip2(const unsigned short *src, unsigned short *dest, int n);

#ifdef _CRAY
extern void cray_to_ieee_array(long *dest, const float *source, int n);
extern void ieee_to_cray_array(float *dest, const long *source, int n);
#endif

/**********************************************************************/

/***** Read Functions *****/
Expand Down
81 changes: 0 additions & 81 deletions raster3d/r3.in.v5d/v5d.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,6 @@
* values are in IEEE format.
*/

/*
* Updates:
*
* April 13, 1995, brianp
* finished Cray support for 2-byte and 4-byte compress modes
*/

#include <grass/config.h>
#include <assert.h>
#include <stdio.h>
Expand Down Expand Up @@ -721,21 +714,6 @@ void v5dCompressGrid(int nr, int nc, int nl, int compressmode,
else {
one_over_a = 1.0 / ga[lev];
}
#ifdef _CRAY
/* this is tricky because sizeof(V5Dushort)==8, not 2 */
for (i = 0; i < nrnc; i++, p++) {
V5Dushort compvalue;

if (IS_MISSING(data[p])) {
compvalue = 65535;
}
else {
compvalue = (V5Dushort)(int)((data[p] - b) * one_over_a);
}
compdata1[p * 2 + 0] = compvalue >> 8; /* upper byte */
compdata1[p * 2 + 1] = compvalue & 0xffu; /* lower byte */
}
#else
for (i = 0; i < nrnc; i++, p++) {
if (IS_MISSING(data[p])) {
compdata2[p] = 65535;
Expand All @@ -745,20 +723,14 @@ void v5dCompressGrid(int nr, int nc, int nl, int compressmode,
}
}
/* TODO: byte-swapping on little endian??? */
#endif
}
}

else {
/* compressmode==4 */
#ifdef _CRAY
cray_to_ieee_array(compdata, data, nrncnl);
#else
/* other machines: just copy 4-byte IEEE floats */
assert(sizeof(float) == 4);
memcpy(compdata, data, nrncnl * 4);
/* TODO: byte-swapping on little endian??? */
#endif
}
}

Expand Down Expand Up @@ -834,20 +806,6 @@ void v5dDecompressGrid(int nr, int nc, int nl, int compressmode, void *compdata,
float a = ga[lev];
float b = gb[lev];

#ifdef _CRAY
/* this is tricky because sizeof(V5Dushort)==8, not 2 */
for (i = 0; i < nrnc; i++, p++) {
int compvalue;

compvalue = (compdata1[p * 2] << 8) | compdata1[p * 2 + 1];
if (compvalue == 65535) {
data[p] = MISSING;
}
else {
data[p] = (float)compvalue * a + b;
}
}
#else
/* sizeof(V5Dushort)==2! */
for (i = 0; i < nrnc; i++, p++) {
if (compdata2[p] == 65535) {
Expand All @@ -857,19 +815,13 @@ void v5dDecompressGrid(int nr, int nc, int nl, int compressmode, void *compdata,
data[p] = (float)(int)compdata2[p] * a + b;
}
}
#endif
}
}

else {
/* compressmode==4 */
#ifdef _CRAY
ieee_to_cray_array(data, compdata, nrncnl);
#else
/* other machines: just copy 4-byte IEEE floats */
assert(sizeof(float) == 4);
memcpy(data, compdata, nrncnl * 4);
#endif
}
}

Expand Down Expand Up @@ -2720,11 +2672,7 @@ int v5dClose(void)
#ifdef UNDERSCORE
int v5dcreate_
#else
#ifdef _CRAY
int V5DCREATE
#else
int v5dcreate
#endif
#endif

(const char *name, const int *numtimes, const int *numvars, const int *nr,
Expand Down Expand Up @@ -2883,11 +2831,7 @@ int v5dcreate
#ifdef UNDERSCORE
int v5dcreatesimple_
#else
#ifdef _CRAY
int V5DCREATESIMPLE
#else
int v5dcreatesimple
#endif
#endif

(const char *name, const int *numtimes, const int *numvars, const int *nr,
Expand Down Expand Up @@ -2920,12 +2864,7 @@ int v5dcreatesimple
#ifdef UNDERSCORE
return v5dcreate_
#else
#ifdef _CRAY
return V5DCREATE
#else

return v5dcreate
#endif
#endif
(name, numtimes, numvars, nr, nc, varnl, varname, timestamp, datestamp,
&compressmode, &projection, projarg, &vertical, vertarg);
Expand All @@ -2939,11 +2878,7 @@ int v5dcreatesimple
#ifdef UNDERSCORE
int v5dsetlowlev_
#else
#ifdef _CRAY
int V5DSETLOWLEV
#else
int v5dsetlowlev
#endif
#endif
(int *lowlev)
{
Expand All @@ -2959,11 +2894,7 @@ int v5dsetlowlev
#ifdef UNDERSCORE
int v5dsetunits_
#else
#ifdef _CRAY
int V5DSETUNITS
#else
int v5dsetunits
#endif
#endif
(int *var, char *name)
{
Expand All @@ -2980,11 +2911,7 @@ int v5dsetunits
#ifdef UNDERSCORE
int v5dwrite_
#else
#ifdef _CRAY
int V5DWRITE
#else
int v5dwrite
#endif
#endif
(const int *time, const int *var, const float *data)
{
Expand All @@ -3001,11 +2928,7 @@ int v5dwrite
#ifdef UNDERSCORE
int v5dmcfile_
#else
#ifdef _CRAY
int V5DMCFILE
#else
int v5dmcfile
#endif
#endif
(const int *time, const int *var, const int *mcfile, const int *mcgrid)
{
Expand All @@ -3029,12 +2952,8 @@ int v5dmcfile
#ifdef UNDERSCORE
int v5dclose_(void)
#else
#ifdef _CRAY
int V5DCLOSE(void)
#else
int v5dclose(void)
#endif
#endif
{
return v5dClose();
}
4 changes: 2 additions & 2 deletions raster3d/r3.in.v5d/v5d.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
* Define our own 1 and 2-byte data types. We use these names to avoid
* collisions with types defined by the OS include files.
*/
typedef unsigned char V5Dubyte; /* Must be 1 byte, except for cray */
typedef unsigned short V5Dushort; /* Must be 2 byte, except for cray */
typedef unsigned char V5Dubyte; /* Must be 1 byte */
typedef unsigned short V5Dushort; /* Must be 2 byte */

#define MISSING 1.0e35
#define IS_MISSING(X) ((X) >= 1.0e30)
Expand Down
Loading

0 comments on commit 8dced26

Please sign in to comment.