From 8a9599c850b59ac0b1314a2815f66fd30ec919f3 Mon Sep 17 00:00:00 2001 From: Russ Rew Date: Sun, 1 Apr 2012 23:42:53 +0000 Subject: [PATCH] Merge my branch back into trunk! --- libsrc/nc.c | 13 +++++++++---- libsrc/v1hpg.c | 5 ++++- nc_test/large_files.c | 25 +++++++++++++------------ 3 files changed, 26 insertions(+), 17 deletions(-) diff --git a/libsrc/nc.c b/libsrc/nc.c index 41a473d70..c11f922e5 100644 --- a/libsrc/nc.c +++ b/libsrc/nc.c @@ -252,16 +252,21 @@ fprintf(stderr, " REC %d %s: %ld\n", ii, (*vpp)->name->cp, (long)index); return NC_EVARSIZE; } #endif - ncp->recsize += (*vpp)->len; + if((*vpp)->len != UINT32_MAX) /* flag for vars >= 2**32 bytes */ + ncp->recsize += (*vpp)->len; last = (*vpp); } /* - * for special case of exactly one record variable, pack value + * for special case of */ - if(last != NULL && ncp->recsize == last->len) + if(last != NULL) { + if(ncp->recsize == last->len) { /* exactly one record variable, pack value */ ncp->recsize = *last->dsizes * last->xsz; - + } else if(last->len == UINT32_MAX) { /* huge last record variable */ + ncp->recsize += *last->dsizes * last->xsz; + } + } if(NC_IsNew(ncp)) NC_set_numrecs(ncp, 0); return NC_NOERR; diff --git a/libsrc/v1hpg.c b/libsrc/v1hpg.c index 2e042b5b1..11550fc00 100644 --- a/libsrc/v1hpg.c +++ b/libsrc/v1hpg.c @@ -1117,7 +1117,10 @@ NC_computeshapes(NC *ncp) { if(first_rec == NULL) first_rec = *vpp; - ncp->recsize += (*vpp)->len; + if((*vpp)->len == UINT32_MAX) + ncp->recsize += (*vpp)->dsizes[0]; + else + ncp->recsize += (*vpp)->len; } else { diff --git a/nc_test/large_files.c b/nc_test/large_files.c index 6356b8d8d..b3e8c12be 100644 --- a/nc_test/large_files.c +++ b/nc_test/large_files.c @@ -22,7 +22,7 @@ #define FILE_NAME "large_files.nc" -void +static void check_err(const int stat, const int line, const char *file) { if (stat != NC_NOERR) { (void) fprintf(stderr, "line %d of %s: %s\n", line, file, nc_strerror(stat)); @@ -46,8 +46,8 @@ main(int argc, char **argv) { int k_dim; int n_dim; -#define NUMRECS 1 -#define I_LEN 4104 +#define NUMRECS 2 +#define I_LEN 4106 #define J_LEN 1023 #define K_LEN 1023 #define N_LEN 2 @@ -94,6 +94,11 @@ main(int argc, char **argv) { /* define variables */ + x_dims[0] = rec_dim; + x_dims[1] = n_dim; + stat = nc_def_var(ncid, "x", NC_BYTE, RANK_x, x_dims, &x_id); + check_err(stat,__LINE__,__FILE__); + var1_dims[0] = rec_dim; var1_dims[1] = i_dim; var1_dims[2] = j_dim; @@ -101,10 +106,6 @@ main(int argc, char **argv) { stat = nc_def_var(ncid, "var1", NC_BYTE, RANK_var1, var1_dims, &var1_id); check_err(stat,__LINE__,__FILE__); - x_dims[0] = rec_dim; - x_dims[1] = n_dim; - stat = nc_def_var(ncid, "x", NC_BYTE, RANK_x, x_dims, &x_id); - check_err(stat,__LINE__,__FILE__); /* don't initialize variables with fill values */ stat = nc_set_fill(ncid, NC_NOFILL, 0); check_err(stat,__LINE__,__FILE__); @@ -126,18 +127,18 @@ main(int argc, char **argv) { for(i=0; i