[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Netcdf data corruption after redef. address@hidden
- Subject: Netcdf data corruption after redef. address@hidden
- Date: Fri, 23 Apr 1999 17:29:06 -0600
Gentlemen:
You have reported problems with netcdf data corruption after
calling nc_redef/nc_endef.
Attached find a patch which I hope fixes the problem.
Please let me know if this works for you or not, so
we may proceed to roll this into a general release.
I apologise that this has taken so long.
We were unable to get a small example which demostrated the problem.
Thank you.
-glenn
Index: posixio.c
===================================================================
RCS file: /upc/share/CVS/netcdf-3/libsrc/posixio.c,v
retrieving revision 1.66
retrieving revision 1.67
diff -c -r1.66 -r1.67
*** posixio.c 1997/12/18 20:34:16 1.66
--- posixio.c 1999/04/23 23:02:41 1.67
***************
*** 2,8 ****
* Copyright 1996, University Corporation for Atmospheric Research
* See netcdf/COPYRIGHT file for copying and redistribution conditions.
*/
! /* $Id: posixio.c,v 1.66 1997/12/18 20:34:16 davis Exp $ */
#include "ncconfig.h"
#include <assert.h>
--- 2,8 ----
* Copyright 1996, University Corporation for Atmospheric Research
* See netcdf/COPYRIGHT file for copying and redistribution conditions.
*/
! /* $Id: posixio.c,v 1.67 1999/04/23 23:02:41 davis Exp $ */
#include "ncconfig.h"
#include <assert.h>
***************
*** 95,101 ****
struct stat sb;
if (fstat(fd, &sb) > -1)
{
! return (size_t) sb.st_blksize;
}
/* else, silent in the face of error */
#endif
--- 95,103 ----
struct stat sb;
if (fstat(fd, &sb) > -1)
{
! if(sb.st_blksize >= 8192)
! return (size_t) sb.st_blksize;
! return 8192;
}
/* else, silent in the face of error */
#endif
***************
*** 501,508 ****
void *src;
void *dest;
! #if 0
! fprintf(stderr, "double_buffr %ld %ld %ld\n",
(long)to, (long)from, (long)nbytes);
#endif
status = px_get(nciop, pxp, to, nbytes, RGN_WRITE,
--- 503,510 ----
void *src;
void *dest;
! #if INSTRUMENT
! fprintf(stderr, "\tdouble_buffr %ld %ld %ld\n",
(long)to, (long)from, (long)nbytes);
#endif
status = px_get(nciop, pxp, to, nbytes, RGN_WRITE,
***************
*** 585,593 ****
--- 587,622 ----
diff = (size_t)(upper - lower);
extent = diff + nbytes;
+ #if INSTRUMENT
+ fprintf(stderr, "ncio_px_move %ld %ld %ld %ld %ld\n",
+ (long)to, (long)from, (long)nbytes, (long)lower, (long)extent);
+ #endif
if(extent > pxp->blksz)
{
size_t remaining = nbytes;
+
+ if(to > from)
+ {
+ off_t frm = from + nbytes;
+ off_t toh = to + nbytes;
+ for(;;)
+ {
+ size_t loopextent = MIN(remaining, pxp->blksz);
+ frm -= loopextent;
+ toh -= loopextent;
+
+ status = px_double_buffer(nciop, toh, frm,
+ loopextent, rflags) ;
+ if(status != ENOERR)
+ return status;
+ remaining -= loopextent;
+
+ if(remaining == 0)
+ break; /* normal loop exit */
+ }
+ }
+ else
+ {
for(;;)
{
size_t loopextent = MIN(remaining, pxp->blksz);
***************
*** 603,614 ****
to += loopextent;
from += loopextent;
}
return ENOERR;
}
! #if 0
! fprintf(stderr, "ncio_px_move %ld %ld %ld %ld %ld\n",
! (long)to, (long)from, (long)nbytes, (long)lower, (long)extent);
#endif
status = px_get(nciop, pxp, lower, extent, RGN_WRITE|rflags,
(void **)&base);
--- 632,643 ----
to += loopextent;
from += loopextent;
}
+ }
return ENOERR;
}
! #if INSTRUMENT
! fprintf(stderr, "\tncio_px_move small\n");
#endif
status = px_get(nciop, pxp, lower, extent, RGN_WRITE|rflags,
(void **)&base);