mirror of
https://github.com/Unidata/netcdf-c.git
synced 2025-01-30 16:10:44 +08:00
Merge my branch back into trunk!
This commit is contained in:
parent
f5bd3bf525
commit
8a9599c850
13
libsrc/nc.c
13
libsrc/nc.c
@ -252,16 +252,21 @@ fprintf(stderr, " REC %d %s: %ld\n", ii, (*vpp)->name->cp, (long)index);
|
|||||||
return NC_EVARSIZE;
|
return NC_EVARSIZE;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
ncp->recsize += (*vpp)->len;
|
if((*vpp)->len != UINT32_MAX) /* flag for vars >= 2**32 bytes */
|
||||||
|
ncp->recsize += (*vpp)->len;
|
||||||
last = (*vpp);
|
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;
|
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))
|
if(NC_IsNew(ncp))
|
||||||
NC_set_numrecs(ncp, 0);
|
NC_set_numrecs(ncp, 0);
|
||||||
return NC_NOERR;
|
return NC_NOERR;
|
||||||
|
@ -1117,7 +1117,10 @@ NC_computeshapes(NC *ncp)
|
|||||||
{
|
{
|
||||||
if(first_rec == NULL)
|
if(first_rec == NULL)
|
||||||
first_rec = *vpp;
|
first_rec = *vpp;
|
||||||
ncp->recsize += (*vpp)->len;
|
if((*vpp)->len == UINT32_MAX)
|
||||||
|
ncp->recsize += (*vpp)->dsizes[0];
|
||||||
|
else
|
||||||
|
ncp->recsize += (*vpp)->len;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
#define FILE_NAME "large_files.nc"
|
#define FILE_NAME "large_files.nc"
|
||||||
|
|
||||||
void
|
static void
|
||||||
check_err(const int stat, const int line, const char *file) {
|
check_err(const int stat, const int line, const char *file) {
|
||||||
if (stat != NC_NOERR) {
|
if (stat != NC_NOERR) {
|
||||||
(void) fprintf(stderr, "line %d of %s: %s\n", line, file, nc_strerror(stat));
|
(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 k_dim;
|
||||||
int n_dim;
|
int n_dim;
|
||||||
|
|
||||||
#define NUMRECS 1
|
#define NUMRECS 2
|
||||||
#define I_LEN 4104
|
#define I_LEN 4106
|
||||||
#define J_LEN 1023
|
#define J_LEN 1023
|
||||||
#define K_LEN 1023
|
#define K_LEN 1023
|
||||||
#define N_LEN 2
|
#define N_LEN 2
|
||||||
@ -94,6 +94,11 @@ main(int argc, char **argv) {
|
|||||||
|
|
||||||
/* define variables */
|
/* 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[0] = rec_dim;
|
||||||
var1_dims[1] = i_dim;
|
var1_dims[1] = i_dim;
|
||||||
var1_dims[2] = j_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);
|
stat = nc_def_var(ncid, "var1", NC_BYTE, RANK_var1, var1_dims, &var1_id);
|
||||||
check_err(stat,__LINE__,__FILE__);
|
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 */
|
/* don't initialize variables with fill values */
|
||||||
stat = nc_set_fill(ncid, NC_NOFILL, 0);
|
stat = nc_set_fill(ncid, NC_NOFILL, 0);
|
||||||
check_err(stat,__LINE__,__FILE__);
|
check_err(stat,__LINE__,__FILE__);
|
||||||
@ -126,18 +127,18 @@ main(int argc, char **argv) {
|
|||||||
for(i=0; i<I_LEN; i++) {
|
for(i=0; i<I_LEN; i++) {
|
||||||
for(j=0; j<J_LEN; j++) {
|
for(j=0; j<J_LEN; j++) {
|
||||||
for (k=0; k<K_LEN; k++) {
|
for (k=0; k<K_LEN; k++) {
|
||||||
var1[j][k] = n;
|
var1[j][k] = (signed char) n;
|
||||||
n++;
|
n++;
|
||||||
n %= 256;
|
n %= 256;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var1_start[1] = i;
|
var1_start[1] = i;
|
||||||
stat = nc_put_vara_schar(ncid, var1_id, var1_start, var1_count, &var1[0][0]);
|
stat = nc_put_vara_schar(ncid, var1_id, var1_start, var1_count, &var1[0][0]);
|
||||||
check_err(stat,__LINE__,__FILE__);
|
check_err(stat,__LINE__,__FILE__);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
stat = nc_put_vara_schar(ncid, x_id, x_start, x_count, x);
|
stat = nc_put_vara_schar(ncid, x_id, x_start, x_count, x);
|
||||||
check_err(stat,__LINE__,__FILE__);
|
check_err(stat,__LINE__,__FILE__);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stat = nc_close(ncid);
|
stat = nc_close(ncid);
|
||||||
@ -171,7 +172,7 @@ main(int argc, char **argv) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
n++;
|
n++;
|
||||||
n %= 256;
|
n %= 256;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user