This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.
Hi Gus, Sorry for taking so long to respond to your comment and bug fix. > The large file test program in nc_test/large_file.c seems to have a bug. > The "int n" number used to provide data via cast to signed char > overflows the integer range. > > The value of n grows up to the product of: > > NUMRECS+1 = 1+1 > I_LEN+1 = 4104+1 > J_LEN+1 = 1023+1 > K_LEN+1 = 1023+1 > > which is a number beyond the maximum "int" value of 2147438648. > > I am not a C programmer, but I would guess also > that casting integer values above the range of signed > char [-128,127], or unsigned values in the range [0,255] > is not guaranteed to be supported by all compilers. > > I am building NetCDF4 on Linux x86_64. > Somehow the Gnu gfortran and Intel icc compile > the original code and run without problems. > However, PGI pgcc breaks down there. > > Here is a patch that I applied to that file which removes the overflow, > and reduces the integer "n" to range [0,255] to use the cast > (signed char) n. > With this patch the test program works in pgcc. > > ##################################### > > 129c129,131 > < var1[j][k] = n++; > --- > > var1[j][k] = (signed char) n; > > n++; > > n %= 255; > 171a174 > > n %= 255; Thanks, I've incorporated a fix into our upcoming snapshot release, and it should appear in the 4.1.2 release. --Russ Russ Rew UCAR Unidata Program address@hidden http://www.unidata.ucar.edu Ticket Details =================== Ticket ID: IRQ-325570 Department: Support netCDF Priority: Critical Status: Closed