Housekeeping on large file tests.

This commit is contained in:
Ward Fisher 2016-11-18 15:48:58 -07:00
parent 3632e07b19
commit b4785f4081
8 changed files with 143 additions and 145 deletions

View File

@ -10,6 +10,7 @@
*/
#include <config.h>
#include <nc_tests.h>
#include "err_macros.h"
#include <netcdf.h>
#include <stdio.h>
#include <string.h>
@ -49,7 +50,7 @@ main(int argc, char **argv)
int cmode_run;
int cflag = NC_CLOBBER;
int res;
int res;
printf("\n*** Testing large files, quickly.\n");
@ -57,14 +58,14 @@ main(int argc, char **argv)
{
size_t big_index = (size_t)MAX_CLASSIC_BYTES + 10;
/* On second pass, try using NC_SHARE. */
if (cmode_run == 1)
if (cmode_run == 1)
{
cflag |= NC_SHARE;
printf("*** Turned on NC_SHARE for subsequent tests.\n");
}
/* Create a netCDF 64-bit offset format file. Write a value. */
sprintf(file_name, "%s/%s", TEMP_LARGE, FILE_NAME);
sprintf(file_name, "%s/%s", TEMP_LARGE, FILE_NAME);
printf("*** Creating %s for 64-bit offset large file test...", file_name);
if ((res = nc_create(file_name, cflag|NC_64BIT_OFFSET, &ncid)))
ERR;
@ -76,13 +77,13 @@ main(int argc, char **argv)
/* test bug fix writing record beyond 2**31 */
if ((res = nc_def_dim(ncid, "longerdim", NC_UNLIMITED, &recdimid)))
ERR;
if ((res = nc_def_var(ncid, "spock", NC_DOUBLE, NUMDIMS,
if ((res = nc_def_var(ncid, "spock", NC_DOUBLE, NUMDIMS,
dimids, &spockid)))
ERR;
if ((res = nc_def_var(ncid, "kirk", NC_DOUBLE, NUMDIMS,
if ((res = nc_def_var(ncid, "kirk", NC_DOUBLE, NUMDIMS,
dimids, &kirkid)))
ERR;
if ((res = nc_def_var(ncid, "scotty", NC_BYTE, 1,
if ((res = nc_def_var(ncid, "scotty", NC_BYTE, 1,
&recdimid, &scottyid)))
ERR;
if ((res = nc_enddef(ncid)))
@ -93,14 +94,14 @@ main(int argc, char **argv)
ERR;
if ((res = nc_get_var1_int(ncid, scottyid, &big_index, &int_val_in)))
ERR;
if (int_val_in != int_val_out)
if (int_val_in != int_val_out)
ERR;
if ((res = nc_close(ncid)))
ERR;
printf("ok\n");
printf("ok\n");
/* How about a meteorological data file about the weather
experience by various generals of revolutionary armies?
experience by various generals of revolutionary armies?
This has 3 dims, 4 vars. The dimensions are such that this will
(just barely) not fit in a classic format file. The first three
@ -112,21 +113,21 @@ main(int argc, char **argv)
everything is rounded to a 4 byte boundary, so you need to add
some bytes for that (how many?), and that pushes us over the
limit.
We will create this file twice, once to ensure it succeeds (with
64-bit offset format), and once to make sure it fails (with
classic format). Then some variations to check record var
boundaries.
boundaries.
*/
printf("*** Now a 64-bit offset, large file, fixed var test...");
printf("*** Now a 64-bit offset, large file, fixed var test...");
if ((res = nc_create(file_name, cflag|NC_64BIT_OFFSET, &ncid)))
ERR;
if ((res = nc_set_fill(ncid, NC_NOFILL, NULL)))
ERR;
if ((res = nc_def_dim(ncid, "revolutionary_fervor",
if ((res = nc_def_dim(ncid, "revolutionary_fervor",
QTR_CLASSIC_MAX, &dimids_gen[0])))
ERR;
if ((res = nc_def_dim(ncid, "post_revoultionary_hangover",
if ((res = nc_def_dim(ncid, "post_revoultionary_hangover",
QTR_CLASSIC_MAX, &dimids_gen[1])))
ERR;
if ((res = nc_def_dim(ncid, "ruthlessness", 100, &dimids_gen[2])))
@ -134,18 +135,18 @@ main(int argc, char **argv)
if ((res = nc_def_var(ncid, "Cromwell", NC_BYTE, 1, &dimids_gen[0],
&cromwellid)))
ERR;
if ((res = nc_def_var(ncid, "Washington", NC_SHORT, 1, &dimids_gen[1],
if ((res = nc_def_var(ncid, "Washington", NC_SHORT, 1, &dimids_gen[1],
&washingtonid)))
ERR;
if ((res = nc_def_var(ncid, "Napolean", NC_BYTE, 1, &dimids_gen[0],
if ((res = nc_def_var(ncid, "Napolean", NC_BYTE, 1, &dimids_gen[0],
&napoleanid)))
ERR;
if ((res = nc_def_var(ncid, "Collins", NC_DOUBLE, 1, &dimids_gen[2],
if ((res = nc_def_var(ncid, "Collins", NC_DOUBLE, 1, &dimids_gen[2],
&collinsid)))
ERR;
if ((res = nc_enddef(ncid)))
ERR;
printf("ok\n");
printf("ok\n");
/* Write a value or two just for fun. */
/*index[0] = QTR_CLASSIC_MAX - 296;
@ -155,7 +156,7 @@ main(int argc, char **argv)
ERR;
if (int_val_in != int_val_out)
BAIL2;*/
printf("*** Now writing some values...");
printf("*** Now writing some values...");
index[0] = QTR_CLASSIC_MAX - 295;
if ((res = nc_put_var1_int(ncid, napoleanid, index, &int_val_out)))
ERR;
@ -182,20 +183,20 @@ main(int argc, char **argv)
if ((res = nc_close(ncid)))
ERR;
printf("ok\n");
printf("ok\n");
/* This time it should fail, because we're trying to cram this into
a classic format file. nc_enddef will detect our violations and
give an error. We've*/
printf("*** Now a classic file which will fail...");
printf("*** Now a classic file which will fail...");
if ((res = nc_create(file_name, cflag, &ncid)))
ERR;
if ((res = nc_set_fill(ncid, NC_NOFILL, NULL)))
ERR;
if ((res = nc_def_dim(ncid, "revolutionary_fervor",
if ((res = nc_def_dim(ncid, "revolutionary_fervor",
QTR_CLASSIC_MAX, &dimids_gen[0])))
ERR;
if ((res = nc_def_dim(ncid, "post_revoultionary_hangover",
if ((res = nc_def_dim(ncid, "post_revoultionary_hangover",
QTR_CLASSIC_MAX, &dimids_gen[1])))
ERR;
if ((res = nc_def_dim(ncid, "ruthlessness", 100, &dimids_gen[2])))
@ -203,82 +204,82 @@ main(int argc, char **argv)
if ((res = nc_def_var(ncid, "Cromwell", NC_BYTE, 1, &dimids_gen[0],
&cromwellid)))
ERR;
if ((res = nc_def_var(ncid, "Washington", NC_SHORT, 1, &dimids_gen[1],
if ((res = nc_def_var(ncid, "Washington", NC_SHORT, 1, &dimids_gen[1],
&washingtonid)))
ERR;
if ((res = nc_def_var(ncid, "Napolean", NC_BYTE, 1, &dimids_gen[0],
if ((res = nc_def_var(ncid, "Napolean", NC_BYTE, 1, &dimids_gen[0],
&napoleanid)))
ERR;
if ((res = nc_def_var(ncid, "Collins", NC_DOUBLE, 1, &dimids_gen[2],
if ((res = nc_def_var(ncid, "Collins", NC_DOUBLE, 1, &dimids_gen[2],
&collinsid)))
ERR;
if ((res = nc_enddef(ncid)) != NC_EVARSIZE)
ERR;
if ((res = nc_close(ncid)) != NC_EVARSIZE)
ERR;
printf("ok\n");
printf("ok\n");
/* This will create some max sized 64-bit offset format fixed vars. */
printf("*** Now a 64-bit offset, simple fixed var create test...");
printf("*** Now a 64-bit offset, simple fixed var create test...");
if ((res = nc_create(file_name, cflag|NC_64BIT_OFFSET, &ncid)))
ERR;
if ((res = nc_set_fill(ncid, NC_NOFILL, NULL)))
ERR;
if ((res = nc_def_dim(ncid, "revolutionary_fervor",
if ((res = nc_def_dim(ncid, "revolutionary_fervor",
MAX_CLASSIC_BYTES, &dimids_gen[0])))
ERR;
if ((res = nc_def_var(ncid, "Cromwell", NC_SHORT, 1, dimids_gen,
&cromwellid)))
ERR;
if ((res = nc_def_var(ncid, "Napolean", NC_SHORT, 1, dimids_gen,
if ((res = nc_def_var(ncid, "Napolean", NC_SHORT, 1, dimids_gen,
&napoleanid)))
ERR;
if ((res = nc_def_var(ncid, "Collins", NC_DOUBLE, 1, dimids_gen,
if ((res = nc_def_var(ncid, "Collins", NC_DOUBLE, 1, dimids_gen,
&collinsid)))
ERR;
if ((res = nc_enddef(ncid)))
ERR;
if ((res = nc_close(ncid)))
ERR;
printf("ok\n");
printf("ok\n");
/* This will exceed the 64-bit offset format limits for one of the
fixed vars. */
printf("*** Now a 64-bit offset, over-sized file that will fail...");
printf("*** Now a 64-bit offset, over-sized file that will fail...");
if ((res = nc_create(file_name, cflag|NC_64BIT_OFFSET, &ncid)))
ERR;
if ((res = nc_set_fill(ncid, NC_NOFILL, NULL)))
ERR;
/* max dim size is MAX_CLASSIC_BYTES. */
if ((res = nc_def_dim(ncid, "revolutionary_fervor",
if ((res = nc_def_dim(ncid, "revolutionary_fervor",
MAX_CLASSIC_BYTES, dimids_gen)))
ERR;
if ((res = nc_def_var(ncid, "Cromwell", NC_DOUBLE, 1, dimids_gen,
&cromwellid)))
ERR;
if ((res = nc_def_var(ncid, "Washington", NC_SHORT, 1, dimids_gen,
if ((res = nc_def_var(ncid, "Washington", NC_SHORT, 1, dimids_gen,
&washingtonid)))
if ((res = nc_enddef(ncid)) != NC_EVARSIZE)
ERR;
if ((res = nc_close(ncid)) != NC_EVARSIZE)
ERR;
printf("ok\n");
printf("ok\n");
/* Now let's see about record vars. First create a 64-bit offset
file with three rec variables, each with the same numbers as
defined above for the fixed var tests. This should all work. */
printf("*** Now a 64-bit offset, record var file...");
printf("*** Now a 64-bit offset, record var file...");
if ((res = nc_create(file_name, cflag|NC_64BIT_OFFSET, &ncid)))
ERR;
if ((res = nc_set_fill(ncid, NC_NOFILL, NULL)))
ERR;
if ((res = nc_def_dim(ncid, "political_trouble",
if ((res = nc_def_dim(ncid, "political_trouble",
NC_UNLIMITED, &dimids_gen[0])))
ERR;
if ((res = nc_def_dim(ncid, "revolutionary_fervor",
if ((res = nc_def_dim(ncid, "revolutionary_fervor",
QTR_CLASSIC_MAX, &dimids_gen[1])))
ERR;
if ((res = nc_def_dim(ncid, "post_revoultionary_hangover",
if ((res = nc_def_dim(ncid, "post_revoultionary_hangover",
QTR_CLASSIC_MAX, &dimids_gen[2])))
ERR;
if ((res = nc_def_dim(ncid, "ruthlessness", 100, &dimids_gen[3])))
@ -286,35 +287,35 @@ main(int argc, char **argv)
if ((res = nc_def_var(ncid, "Cromwell", NC_BYTE, 2, dimids_gen,
&cromwellid)))
ERR;
if ((res = nc_def_var(ncid, "Washington", NC_SHORT, 2, dimids_gen,
if ((res = nc_def_var(ncid, "Washington", NC_SHORT, 2, dimids_gen,
&washingtonid)))
ERR;
if ((res = nc_def_var(ncid, "Napolean", NC_BYTE, 2, dimids_gen,
if ((res = nc_def_var(ncid, "Napolean", NC_BYTE, 2, dimids_gen,
&napoleanid)))
ERR;
if ((res = nc_def_var(ncid, "Collins", NC_DOUBLE, 1, &dimids_gen[2],
if ((res = nc_def_var(ncid, "Collins", NC_DOUBLE, 1, &dimids_gen[2],
&collinsid)))
ERR;
if ((res = nc_enddef(ncid)))
ERR;
if ((res = nc_close(ncid)))
ERR;
printf("ok\n");
printf("ok\n");
/* Now try this record file in classic format. It should fail and
the enddef. Too many bytes in the first record.*/
printf("*** Now a classic file that's too big and will fail...");
printf("*** Now a classic file that's too big and will fail...");
if ((res = nc_create(file_name, cflag, &ncid)))
ERR;
if ((res = nc_set_fill(ncid, NC_NOFILL, NULL)))
ERR;
if ((res = nc_def_dim(ncid, "political_trouble",
if ((res = nc_def_dim(ncid, "political_trouble",
NC_UNLIMITED, &dimids_gen[0])))
ERR;
if ((res = nc_def_dim(ncid, "revolutionary_fervor",
if ((res = nc_def_dim(ncid, "revolutionary_fervor",
QTR_CLASSIC_MAX, &dimids_gen[1])))
ERR;
if ((res = nc_def_dim(ncid, "post_revoultionary_hangover",
if ((res = nc_def_dim(ncid, "post_revoultionary_hangover",
QTR_CLASSIC_MAX, &dimids_gen[2])))
ERR;
if ((res = nc_def_dim(ncid, "ruthlessness", 100, &dimids_gen[3])))
@ -322,34 +323,34 @@ main(int argc, char **argv)
if ((res = nc_def_var(ncid, "Cromwell", NC_BYTE, 2, dimids_gen,
&cromwellid)))
ERR;
if ((res = nc_def_var(ncid, "Washington", NC_SHORT, 2, dimids_gen,
if ((res = nc_def_var(ncid, "Washington", NC_SHORT, 2, dimids_gen,
&washingtonid)))
ERR;
if ((res = nc_def_var(ncid, "Napolean", NC_BYTE, 2, dimids_gen,
if ((res = nc_def_var(ncid, "Napolean", NC_BYTE, 2, dimids_gen,
&napoleanid)))
ERR;
if ((res = nc_def_var(ncid, "Collins", NC_DOUBLE, 1, &dimids_gen[2],
if ((res = nc_def_var(ncid, "Collins", NC_DOUBLE, 1, &dimids_gen[2],
&collinsid)))
ERR;
if ((res = nc_enddef(ncid)) != NC_EVARSIZE)
ERR;
if ((res = nc_close(ncid)) != NC_EVARSIZE)
ERR;
printf("ok\n");
printf("ok\n");
/* Now try this record file in classic format. It just barely
passes at the enddef. Almost, but not quite, too many bytes in
the first record. Since I'm adding a fixed variable (Collins),
I don't get the last record size exemption. */
printf("*** Now a classic file with recs and one fixed will fail...");
the first record. Since I'm adding a fixed variable (Collins),
I don't get the last record size exemption. */
printf("*** Now a classic file with recs and one fixed will fail...");
if ((res = nc_create(file_name, cflag, &ncid)))
ERR;
if ((res = nc_set_fill(ncid, NC_NOFILL, NULL)))
ERR;
if ((res = nc_def_dim(ncid, "political_trouble",
if ((res = nc_def_dim(ncid, "political_trouble",
NC_UNLIMITED, &dimids_gen[0])))
ERR;
if ((res = nc_def_dim(ncid, "revolutionary_fervor",
if ((res = nc_def_dim(ncid, "revolutionary_fervor",
MAX_CLASSIC_BYTES, &dimids_gen[1])))
ERR;
if ((res = nc_def_dim(ncid, "ruthlessness", 100, &dimids_gen[2])))
@ -357,14 +358,14 @@ main(int argc, char **argv)
if ((res = nc_def_var(ncid, "Cromwell", NC_BYTE, 2, dimids_gen,
&cromwellid)))
ERR;
if ((res = nc_def_var(ncid, "Collins", NC_DOUBLE, 1, &dimids_gen[2],
if ((res = nc_def_var(ncid, "Collins", NC_DOUBLE, 1, &dimids_gen[2],
&collinsid)))
ERR;
if ((res = nc_enddef(ncid)))
ERR;
if ((res = nc_close(ncid)))
ERR;
printf("ok\n");
printf("ok\n");
/* Try a classic file with several records, and the last record var
with a record size greater than our magic number of 2 GiB - 4
@ -373,17 +374,17 @@ main(int argc, char **argv)
increases his size to 2147483644 (the max dimension size) times
8, or about 16 GB per record. Zowie! (Mind you, Cromwell
certainly had a great deal of revolutionary fervor.)
*/
printf("*** Now a classic file with one large rec var...");
*/
printf("*** Now a classic file with one large rec var...");
if ((res = nc_create(file_name, cflag, &ncid)))
ERR;
if ((res = nc_set_fill(ncid, NC_NOFILL, NULL)))
ERR;
if ((res = nc_def_dim(ncid, "political_trouble",
if ((res = nc_def_dim(ncid, "political_trouble",
NC_UNLIMITED, &dimids_gen[0])))
ERR;
if ((res = nc_def_dim(ncid, "revolutionary_fervor",
MAX_CLASSIC_BYTES, &dimids_gen[1])))
if ((res = nc_def_dim(ncid, "revolutionary_fervor",
MAX_CLASSIC_BYTES, &dimids_gen[1])))
ERR;
if ((res = nc_def_var(ncid, "Cromwell", NC_DOUBLE, 2, dimids_gen,
&cromwellid)))
@ -400,8 +401,8 @@ main(int argc, char **argv)
ERR;
if ((res = nc_close(ncid)))
ERR;
printf("ok\n");
printf("ok\n");
/* This is a classic format file with an extra-large last record
var. */
printf("*** Now a classic file with extra-large last record var...") ;
@ -409,23 +410,23 @@ main(int argc, char **argv)
ERR;
if ((res = nc_set_fill(ncid, NC_NOFILL, NULL)))
ERR;
if ((res = nc_def_dim(ncid, "political_trouble",
if ((res = nc_def_dim(ncid, "political_trouble",
NC_UNLIMITED, &dimids_gen[0])))
ERR;
if ((res = nc_def_dim(ncid, "revolutionary_fervor",
MAX_CLASSIC_BYTES, &dimids_gen[1])))
if ((res = nc_def_dim(ncid, "revolutionary_fervor",
MAX_CLASSIC_BYTES, &dimids_gen[1])))
ERR;
dimids_gen1[0] = dimids_gen[0];
if ((res = nc_def_dim(ncid, "post_revoultionary_hangover",
if ((res = nc_def_dim(ncid, "post_revoultionary_hangover",
5368, &dimids_gen1[1])))
ERR;
if ((res = nc_def_var(ncid, "Washington", NC_SHORT, 2, dimids_gen1,
if ((res = nc_def_var(ncid, "Washington", NC_SHORT, 2, dimids_gen1,
&washingtonid)))
ERR;
if ((res = nc_def_var(ncid, "Napolean", NC_BYTE, 2, dimids_gen1,
if ((res = nc_def_var(ncid, "Napolean", NC_BYTE, 2, dimids_gen1,
&napoleanid)))
ERR;
if ((res = nc_def_var(ncid, "Collins", NC_DOUBLE, 2, dimids_gen1,
if ((res = nc_def_var(ncid, "Collins", NC_DOUBLE, 2, dimids_gen1,
&collinsid)))
ERR;
if ((res = nc_def_var(ncid, "Cromwell", NC_DOUBLE, 2, dimids_gen,
@ -443,108 +444,108 @@ main(int argc, char **argv)
ERR;
if ((res = nc_close(ncid)))
ERR;
printf("ok\n");
printf("ok\n");
/* This is a classic format file with an extra-large second to last
record var. But this time it won't work, because the size
exemption only applies to the last record var. Note that one
dimension is small (5000). */
printf("*** Now a classic file xtra-large 2nd to last var that will fail...");
printf("*** Now a classic file xtra-large 2nd to last var that will fail...");
if ((res = nc_create(file_name, cflag, &ncid)))
ERR;
if ((res = nc_set_fill(ncid, NC_NOFILL, NULL)))
ERR;
if ((res = nc_def_dim(ncid, "political_trouble",
if ((res = nc_def_dim(ncid, "political_trouble",
NC_UNLIMITED, &dimids_gen[0])))
ERR;
if ((res = nc_def_dim(ncid, "revolutionary_fervor",
MAX_CLASSIC_BYTES, &dimids_gen[1])))
if ((res = nc_def_dim(ncid, "revolutionary_fervor",
MAX_CLASSIC_BYTES, &dimids_gen[1])))
ERR;
dimids_gen1[0] = dimids_gen[0];
if ((res = nc_def_dim(ncid, "post_revoultionary_hangover",
if ((res = nc_def_dim(ncid, "post_revoultionary_hangover",
5000, &dimids_gen1[1])))
ERR;
if ((res = nc_def_var(ncid, "Washington", NC_SHORT, 2, dimids_gen1,
if ((res = nc_def_var(ncid, "Washington", NC_SHORT, 2, dimids_gen1,
&washingtonid)))
ERR;
if ((res = nc_def_var(ncid, "Napolean", NC_BYTE, 2, dimids_gen1,
if ((res = nc_def_var(ncid, "Napolean", NC_BYTE, 2, dimids_gen1,
&napoleanid)))
ERR;
if ((res = nc_def_var(ncid, "Cromwell", NC_DOUBLE, 2, dimids_gen,
&cromwellid)))
ERR;
if ((res = nc_def_var(ncid, "Collins", NC_DOUBLE, 2, dimids_gen1,
if ((res = nc_def_var(ncid, "Collins", NC_DOUBLE, 2, dimids_gen1,
&collinsid)))
ERR;
if ((res = nc_enddef(ncid)) != NC_EVARSIZE)
ERR;
if ((res = nc_close(ncid)) != NC_EVARSIZE)
ERR;
printf("ok\n");
printf("ok\n");
/* Now try an extra large second to last ver with 64-bit
offset. This won't work either, because the cromwell var is so
large. It exceeds the 4GiB - 4 byte per record limit for record
vars. */
printf("*** Now a 64-bit offset file with too-large rec var that will fail...");
printf("*** Now a 64-bit offset file with too-large rec var that will fail...");
if ((res = nc_create(file_name, cflag|NC_64BIT_OFFSET, &ncid)))
ERR;
if ((res = nc_set_fill(ncid, NC_NOFILL, NULL)))
ERR;
if ((res = nc_def_dim(ncid, "political_trouble",
if ((res = nc_def_dim(ncid, "political_trouble",
NC_UNLIMITED, &dimids_gen[0])))
ERR;
if ((res = nc_def_dim(ncid, "revolutionary_fervor",
MAX_CLASSIC_BYTES, &dimids_gen[1])))
if ((res = nc_def_dim(ncid, "revolutionary_fervor",
MAX_CLASSIC_BYTES, &dimids_gen[1])))
ERR;
dimids_gen1[0] = dimids_gen[0];
if ((res = nc_def_dim(ncid, "post_revoultionary_hangover",
if ((res = nc_def_dim(ncid, "post_revoultionary_hangover",
5368, &dimids_gen1[1])))
ERR;
if ((res = nc_def_var(ncid, "Washington", NC_SHORT, 2, dimids_gen1,
if ((res = nc_def_var(ncid, "Washington", NC_SHORT, 2, dimids_gen1,
&washingtonid)))
ERR;
if ((res = nc_def_var(ncid, "Napolean", NC_BYTE, 2, dimids_gen1,
if ((res = nc_def_var(ncid, "Napolean", NC_BYTE, 2, dimids_gen1,
&napoleanid)))
ERR;
if ((res = nc_def_var(ncid, "Cromwell", NC_DOUBLE, 2, dimids_gen,
&cromwellid)))
ERR;
if ((res = nc_def_var(ncid, "Collins", NC_DOUBLE, 2, dimids_gen1,
if ((res = nc_def_var(ncid, "Collins", NC_DOUBLE, 2, dimids_gen1,
&collinsid)))
ERR;
if ((res = nc_enddef(ncid)) != NC_EVARSIZE)
ERR;
if ((res = nc_close(ncid)) != NC_EVARSIZE)
ERR;
printf("ok\n");
printf("ok\n");
/* A 64-bit offset record file that just fits... */
printf("*** Now a 64 bit-offset file that just fits...");
printf("*** Now a 64 bit-offset file that just fits...");
if ((res = nc_create(file_name, cflag|NC_64BIT_OFFSET, &ncid)))
ERR;
if ((res = nc_set_fill(ncid, NC_NOFILL, NULL)))
ERR;
if ((res = nc_def_dim(ncid, "political_trouble",
if ((res = nc_def_dim(ncid, "political_trouble",
NC_UNLIMITED, &dimids_gen[0])))
ERR;
if ((res = nc_def_dim(ncid, "revolutionary_fervor",
MAX_CLASSIC_BYTES, &dimids_gen[1])))
if ((res = nc_def_dim(ncid, "revolutionary_fervor",
MAX_CLASSIC_BYTES, &dimids_gen[1])))
ERR;
dimids_gen1[0] = dimids_gen[0];
if ((res = nc_def_dim(ncid, "post_revoultionary_hangover",
if ((res = nc_def_dim(ncid, "post_revoultionary_hangover",
MAX_CLASSIC_BYTES, &dimids_gen1[1])))
ERR;
if ((res = nc_def_var(ncid, "Washington", NC_SHORT, 2, dimids_gen1,
if ((res = nc_def_var(ncid, "Washington", NC_SHORT, 2, dimids_gen1,
&washingtonid)))
ERR;
if ((res = nc_def_var(ncid, "Napolean", NC_SHORT, 2, dimids_gen1,
if ((res = nc_def_var(ncid, "Napolean", NC_SHORT, 2, dimids_gen1,
&napoleanid)))
ERR;
if ((res = nc_def_var(ncid, "Cromwell", NC_SHORT, 2, dimids_gen,
&cromwellid)))
ERR;
if ((res = nc_def_var(ncid, "Collins", NC_DOUBLE, 2, dimids_gen1,
if ((res = nc_def_var(ncid, "Collins", NC_DOUBLE, 2, dimids_gen1,
&collinsid)))
ERR;
if ((res = nc_enddef(ncid)))
@ -559,20 +560,14 @@ main(int argc, char **argv)
ERR;
if ((res = nc_close(ncid)))
ERR;
printf("ok\n");
printf("ok\n");
} /* end of cmode run */
/* Wow! Everything worked! */
printf("*** Tests successful!\n");
printf("*** Tests successful!\n");
/* Delete the huge data file we created. */
(void) remove(file_name);
(void) remove(file_name);
return 0;
}

View File

@ -12,6 +12,7 @@
*/
#include <nc_tests.h>
#include "err_macros.h"
#include <netcdf.h>
#include <stdio.h>
#include <string.h>
@ -37,7 +38,7 @@
static int
test_big_var(const char *testfile)
test_big_var(const char *testfile)
{
int ncid, varid, dimids[NUMDIMS];
size_t index[NUMDIMS];
@ -48,7 +49,7 @@ test_big_var(const char *testfile)
signed char data[DIM2][DIM3];
int i, j;
int nerrs = 0;
/* Create a file with one big record variable. */
if (nc_create(testfile, NC_CLOBBER, &ncid)) ERR;
if (nc_set_fill(ncid, NC_NOFILL, NULL)) ERR;
@ -81,9 +82,9 @@ test_big_var(const char *testfile)
for (i = 0; i < DIM2; i++)
for (j = 0; j < DIM3; j++)
{
if (data[i][j] != (signed char)((i + j) % 16))
if (data[i][j] != (signed char)((i + j) % 16))
{
printf("error on start[0]: %d i: %d j: %d expected %d got %d\n",
printf("error on start[0]: %d i: %d j: %d expected %d got %d\n",
start[0], i, j, (i + j) % 16, data[i][j]);
ERR;
if(nerrs++ > 2)
@ -95,9 +96,9 @@ test_big_var(const char *testfile)
for (i = 0; i < DIM2; i++)
for (j = 0; j < DIM3; j++)
{
if (data[i][j] != (signed char)((i + j) % 16))
if (data[i][j] != (signed char)((i + j) % 16))
{
printf("error on start[0]: %d i: %d j: %d expected %d got %d\n",
printf("error on start[0]: %d i: %d j: %d expected %d got %d\n",
start[0], i, j, (i + j) % 16, data[i][j]);
ERR;
if(nerrs++ > 2)
@ -123,6 +124,6 @@ main(int argc, char **argv) {
(void) remove(testfile);
SUMMARIZE_ERR;
}
FINAL_RESULTS;
}

View File

@ -9,6 +9,7 @@
*/
#include <nc_tests.h>
#include "err_macros.h"
#include <netcdf.h>
#include <stdio.h>
#include <string.h>
@ -29,13 +30,13 @@
#define DIM1 2048
#define DIM2 2097153 /* DIM1*DIM2*sizeof(char) > 2**32 */
/*
/*
* In netCDF-3.6.2, an assertion failure occurs on 32-bit platforms
* when creating a byte variable for which the product of dimensions
* is greater than 2**32. Check that this bug has been fixed.
*/
static int
test_big_var(const char *testfile)
test_big_var(const char *testfile)
{
int ncid, varid, dimids[NUMDIMS];
size_t index[NUMDIMS];
@ -78,6 +79,6 @@ main(int argc, char **argv) {
(void) remove(testfile);
SUMMARIZE_ERR;
}
FINAL_RESULTS;
}

View File

@ -12,6 +12,7 @@
#include "config.h"
#include <nc_tests.h>
#include "err_macros.h"
#include <netcdf.h>
#include <stdio.h>
#include <string.h>
@ -32,7 +33,7 @@
#define DIM1 1000
#define DIM2 2000 /* DIM0*DIM1*DIM2 > 2**32 */
/*
/*
* This program tests the fix for a large file bug in versions
* previous to netCDF-4.1.2 for 32-bit platforms, writing to a
* variable with more than 1 dimension and more than 2**32 values,
@ -41,7 +42,7 @@
* as well, but that's not tested here.
*/
static int
test_big_var(const char *testfile)
test_big_var(const char *testfile)
{
int ncid, varid, dimids[NUMDIMS];
size_t index[NUMDIMS];
@ -91,7 +92,7 @@ test_big_var(const char *testfile)
{
if (data[i][j] != 42 )
{
printf("error on start[0]: %d i: %d j: %d expected %d got %d\n",
printf("error on start[0]: %d i: %d j: %d expected %d got %d\n",
start[0], i, j, 42, data[i][j]);
ERR;
if(nerrs++ > 1)
@ -105,7 +106,7 @@ test_big_var(const char *testfile)
{
if (data[i][j] != 19 )
{
printf("error on start[0]: %d i: %d j: %d expected %d got %d\n",
printf("error on start[0]: %d i: %d j: %d expected %d got %d\n",
start[0], i, j, 19, data[i][j]);
ERR;
if(nerrs++ > 1)
@ -132,6 +133,6 @@ main(int argc, char **argv) {
(void) remove(testfile);
SUMMARIZE_ERR;
}
FINAL_RESULTS;
}

View File

@ -11,6 +11,7 @@
*/
#include <nc_tests.h>
#include "err_macros.h"
#include <netcdf.h>
#include <stdio.h>
#include <string.h>
@ -33,7 +34,7 @@
#define DIM3 1000000 /* DIM2*DIM3 > 2**32 */
#define FIRST_VAL 65
#define SECOND_VAL 90
/*
/*
* This program tests the fix for a large file bug in versions
* previous to netCDF-4.1.2 for 32-bit platforms, writing to a
* variable with more than 1 dimension and more than 2**32 values,
@ -42,7 +43,7 @@
* as well, but that's not tested here.
*/
static int
test_big_var(const char *testfile)
test_big_var(const char *testfile)
{
int ncid, varid, dimids[NUMDIMS];
size_t start[NUMDIMS] = {0, 0, 0, 0};
@ -50,7 +51,7 @@ test_big_var(const char *testfile)
short data[DIM3];
int i, j, k;
int nerrs = 0;
/* Create a file with one big 4D variable. */
if (nc_create(testfile, NC_CLOBBER, &ncid)) ERR;
if (nc_set_fill(ncid, NC_NOFILL, NULL)) ERR;
@ -84,7 +85,7 @@ test_big_var(const char *testfile)
if (nc_get_vara_short(ncid, varid, start, count, &data[0])) ERR;
for (j = 0; j < DIM3; j++) {
if (data[j] != FIRST_VAL ) {
printf("error on start[0..2]: %d,%d,%d j: %d, expected %d got %d\n",
printf("error on start[0..2]: %d,%d,%d j: %d, expected %d got %d\n",
start[0], start[1], start[2], j, FIRST_VAL, data[j]);
ERR;
if(nerrs++ > 1)
@ -110,6 +111,6 @@ main(int argc, char **argv) {
(void) remove(testfile);
SUMMARIZE_ERR;
}
FINAL_RESULTS;
}

View File

@ -12,6 +12,7 @@
#include <string.h>
#include <stdlib.h>
#include <nc_tests.h>
#include "err_macros.h"
#include <netcdf.h>
/* Test with both classic and 64-bit offset files. If netcdf-4 is
@ -28,10 +29,10 @@
#define DIM3 1024
#define DIM4 2097153 /* DIM3*DIM4*sizeof(short) > 2**32 */
/*
/*
* In netCDF-3.6.2, a divide by zero occurs on 32-bit platforms when
* creating a variable for which the product of dimensions is exactly
* 2**32. Check that this bug has been fixed.
* 2**32. Check that this bug has been fixed.
*/
static int
test_big_var(const char *testfile) {
@ -89,7 +90,7 @@ test_large_byte_var(const char *testfile) {
count[0] = 1;
count[1] = DIM2;
for (start[0] = 0; start[0] < DIM1; start[0]++) {
if (nc_put_vara_schar(ncid, varid, start, count, vals))
if (nc_put_vara_schar(ncid, varid, start, count, vals))
{
ERR;
break;
@ -151,15 +152,15 @@ main(int argc, char **argv) {
testfile);
/* Go thru formats and run all tests for each of two (for netCDF-3
* only builds), or 4 (for netCDF-4 builds) different formats. */
for (i = NC_FORMAT_CLASSIC; i <= NUM_FORMATS; i++)
for (i = NC_FORMAT_CLASSIC; i <= NUM_FORMATS; i++)
{
nc_set_default_format(i, NULL);
printf("*** testing format %d with a variable with 2**32 values...", i);
test_big_var(testfile);
(void) remove(testfile);
SUMMARIZE_ERR;
printf("*** testing format %d with a byte variable with > 2**32 values...", i);
test_large_byte_var(testfile);
(void) remove(testfile);

View File

@ -2,11 +2,12 @@
Copyright 2005 University Corporation for Atmospheric Research/Unidata
See COPYRIGHT file for conditions of use.
Test netcdf-4 variables.
Test netcdf-4 variables.
$Id: tst_large.c,v 1.5 2009/05/18 10:26:24 ed Exp $
*/
#include <nc_tests.h>
#include "err_macros.h"
#include "netcdf.h"
#include "ncdispatch.h"
@ -32,7 +33,7 @@ main(int argc, char **argv)
int j;
/* Create phony data. */
for (j = 0; j < DIM2; j++)
for (j = 0; j < DIM2; j++)
vals[j] = 9 * (j + 11); /* note vals[j] is 99 when j==0 */
/* Create file with 2 dims and one var. */
@ -61,5 +62,3 @@ main(int argc, char **argv)
FINAL_RESULTS;
}

View File

@ -9,6 +9,7 @@
*/
#include <nc_tests.h>
#include "err_macros.h"
#include "netcdf.h"
#define FILE_NAME "tst_large2.nc"
@ -35,11 +36,11 @@ int main(int argc, char **argv)
char file_name[NC_MAX_NAME * 2 + 1];
float *data;
int this_format[NUM_FORMATS] = {NC_64BIT_OFFSET, NC_NETCDF4};
char format_name[NUM_FORMATS][NC_MAX_NAME + 1] =
char format_name[NUM_FORMATS][NC_MAX_NAME + 1] =
{"64-bit offset", "netCDF-4"};
int i, j, f;
printf("sizes: int - %d, size_t - %d, and int * - %d\n",
printf("sizes: int - %d, size_t - %d, and int * - %d\n",
sizeof(int), sizeof(size_t), sizeof(int *));
/* Allocate room for one slab of data. */
@ -80,9 +81,9 @@ int main(int argc, char **argv)
for (i = 0; i < LAT_LEN; i++)
for (j = 0; j < LON_LEN; j++)
{
if (data[j + LON_LEN * i] != (start[0] + i + j) % 19)
if (data[j + LON_LEN * i] != (start[0] + i + j) % 19)
{
printf("error on start[0]: %d i: %d j: %d expected %d got %g\n",
printf("error on start[0]: %d i: %d j: %d expected %d got %g\n",
start[0], i, j, (start[0] + i + j), data[j + LON_LEN * i]);
ERR_RET;
}
@ -99,5 +100,3 @@ int main(int argc, char **argv)
FINAL_RESULTS;
}