diff --git a/.flake8 b/.flake8 index a44d0182e5f..45792c60cf7 100644 --- a/.flake8 +++ b/.flake8 @@ -74,7 +74,6 @@ per-file-ignores = python/grass/temporal/temporal_algebra.py: E722 python/grass/temporal/temporal_granularity.py: E722 python/grass/temporal/temporal_raster_base_algebra.py: E722 - python/grass/temporal/temporal_topology_dataset_connector.py: E722 # Current benchmarks/tests are changing sys.path before import. # Possibly, a different approach should be taken there anyway. python/grass/pygrass/tests/benchmark.py: E402, F821 diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index d98950b0818..a31f5176124 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -56,7 +56,7 @@ jobs: if: ${{ matrix.language == 'c-cpp' }} - name: Initialize CodeQL - uses: github/codeql-action/init@662472033e021d55d94146f66f6058822b0b39fd # v3.27.0 + uses: github/codeql-action/init@4f3212b61783c3c68e8309a0f18a699764811cda # v3.27.1 with: languages: ${{ matrix.language }} config-file: ./.github/codeql/codeql-config.yml @@ -81,6 +81,6 @@ jobs: run: .github/workflows/build_ubuntu-22.04.sh "${HOME}/install" - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@662472033e021d55d94146f66f6058822b0b39fd # v3.27.0 + uses: github/codeql-action/analyze@4f3212b61783c3c68e8309a0f18a699764811cda # v3.27.1 with: category: "/language:${{matrix.language}}" diff --git a/.github/workflows/python-code-quality.yml b/.github/workflows/python-code-quality.yml index 418af0ceffe..e1676d179fa 100644 --- a/.github/workflows/python-code-quality.yml +++ b/.github/workflows/python-code-quality.yml @@ -135,7 +135,7 @@ jobs: path: bandit.sarif - name: Upload SARIF File into Security Tab - uses: github/codeql-action/upload-sarif@662472033e021d55d94146f66f6058822b0b39fd # v3.27.0 + uses: github/codeql-action/upload-sarif@4f3212b61783c3c68e8309a0f18a699764811cda # v3.27.1 with: sarif_file: bandit.sarif diff --git a/imagery/i.vi/main.c b/imagery/i.vi/main.c index dd1ceb8d6cf..7947aee6c50 100644 --- a/imagery/i.vi/main.c +++ b/imagery/i.vi/main.c @@ -593,6 +593,16 @@ int main(int argc, char *argv[]) else G_fatal_error(_("Unknown color request '%s'"), style); } + else if (!strcasecmp(viflag, "ndwi")) { + /* apply predefined NDWI color table */ + const char *style = "ndwi"; + + if (G_find_color_rule("ndwi")) { + Rast_make_fp_colors(&colors, style, -1.0, 1.0); + } + else + G_fatal_error(_("Unknown color request '%s'"), style); + } else { /* Color from -1.0 to +1.0 in grey */ Rast_init_colors(&colors); diff --git a/lib/Makefile b/lib/Makefile index a313a656f36..91c38f5c73b 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -4,11 +4,11 @@ include $(MODULE_TOPDIR)/include/Make/Vars.make #order is relevant: SUBDIRS = \ + external \ datetime \ gis \ proj \ raster \ - external \ gmath \ linkm \ driver \ diff --git a/lib/gis/file_name.c b/lib/gis/file_name.c index 7bf7b9d2539..a3e7bd5d786 100644 --- a/lib/gis/file_name.c +++ b/lib/gis/file_name.c @@ -161,13 +161,13 @@ char *file_name(char *path, const char *dir, const char *element, const char *name, const char *mapset, const char *base) { const char *pname = name; + char xname[GNAME_MAX] = {'\0'}; if (base && *base) { sprintf(path, "%s", base); } else { - char xname[GNAME_MAX]; - char xmapset[GMAPSET_MAX]; + char xmapset[GMAPSET_MAX] = {'\0'}; char *location = G__location_path(); /* diff --git a/python/grass/temporal/temporal_topology_dataset_connector.py b/python/grass/temporal/temporal_topology_dataset_connector.py index fddf478ad71..a296d9d4d78 100644 --- a/python/grass/temporal/temporal_topology_dataset_connector.py +++ b/python/grass/temporal/temporal_topology_dataset_connector.py @@ -160,47 +160,47 @@ def get_number_of_temporal_relations(self): relations = {} try: relations["equal"] = len(self._temporal_topology["EQUAL"]) - except: + except KeyError: relations["equal"] = 0 try: relations["follows"] = len(self._temporal_topology["FOLLOWS"]) - except: + except KeyError: relations["follows"] = 0 try: relations["precedes"] = len(self._temporal_topology["PRECEDES"]) - except: + except KeyError: relations["precedes"] = 0 try: relations["overlaps"] = len(self._temporal_topology["OVERLAPS"]) - except: + except KeyError: relations["overlaps"] = 0 try: relations["overlapped"] = len(self._temporal_topology["OVERLAPPED"]) - except: + except KeyError: relations["overlapped"] = 0 try: relations["during"] = len(self._temporal_topology["DURING"]) - except: + except KeyError: relations["during"] = 0 try: relations["contains"] = len(self._temporal_topology["CONTAINS"]) - except: + except KeyError: relations["contains"] = 0 try: relations["starts"] = len(self._temporal_topology["STARTS"]) - except: + except KeyError: relations["starts"] = 0 try: relations["started"] = len(self._temporal_topology["STARTED"]) - except: + except KeyError: relations["started"] = 0 try: relations["finishes"] = len(self._temporal_topology["FINISHES"]) - except: + except KeyError: relations["finishes"] = 0 try: relations["finished"] = len(self._temporal_topology["FINISHED"]) - except: + except KeyError: relations["finished"] = 0 return relations diff --git a/raster/r.circle/testsuite/test_circle.py b/raster/r.circle/testsuite/test_circle.py new file mode 100644 index 00000000000..1c0a4b62f54 --- /dev/null +++ b/raster/r.circle/testsuite/test_circle.py @@ -0,0 +1,85 @@ +from grass.gunittest.case import TestCase +from grass.gunittest.main import test +import grass.script as gs +from grass.gunittest.gmodules import SimpleModule + + +class TestRCircle(TestCase): + + @classmethod + def setUpClass(cls): + """Set up a temporary region for testing.""" + cls.output = "test_circle" + cls.use_temp_region() + cls.runModule("g.region", n=30, s=0, e=30, w=0, res=10) + + @classmethod + def tearDownClass(cls): + """Clean up after tests.""" + cls.del_temp_region() + + def tearDown(self): + gs.run_command( + "g.remove", + type="raster", + name=self.output, + flags="f", + ) + + def test_create_circle_with_b_flag(self): + """Test creating a binary circle with r.circle using -b flag.""" + + module = SimpleModule( + "r.circle", output=self.output, coordinates=(15, 15), max=10, flags="b" + ) + + self.assertModule(module) + + self.assertRasterExists(self.output) + + self.assertRasterMinMax( + map=self.output, + refmin=1, + refmax=1, + msg="Binary circle should have category value of 1", + ) + + def test_create_circle_without_b_flag(self): + """Test creating a circle with r.circle without -b flag.""" + + module = SimpleModule( + "r.circle", output=self.output, coordinates=(15, 15), max=10 + ) + + self.assertModule(module) + + self.assertRasterExists(self.output) + + self.assertRasterMinMax( + map=self.output, + refmin=0, + refmax=10, + msg="Circle should have distance values from 0 to 10", + ) + + def test_create_circle_with_multiplier(self): + """Test creating a circle with r.circle with a multiplier.""" + + module = SimpleModule( + "r.circle", output=self.output, coordinates=(15, 15), max=10, multiplier=2 + ) + + self.assertModule(module) + + self.assertRasterExists(self.output) + + self.assertRasterMinMax( + map=self.output, + refmin=0, + refmax=20, + msg="Circle should have distance values from 0 to 20", + ) + + +if __name__ == "__main__": + test() diff --git a/raster3d/r3.in.v5d/binio.c b/raster3d/r3.in.v5d/binio.c index b47723a2929..98cf70a9fdd 100644 --- a/raster3d/r3.in.v5d/binio.c +++ b/raster3d/r3.in.v5d/binio.c @@ -32,26 +32,11 @@ * If an ANSI compiler is used prototypes and ANSI function declarations * are used. Otherwise use K&R conventions. * - * If we're running on a CRAY (8-byte ints and floats), conversions will - * be done as needed. - */ - -/* - * Updates: - * - * April 13, 1995, brianp - * added cray_to_ieee and iee_to_cray array conversion functions. - * fixed potential cray bug in write_float4_array function. - * */ #include #include #include -#ifdef _CRAY -#include -#include -#endif #include "binio.h" /**********************************************************************/ @@ -94,132 +79,6 @@ void flip2(const unsigned short *src, unsigned short *dest, int n) } } -#ifdef _CRAY - -/***************************************************************************** - * - * The following source code is in the public domain. - * Specifically, we give to the public domain all rights for future licensing - * of the source code, all resale rights, and all publishing rights. - * - * We ask, but do not require, that the following message be included in all - * derived works: - * - * Portions developed at the National Center for Supercomputing Applications at - * the University of Illinois at Urbana-Champaign. - * - * THE UNIVERSITY OF ILLINOIS GIVES NO WARRANTY, EXPRESSED OR IMPLIED, FOR THE - * SOFTWARE AND/OR DOCUMENTATION PROVIDED, INCLUDING, WITHOUT LIMITATION, - * WARRANTY OF MERCHANTABILITY AND WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE - * - ****************************************************************************/ - -/** THESE ROUTINES MUST BE COMPILED ON THE CRAY ONLY SINCE THEY **/ - -/** REQUIRE 8-BYTES PER C-TYPE LONG **/ - -/* Cray to IEEE single precision */ -static void c_to_if(long *t, const long *f) -{ - if (*f != 0) { - *t = (((*f & 0x8000000000000000) | /* sign bit */ - ((((*f & 0x7fff000000000000) >> 48) - 16258) << 55)) + /* exp */ - (((*f & 0x00007fffff000000) + ((*f & 0x0000000000800000) << 1)) - << 8)); /* mantissa */ - } - else - *t = *f; -} - -#define C_TO_IF(T, F) \ - if (F != 0) { \ - T = (((F & 0x8000000000000000) | \ - ((((F & 0x7fff000000000000) >> 48) - 16258) << 55)) + \ - (((F & 0x00007fffff000000) + ((F & 0x0000000000800000) << 1)) \ - << 8)); \ - } \ - else { \ - T = F; \ - } - -/* IEEE single precision to Cray */ -static void if_to_c(long *t, const long *f) -{ - if (*f != 0) { - *t = (((*f & 0x8000000000000000) | - ((*f & 0x7f80000000000000) >> 7) + (16258L << 48)) | - (((*f & 0x007fffff00000000) >> 8) | (0x0000800000000000))); - if ((*f << 1) == 0) - *t = 0; - } - else - *t = *f; -} - -/* T and F must be longs! */ -#define IF_TO_C(T, F) \ - if (F != 0) { \ - T = (((F & 0x8000000000000000) | \ - ((F & 0x7f80000000000000) >> 7) + (16258L << 48)) | \ - (((F & 0x007fffff00000000) >> 8) | (0x0000800000000000))); \ - if ((F << 1) == 0) \ - T = 0; \ - } \ - else { \ - T = F; \ - } - -/* - * Convert an array of Cray 8-byte floats to an array of IEEE 4-byte floats. - */ -void cray_to_ieee_array(long *dest, const float *source, int n) -{ - long *dst; - const long *src; - long tmp1, tmp2; - int i; - - dst = dest; - src = (const long *)source; - - for (i = 0; i < n; i += 2) { /* add 1 in case n is odd */ - c_to_if(&tmp1, &src[i]); - c_to_if(&tmp2, &src[i + 1]); - *dst = (tmp1 & 0xffffffff00000000) | (tmp2 >> 32); - dst++; - } -} - -/* - * Convert an array of IEEE 4-byte floats to an array of 8-byte Cray floats. - */ -void ieee_to_cray_array(float *dest, const long *source, int n) -{ - long *dst; - const long *src; - int i; - long ieee; - - src = source; - dst = (long *)dest; - - for (i = 0; i < n; i++) { - /* most significant 4-bytes of ieee contain bit pattern to convert */ - if ((i & 1) == 0) { - /* get upper half */ - ieee = src[i / 2] & 0xffffffff00000000; - } - else { - /* get lower half */ - ieee = src[i / 2] << 32; - } - if_to_c(dst, &ieee); - dst++; - } -} - -#endif /*_CRAY*/ - /**********************************************************************/ /***** Read Functions *****/ @@ -247,25 +106,6 @@ int read_bytes(int f, void *b, int n) */ int read_int2_array(int f, short *iarray, int n) { -#ifdef _CRAY - int i; - signed char *buffer; - int nread; - - buffer = (signed char *)G_malloc(n * 2); - if (!buffer) - return 0; - nread = read(f, buffer, n * 2); - if (nread <= 0) - return 0; - nread /= 2; - for (i = 0; i < nread; i++) { - /* don't forget about sign extension! */ - iarray[i] = (buffer[i * 2] * 256) | buffer[i * 2 + 1]; - } - G_free(buffer); - return nread; -#else int nread = read(f, iarray, n * 2); if (nread <= 0) @@ -274,7 +114,6 @@ int read_int2_array(int f, short *iarray, int n) flip2((const unsigned short *)iarray, (unsigned short *)iarray, nread / 2); #endif return nread / 2; -#endif } /* @@ -286,24 +125,6 @@ int read_int2_array(int f, short *iarray, int n) */ int read_uint2_array(int f, unsigned short *iarray, int n) { -#ifdef _CRAY - int i; - unsigned char *buffer; - int nread; - - buffer = (unsigned char *)G_malloc(n * 2); - if (!buffer) - return 0; - nread = read(f, buffer, n * 2); - if (nread <= 0) - return 0; - nread /= 2; - for (i = 0; i < nread; i++) { - iarray[i] = (buffer[i * 2] << 8) | buffer[i * 2 + 1]; - } - G_free(buffer); - return nread; -#else int nread = read(f, iarray, n * 2); if (nread <= 0) @@ -312,7 +133,6 @@ int read_uint2_array(int f, unsigned short *iarray, int n) flip2(iarray, iarray, nread / 2); #endif return nread / 2; -#endif } /* @@ -336,9 +156,6 @@ int read_int4(int f, int *i) } #else if (read(f, i, 4) == 4) { -#ifdef _CRAY - *i = *i >> 32; -#endif return 1; } else { @@ -356,30 +173,6 @@ int read_int4(int f, int *i) */ int read_int4_array(int f, int *iarray, int n) { -#ifdef _CRAY - int j, nread; - int *buffer; - - buffer = (int *)G_malloc((n + 1) * 4); - if (!buffer) - return 0; - nread = read(f, buffer, 4 * n); - if (nread <= 0) { - return 0; - } - nread /= 4; - - for (j = 0; j < nread; j++) { - if ((j & 1) == 0) { - iarray[j] = buffer[j / 2] >> 32; - } - else { - iarray[j] = buffer[j / 2] & 0xffffffff; - } - } - G_free(buffer); - return nread; -#else int nread = read(f, iarray, 4 * n); if (nread <= 0) @@ -388,7 +181,6 @@ int read_int4_array(int f, int *iarray, int n) flip4((const unsigned int *)iarray, (unsigned int *)iarray, nread / 4); #endif return nread / 4; -#endif } /* @@ -399,16 +191,6 @@ int read_int4_array(int f, int *iarray, int n) */ int read_float4(int f, float *x) { -#ifdef _CRAY - long buffer = 0; - - if (read(f, &buffer, 4) == 4) { - /* convert IEEE float (buffer) to Cray float (x) */ - if_to_c((long *)x, &buffer); - return 1; - } - return 0; -#else #ifdef LITTLE unsigned int n, *iptr; @@ -428,7 +210,6 @@ int read_float4(int f, float *x) return 0; } #endif -#endif } /* @@ -440,22 +221,6 @@ int read_float4(int f, float *x) */ int read_float4_array(int f, float *x, int n) { -#ifdef _CRAY - /* read IEEE floats into buffer, then convert to Cray format */ - long *buffer; - int i, nread; - - buffer = (long *)G_malloc((n + 1) * 4); - if (!buffer) - return 0; - nread = read(f, buffer, n * 4); - if (nread <= 0) - return 0; - nread /= 4; - ieee_to_cray_array(x, buffer, nread); - G_free(buffer); - return nread; -#else int nread = read(f, x, 4 * n); if (nread <= 0) @@ -464,7 +229,6 @@ int read_float4_array(int f, float *x, int n) flip4((const unsigned int *)x, (unsigned int *)x, nread / 4); #endif return nread / 4; -#endif } /* @@ -541,10 +305,6 @@ int write_bytes(int f, const void *b, int n) */ int write_int2_array(int f, const short *iarray, int n) { -#ifdef _CRAY - printf("write_int2_array not implemented!\n"); - exit(1); -#else int nwritten; #ifdef LITTLE @@ -557,7 +317,6 @@ int write_int2_array(int f, const short *iarray, int n) if (nwritten <= 0) return 0; return nwritten / 2; -#endif } /* @@ -569,24 +328,6 @@ int write_int2_array(int f, const short *iarray, int n) */ int write_uint2_array(int f, const unsigned short *iarray, int n) { -#ifdef _CRAY - int i, nwritten; - unsigned char *buffer; - - buffer = (unsigned char *)G_malloc(2 * n); - if (!buffer) - return 0; - for (i = 0; i < n; i++) { - buffer[i * 2] = (iarray[i] >> 8) & 0xff; - buffer[i * 2 + 1] = iarray[i] & 0xff; - } - nwritten = write(f, buffer, 2 * n); - G_free(buffer); - if (nwritten <= 0) - return 0; - else - return nwritten / 2; -#else int nwritten; #ifdef LITTLE @@ -600,7 +341,6 @@ int write_uint2_array(int f, const unsigned short *iarray, int n) return 0; else return nwritten / 2; -#endif } /* @@ -611,15 +351,10 @@ int write_uint2_array(int f, const unsigned short *iarray, int n) */ int write_int4(int f, int i) { -#ifdef _CRAY - i = i << 32; - return write(f, &i, 4) > 0; -#else #ifdef LITTLE i = FLIP4(i); #endif return write(f, &i, 4) > 0; -#endif } /* @@ -631,28 +366,6 @@ int write_int4(int f, int i) */ int write_int4_array(int f, const int *i, int n) { -#ifdef _CRAY - int j, nwritten; - char *buf, *b, *ptr; - - b = buf = (char *)G_malloc(n * 4 + 8); - if (!b) - return 0; - ptr = (char *)i; - for (j = 0; j < n; j++) { - ptr += 4; /* skip upper 4 bytes */ - *b++ = *ptr++; - *b++ = *ptr++; - *b++ = *ptr++; - *b++ = *ptr++; - } - nwritten = write(f, buf, 4 * n); - G_free(buf); - if (nwritten <= 0) - return 0; - else - return nwritten / 4; -#else #ifdef LITTLE int nwritten; @@ -666,7 +379,6 @@ int write_int4_array(int f, const int *i, int n) #else return write(f, i, 4 * n) / 4; #endif -#endif } /* @@ -677,12 +389,6 @@ int write_int4_array(int f, const int *i, int n) */ int write_float4(int f, float x) { -#ifdef _CRAY - char buffer[8]; - - c_to_if((long *)buffer, (const long *)&x); - return write(f, buffer, 4) > 0; -#else #ifdef LITTLE float y; unsigned int *iptr = (unsigned int *)&y, temp; @@ -696,7 +402,6 @@ int write_float4(int f, float x) y = (float)x; return write(f, &y, 4) > 0; #endif -#endif } /* @@ -708,22 +413,6 @@ int write_float4(int f, float x) */ int write_float4_array(int f, const float *x, int n) { -#ifdef _CRAY - /* convert cray floats to IEEE and put into buffer */ - int nwritten; - long *buffer; - - buffer = (long *)G_malloc(n * 4 + 8); - if (!buffer) - return 0; - cray_to_ieee_array(buffer, x, n); - nwritten = write(f, buffer, 4 * n); - G_free(buffer); - if (nwritten <= 0) - return 0; - else - return nwritten / 4; -#else #ifdef LITTLE int nwritten; @@ -737,7 +426,6 @@ int write_float4_array(int f, const float *x, int n) #else return write(f, x, 4 * n) / 4; #endif -#endif } /* diff --git a/raster3d/r3.in.v5d/binio.h b/raster3d/r3.in.v5d/binio.h index f987e3cf64b..e6a80d8a9db 100644 --- a/raster3d/r3.in.v5d/binio.h +++ b/raster3d/r3.in.v5d/binio.h @@ -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 *****/ diff --git a/raster3d/r3.in.v5d/v5d.c b/raster3d/r3.in.v5d/v5d.c index 54f75f2361a..ef9f7487ae3 100644 --- a/raster3d/r3.in.v5d/v5d.c +++ b/raster3d/r3.in.v5d/v5d.c @@ -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 #include #include @@ -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; @@ -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 } } @@ -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) { @@ -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 } } @@ -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, @@ -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, @@ -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); @@ -2939,11 +2878,7 @@ int v5dcreatesimple #ifdef UNDERSCORE int v5dsetlowlev_ #else -#ifdef _CRAY -int V5DSETLOWLEV -#else int v5dsetlowlev -#endif #endif (int *lowlev) { @@ -2959,11 +2894,7 @@ int v5dsetlowlev #ifdef UNDERSCORE int v5dsetunits_ #else -#ifdef _CRAY -int V5DSETUNITS -#else int v5dsetunits -#endif #endif (int *var, char *name) { @@ -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) { @@ -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) { @@ -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(); } diff --git a/raster3d/r3.in.v5d/v5d.h b/raster3d/r3.in.v5d/v5d.h index 49a604416fa..b2c985dca12 100644 --- a/raster3d/r3.in.v5d/v5d.h +++ b/raster3d/r3.in.v5d/v5d.h @@ -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) diff --git a/raster3d/r3.out.v5d/binio.c b/raster3d/r3.out.v5d/binio.c index f8582e97313..98cf70a9fdd 100644 --- a/raster3d/r3.out.v5d/binio.c +++ b/raster3d/r3.out.v5d/binio.c @@ -32,26 +32,11 @@ * If an ANSI compiler is used prototypes and ANSI function declarations * are used. Otherwise use K&R conventions. * - * If we're running on a CRAY (8-byte ints and floats), conversions will - * be done as needed. - */ - -/* - * Updates: - * - * April 13, 1995, brianp - * added cray_to_ieee and iee_to_cray array conversion functions. - * fixed potential cray bug in write_float4_array function. - * */ #include #include #include -#ifdef _CRAY -#include -#include -#endif #include "binio.h" /**********************************************************************/ @@ -94,132 +79,6 @@ void flip2(const unsigned short *src, unsigned short *dest, int n) } } -#ifdef _CRAY - -/***************************************************************************** - * - * The following source code is in the public domain. - * Specifically, we give to the public domain all rights for future licensing - * of the source code, all resale rights, and all publishing rights. - * - * We ask, but do not require, that the following message be included in all - * derived works: - * - * Portions developed at the National Center for Supercomputing Applications at - * the University of Illinois at Urbana-Champaign. - * - * THE UNIVERSITY OF ILLINOIS GIVES NO WARRANTY, EXPRESSED OR IMPLIED, FOR THE - * SOFTWARE AND/OR DOCUMENTATION PROVIDED, INCLUDING, WITHOUT LIMITATION, - * WARRANTY OF MERCHANTABILITY AND WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE - * - ****************************************************************************/ - -/** THESE ROUTINES MUST BE COMPILED ON THE CRAY ONLY SINCE THEY **/ - -/** REQUIRE 8-BYTES PER C-TYPE LONG **/ - -/* Cray to IEEE single precision */ -static void c_to_if(long *t, const long *f) -{ - if (*f != 0) { - *t = (((*f & 0x8000000000000000) | /* sign bit */ - ((((*f & 0x7fff000000000000) >> 48) - 16258) << 55)) + /* exp */ - (((*f & 0x00007fffff000000) + ((*f & 0x0000000000800000) << 1)) - << 8)); /* mantissa */ - } - else - *t = *f; -} - -#define C_TO_IF(T, F) \ - if (F != 0) { \ - T = (((F & 0x8000000000000000) | \ - ((((F & 0x7fff000000000000) >> 48) - 16258) << 55)) + \ - (((F & 0x00007fffff000000) + ((F & 0x0000000000800000) << 1)) \ - << 8)); \ - } \ - else { \ - T = F; \ - } - -/* IEEE single precision to Cray */ -static void if_to_c(long *t, const long *f) -{ - if (*f != 0) { - *t = (((*f & 0x8000000000000000) | - ((*f & 0x7f80000000000000) >> 7) + (16258 << 48)) | - (((*f & 0x007fffff00000000) >> 8) | (0x0000800000000000))); - if ((*f << 1) == 0) - *t = 0; - } - else - *t = *f; -} - -/* T and F must be longs! */ -#define IF_TO_C(T, F) \ - if (F != 0) { \ - T = (((F & 0x8000000000000000) | \ - ((F & 0x7f80000000000000) >> 7) + (16258 << 48)) | \ - (((F & 0x007fffff00000000) >> 8) | (0x0000800000000000))); \ - if ((F << 1) == 0) \ - T = 0; \ - } \ - else { \ - T = F; \ - } - -/* - * Convert an array of Cray 8-byte floats to an array of IEEE 4-byte floats. - */ -void cray_to_ieee_array(long *dest, const float *source, int n) -{ - long *dst; - const long *src; - long tmp1, tmp2; - int i; - - dst = dest; - src = (const long *)source; - - for (i = 0; i < n; i += 2) { /* add 1 in case n is odd */ - c_to_if(&tmp1, &src[i]); - c_to_if(&tmp2, &src[i + 1]); - *dst = (tmp1 & 0xffffffff00000000) | (tmp2 >> 32); - dst++; - } -} - -/* - * Convert an array of IEEE 4-byte floats to an array of 8-byte Cray floats. - */ -void ieee_to_cray_array(float *dest, const long *source, int n) -{ - long *dst; - const long *src; - int i; - long ieee; - - src = source; - dst = (long *)dest; - - for (i = 0; i < n; i++) { - /* most significant 4-bytes of ieee contain bit pattern to convert */ - if ((i & 1) == 0) { - /* get upper half */ - ieee = src[i / 2] & 0xffffffff00000000; - } - else { - /* get lower half */ - ieee = src[i / 2] << 32; - } - if_to_c(dst, &ieee); - dst++; - } -} - -#endif /*_CRAY*/ - /**********************************************************************/ /***** Read Functions *****/ @@ -247,25 +106,6 @@ int read_bytes(int f, void *b, int n) */ int read_int2_array(int f, short *iarray, int n) { -#ifdef _CRAY - int i; - signed char *buffer; - int nread; - - buffer = (signed char *)G_malloc(n * 2); - if (!buffer) - return 0; - nread = read(f, buffer, n * 2); - if (nread <= 0) - return 0; - nread /= 2; - for (i = 0; i < nread; i++) { - /* don't forget about sign extension! */ - iarray[i] = (buffer[i * 2] * 256) | buffer[i * 2 + 1]; - } - G_free(buffer); - return nread; -#else int nread = read(f, iarray, n * 2); if (nread <= 0) @@ -274,7 +114,6 @@ int read_int2_array(int f, short *iarray, int n) flip2((const unsigned short *)iarray, (unsigned short *)iarray, nread / 2); #endif return nread / 2; -#endif } /* @@ -286,24 +125,6 @@ int read_int2_array(int f, short *iarray, int n) */ int read_uint2_array(int f, unsigned short *iarray, int n) { -#ifdef _CRAY - int i; - unsigned char *buffer; - int nread; - - buffer = (unsigned char *)G_malloc(n * 2); - if (!buffer) - return 0; - nread = read(f, buffer, n * 2); - if (nread <= 0) - return 0; - nread /= 2; - for (i = 0; i < nread; i++) { - iarray[i] = (buffer[i * 2] << 8) | buffer[i * 2 + 1]; - } - G_free(buffer); - return nread; -#else int nread = read(f, iarray, n * 2); if (nread <= 0) @@ -312,7 +133,6 @@ int read_uint2_array(int f, unsigned short *iarray, int n) flip2(iarray, iarray, nread / 2); #endif return nread / 2; -#endif } /* @@ -336,9 +156,6 @@ int read_int4(int f, int *i) } #else if (read(f, i, 4) == 4) { -#ifdef _CRAY - *i = *i >> 32; -#endif return 1; } else { @@ -356,30 +173,6 @@ int read_int4(int f, int *i) */ int read_int4_array(int f, int *iarray, int n) { -#ifdef _CRAY - int j, nread; - int *buffer; - - buffer = (int *)G_malloc((n + 1) * 4); - if (!buffer) - return 0; - nread = read(f, buffer, 4 * n); - if (nread <= 0) { - return 0; - } - nread /= 4; - - for (j = 0; j < nread; j++) { - if ((j & 1) == 0) { - iarray[j] = buffer[j / 2] >> 32; - } - else { - iarray[j] = buffer[j / 2] & 0xffffffff; - } - } - G_free(buffer); - return nread; -#else int nread = read(f, iarray, 4 * n); if (nread <= 0) @@ -388,7 +181,6 @@ int read_int4_array(int f, int *iarray, int n) flip4((const unsigned int *)iarray, (unsigned int *)iarray, nread / 4); #endif return nread / 4; -#endif } /* @@ -399,16 +191,6 @@ int read_int4_array(int f, int *iarray, int n) */ int read_float4(int f, float *x) { -#ifdef _CRAY - long buffer = 0; - - if (read(f, &buffer, 4) == 4) { - /* convert IEEE float (buffer) to Cray float (x) */ - if_to_c((long *)x, &buffer); - return 1; - } - return 0; -#else #ifdef LITTLE unsigned int n, *iptr; @@ -428,7 +210,6 @@ int read_float4(int f, float *x) return 0; } #endif -#endif } /* @@ -440,22 +221,6 @@ int read_float4(int f, float *x) */ int read_float4_array(int f, float *x, int n) { -#ifdef _CRAY - /* read IEEE floats into buffer, then convert to Cray format */ - long *buffer; - int i, nread; - - buffer = (long *)G_malloc((n + 1) * 4); - if (!buffer) - return 0; - nread = read(f, buffer, n * 4); - if (nread <= 0) - return 0; - nread /= 4; - ieee_to_cray_array(x, buffer, nread); - G_free(buffer); - return nread; -#else int nread = read(f, x, 4 * n); if (nread <= 0) @@ -464,7 +229,6 @@ int read_float4_array(int f, float *x, int n) flip4((const unsigned int *)x, (unsigned int *)x, nread / 4); #endif return nread / 4; -#endif } /* @@ -541,10 +305,6 @@ int write_bytes(int f, const void *b, int n) */ int write_int2_array(int f, const short *iarray, int n) { -#ifdef _CRAY - printf("write_int2_array not implemented!\n"); - exit(1); -#else int nwritten; #ifdef LITTLE @@ -557,7 +317,6 @@ int write_int2_array(int f, const short *iarray, int n) if (nwritten <= 0) return 0; return nwritten / 2; -#endif } /* @@ -569,24 +328,6 @@ int write_int2_array(int f, const short *iarray, int n) */ int write_uint2_array(int f, const unsigned short *iarray, int n) { -#ifdef _CRAY - int i, nwritten; - unsigned char *buffer; - - buffer = (unsigned char *)G_malloc(2 * n); - if (!buffer) - return 0; - for (i = 0; i < n; i++) { - buffer[i * 2] = (iarray[i] >> 8) & 0xff; - buffer[i * 2 + 1] = iarray[i] & 0xff; - } - nwritten = write(f, buffer, 2 * n); - G_free(buffer); - if (nwritten <= 0) - return 0; - else - return nwritten / 2; -#else int nwritten; #ifdef LITTLE @@ -600,7 +341,6 @@ int write_uint2_array(int f, const unsigned short *iarray, int n) return 0; else return nwritten / 2; -#endif } /* @@ -611,15 +351,10 @@ int write_uint2_array(int f, const unsigned short *iarray, int n) */ int write_int4(int f, int i) { -#ifdef _CRAY - i = i << 32; - return write(f, &i, 4) > 0; -#else #ifdef LITTLE i = FLIP4(i); #endif return write(f, &i, 4) > 0; -#endif } /* @@ -631,28 +366,6 @@ int write_int4(int f, int i) */ int write_int4_array(int f, const int *i, int n) { -#ifdef _CRAY - int j, nwritten; - char *buf, *b, *ptr; - - b = buf = (char *)G_malloc(n * 4 + 8); - if (!b) - return 0; - ptr = (char *)i; - for (j = 0; j < n; j++) { - ptr += 4; /* skip upper 4 bytes */ - *b++ = *ptr++; - *b++ = *ptr++; - *b++ = *ptr++; - *b++ = *ptr++; - } - nwritten = write(f, buf, 4 * n); - G_free(buf); - if (nwritten <= 0) - return 0; - else - return nwritten / 4; -#else #ifdef LITTLE int nwritten; @@ -666,7 +379,6 @@ int write_int4_array(int f, const int *i, int n) #else return write(f, i, 4 * n) / 4; #endif -#endif } /* @@ -677,12 +389,6 @@ int write_int4_array(int f, const int *i, int n) */ int write_float4(int f, float x) { -#ifdef _CRAY - char buffer[8]; - - c_to_if((long *)buffer, (const long *)&x); - return write(f, buffer, 4) > 0; -#else #ifdef LITTLE float y; unsigned int *iptr = (unsigned int *)&y, temp; @@ -696,7 +402,6 @@ int write_float4(int f, float x) y = (float)x; return write(f, &y, 4) > 0; #endif -#endif } /* @@ -708,22 +413,6 @@ int write_float4(int f, float x) */ int write_float4_array(int f, const float *x, int n) { -#ifdef _CRAY - /* convert cray floats to IEEE and put into buffer */ - int nwritten; - long *buffer; - - buffer = (long *)G_malloc(n * 4 + 8); - if (!buffer) - return 0; - cray_to_ieee_array(buffer, x, n); - nwritten = write(f, buffer, 4 * n); - G_free(buffer); - if (nwritten <= 0) - return 0; - else - return nwritten / 4; -#else #ifdef LITTLE int nwritten; @@ -737,7 +426,6 @@ int write_float4_array(int f, const float *x, int n) #else return write(f, x, 4 * n) / 4; #endif -#endif } /* diff --git a/raster3d/r3.out.v5d/binio.h b/raster3d/r3.out.v5d/binio.h index f987e3cf64b..e6a80d8a9db 100644 --- a/raster3d/r3.out.v5d/binio.h +++ b/raster3d/r3.out.v5d/binio.h @@ -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 *****/ diff --git a/raster3d/r3.out.v5d/v5d.c b/raster3d/r3.out.v5d/v5d.c index a68fe75928e..f44bbc1a86a 100644 --- a/raster3d/r3.out.v5d/v5d.c +++ b/raster3d/r3.out.v5d/v5d.c @@ -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 #include #include @@ -719,21 +712,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; @@ -743,20 +721,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 } } @@ -832,20 +804,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) { @@ -855,19 +813,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 } } @@ -2687,11 +2639,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, @@ -2850,11 +2798,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, @@ -2887,12 +2831,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); @@ -2906,11 +2845,7 @@ int v5dcreatesimple #ifdef UNDERSCORE int v5dsetlowlev_ #else -#ifdef _CRAY -int V5DSETLOWLEV -#else int v5dsetlowlev -#endif #endif (int *lowlev) { @@ -2926,11 +2861,7 @@ int v5dsetlowlev #ifdef UNDERSCORE int v5dsetunits_ #else -#ifdef _CRAY -int V5DSETUNITS -#else int v5dsetunits -#endif #endif (int *var, char *name) { @@ -2947,11 +2878,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) { @@ -2968,11 +2895,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) { @@ -2996,12 +2919,8 @@ int v5dmcfile #ifdef UNDERSCORE int v5dclose_(void) #else -#ifdef _CRAY -int V5DCLOSE(void) -#else int v5dclose(void) #endif -#endif { return v5dClose(); } diff --git a/raster3d/r3.out.v5d/v5d.h b/raster3d/r3.out.v5d/v5d.h index b7675d8b501..d027d85011d 100644 --- a/raster3d/r3.out.v5d/v5d.h +++ b/raster3d/r3.out.v5d/v5d.h @@ -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) diff --git a/vector/v.rectify/v.rectify.html b/vector/v.rectify/v.rectify.html index 6bfb8e628bf..a90eefef229 100644 --- a/vector/v.rectify/v.rectify.html +++ b/vector/v.rectify/v.rectify.html @@ -46,11 +46,12 @@

Coordinate transformation and RMSE

The desired order of transformation (1, 2, or 3) is selected with the order option. -v.rectify will calculate the RMSE if the -r flag is -given and print out statistcs in tabular format. The last row gives a -summary with the first column holding the number of active points, -followed by average deviations for each dimension and both forward and -backward transformation and finally forward and backward overall RMSE. +If the -r flag is given, v.rectify will calculate the +Root Mean Square Error (RMSE) and print out statistics in tabular format. +The last row gives a summary with the first column holding the number of +active points, followed by average deviations for each dimension and both +forward and backward transformation and finally forward and backward +overall RMSE.

2D linear affine transformation (1st order transformation)