int
main()
{
    extern int ncopts;		/* netCDF error options */

    static char testfile[] = "testfile.nc";

    ncopts &= ~NC_FATAL;	/* make errors nonfatal */
    ncopts &= ~NC_VERBOSE;	/* turn off error messages */

    test_nccreate(testfile);

    test_ncopen(testfile);

    test_ncredef(testfile);

    test_ncendef(testfile);

    test_ncclose(testfile);

    test_ncinquire(testfile);

    test_ncsync(testfile);

    test_ncabort(testfile);

    test_ncdimdef(testfile);

    test_ncdimid(testfile);

    test_ncdiminq(testfile);

    test_ncdimrename(testfile);

    test_ncvardef(testfile);

    test_ncvarid(testfile);

    test_ncvarinq(testfile);

    test_ncvarput1(testfile);

    test_ncvarget1(testfile);

    test_ncvarput(testfile);

    test_ncvarget(testfile);

    test_ncvarputg(testfile);

    test_ncvargetg(testfile);

    test_ncrecinq(testfile);

    test_ncrecput(testfile);

    test_ncrecget(testfile);

    test_ncvarrename(testfile);

    test_ncattput(testfile);

    test_ncattinq(testfile);

    test_ncattget(testfile);

    test_ncattcopy(testfile, "test2.nc");

    test_ncattname(testfile);

    test_ncattrename(testfile);

    test_ncattdel(testfile);

    test_nctypelen();

#ifdef vms
#define EXIT_SUCCESS 1
#else
#define EXIT_SUCCESS 0
#endif
    return EXIT_SUCCESS;
}
Exemple #2
0
int
main(int argc, char **argv)
{
    extern int ncopts;		/* netCDF error options */
    char *testfiles[] = {"nonesuch", "nctest_classic.nc", 
			 "nctest_64bit_offset.nc", "nctest_netcdf4.nc"};
    char *testfile;
    int i, nerrs = 0;

#ifdef USE_PARALLEL
   MPI_Init(&argc, &argv);
#endif

    ncopts &= ~NC_FATAL;	/* make errors nonfatal */
    ncopts &= ~NC_VERBOSE;	/* turn off error messages */

    fprintf(stderr, "Testing V2 API with %d different netCDF formats.\n", 
	   NUM_FORMATS);

    for (i = 1; i <= NUM_FORMATS; i++)
    {
       switch (i) 
       {
	  case NC_FORMAT_CLASSIC:
	     nc_set_default_format(NC_FORMAT_CLASSIC, NULL);
	     fprintf(stderr, "\n\nSwitching to netCDF classic format.\n");
	     break;
	  case NC_FORMAT_64BIT:
	     nc_set_default_format(NC_FORMAT_64BIT, NULL);
	     fprintf(stderr, "\n\nSwitching to 64-bit offset format.\n");
	     break;
#ifdef USE_NETCDF4 
	  case NC_FORMAT_NETCDF4: /* actually it's _CLASSIC. */
	     nc_set_default_format(NC_FORMAT_NETCDF4_CLASSIC, NULL);
	     fprintf(stderr, "\n\nSwitching to netCDF-4 format (with NC_CLASSIC_MODEL).\n");
	     break;
#endif
	  default:
	     fprintf(stderr, "Unexpected format!\n");
	     return 2;
       }
       testfile = testfiles[i];

       /* Run all the tests for this format. */
       nerrs += test_nccreate(testfile);
       nerrs += test_ncopen(testfile);
       nerrs += test_ncredef(testfile);
       nerrs += test_ncendef(testfile);
       nerrs += test_ncclose(testfile);
       nerrs += test_ncinquire(testfile);
       nerrs += test_ncsync(testfile);
       nerrs += test_ncabort(testfile);
       nerrs += test_ncdimdef(testfile);
       nerrs += test_ncdimid(testfile);
       nerrs += test_ncdiminq(testfile);
       nerrs += test_ncdimrename(testfile);
       nerrs += test_ncvardef(testfile);
       nerrs += test_ncvarid(testfile);
       nerrs += test_ncvarinq(testfile);
       nerrs += test_ncvarput1(testfile);
       nerrs += test_ncvarget1(testfile);
       nerrs += test_ncvarput(testfile);
       nerrs += test_ncvarget(testfile);
       nerrs += test_ncvarputg(testfile);
       nerrs += test_ncvargetg(testfile);
       nerrs += test_ncrecinq(testfile);
       nerrs += test_ncrecput(testfile);
       nerrs += test_ncrecget(testfile);
       nerrs += test_ncvarrename(testfile);
       nerrs += test_ncattput(testfile);
       nerrs += test_ncattinq(testfile);
       nerrs += test_ncattget(testfile);
       nerrs += test_ncattcopy(testfile, "test2.nc");
       nerrs += test_ncattname(testfile);
       nerrs += test_ncattrename(testfile);
       nerrs += test_ncattdel(testfile);
       nerrs += test_nctypelen();
    }
    
    fprintf(stderr, "\nTotal number of failures: %d\n", nerrs);

    if (nerrs)
    {
       fprintf(stderr, "nctest FAILURE!!!\n");
       return 2;
    }
    else
       fprintf(stderr, "nctest SUCCESS!!!\n");
#ifdef USE_PARALLEL
   MPI_Finalize();
#endif   

    return 0;
}