From 8f684ad5be2906a0975d245af4e5696328a610bb Mon Sep 17 00:00:00 2001 From: "R. Timothy Edwards" Date: Wed, 25 Feb 2026 09:59:28 -0500 Subject: [PATCH] Found and fixed the actual error underlying the problem with grid rescaling while reading a GDS AREF record. The previous commit is still valid and prevents excessive warnings and unnecessary rescaling when a bogus value is given for an array pitch when the array has only one row or one column. But the scaling was still incorrect and would potentially cause an error if an array pitch was at a finer scale than any data read before it, forcing a valid grid rescaling. This now works correctly. --- VERSION | 2 +- calma/CalmaRdcl.c | 27 ++++++++++++++++++++++----- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/VERSION b/VERSION index 0e7c2dbd..2899557e 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -8.3.607 +8.3.608 diff --git a/calma/CalmaRdcl.c b/calma/CalmaRdcl.c index 15cc4531..016d6a62 100644 --- a/calma/CalmaRdcl.c +++ b/calma/CalmaRdcl.c @@ -1002,7 +1002,7 @@ calmaElementSref( for (n = 0; n < nref; n++) { - savescale = cifCurReadStyle->crs_scaleFactor; + savescale = calmaReadScale1; /* If there is only one column, then X data in the 2nd or 3rd * entry is irrelevant. If there is only one row, then Y data @@ -1010,6 +1010,7 @@ calmaElementSref( * by incorrect/uninitialized data in these positions by ignoring * them as needed. */ + if ((n > 0) && (rows == 1)) { calmaReadX(&refarray[n], 1); @@ -1023,11 +1024,30 @@ calmaElementSref( refarray[n].p_x = 0; } else - { calmaReadPoint(&refarray[n], 1); + + if (savescale != calmaReadScale1) + { + /* Scale changed, so update previous points read */ + int newscale = calmaReadScale1 / savescale; + for (i = 0; i < n; i++) + { + refarray[i].p_x *= newscale; + refarray[i].p_y *= newscale; + } } + if (FEOF(calmaInputFile)) + return -1; + } + + for (n = 0; n < nref; n++) refunscaled[n] = refarray[n]; // Save for CDFLATGDS cells + + for (n = 0; n < nref; n++) + { + savescale = cifCurReadStyle->crs_scaleFactor; + refarray[n].p_x = CIFScaleCoord(refarray[n].p_x, COORD_EXACT); if (savescale != cifCurReadStyle->crs_scaleFactor) { @@ -1048,9 +1068,6 @@ calmaElementSref( } refarray[n].p_x *= (savescale / cifCurReadStyle->crs_scaleFactor); } - - if (FEOF(calmaInputFile)) - return -1; } /* Skip remainder */