int main(int argc, char **argv) { int i; /* Set defaults */ persist = 0; usenetcdf4 = 0; mmap = 0; diskless = 0; file = 0; diskmode = 0; for(i=1;i<argc;i++) { if(strcmp(argv[i],"diskless")==0) diskless=1; else if(strcmp(argv[i],"mmap")==0) mmap=1; else if(strcmp(argv[i],"file")==0) file=1; else if(strcmp(argv[i],"persist")==0) persist=1; /* ignore anything not recognized */ } if(diskless && mmap) { fprintf(stderr,"NC_DISKLESS and NC_MMAP are mutually exclusive\n"); exit(1); } if(!diskless && !mmap && !file) { fprintf(stderr,"file or diskless or mmap must be specified\n"); exit(1); } if(diskless) diskmode |= NC_DISKLESS; if(mmap) diskmode |= NC_MMAP; if(persist) diskmode |= NC_PERSIST; printf("\n*** Testing create/modify file=%s mode=%s\n", NCFILENAME, diskless?"diskless":"mmap"); /* case NC_FORMAT_CLASSIC: only test this format */ nc_set_default_format(NC_FORMAT_CLASSIC, NULL); printf("*** testing diskless file with two growing record " "variables, with attributes added..."); test_two_growing_with_att(NCFILENAME); SUMMARIZE_ERR; FINAL_RESULTS; }
int main(int argc, char **argv) { int i; /* Set defaults */ persist = 0; usenetcdf4 = 0; mmap = 0; diskless = 0; diskmode = 0; for(i=1;i<argc;i++) { if(strcmp(argv[i],"diskless")==0) diskless=1; else if(strcmp(argv[i],"mmap")==0) mmap=1; /* ignore anything not recognized */ } if(diskless) diskmode |= NC_DISKLESS; if(diskless && mmap) diskmode |= NC_MMAP; printf("\n*** Testing diskless file: create/modify %s", diskless?"in-memory":"in-file"); if(diskless && mmap) printf("+mmap"); printf(" %s\n",NCFILENAME); /* case NC_FORMAT_CLASSIC: only test this format */ nc_set_default_format(NC_FORMAT_CLASSIC, NULL); printf("*** testing diskless file with two growing record " "variables, with attributes added..."); test_two_growing_with_att(NCFILENAME); SUMMARIZE_ERR; FINAL_RESULTS; }
int main(int argc, char *argv[]) { char filename[256]; int i, rank, nprocs, err, nerrs=0; int cmode[NUM_FORMATS]={0, NC_64BIT_OFFSET, NC_64BIT_DATA}; MPI_Init(&argc, &argv); MPI_Comm_size(MPI_COMM_WORLD, &nprocs); MPI_Comm_rank(MPI_COMM_WORLD, &rank); if (argc > 2) { if (!rank) printf("Usage: %s [filename]\n",argv[0]); MPI_Finalize(); return 0; } if (argc == 2) snprintf(filename, 256, "%s", argv[1]); else strcpy(filename, "testfile.nc"); MPI_Bcast(filename, 256, MPI_CHAR, 0, MPI_COMM_WORLD); char *cmd_str = (char*)malloc(strlen(argv[0]) + 256); sprintf(cmd_str, "*** TESTING C %s for emulating netCDF tst_small ", basename(argv[0])); if (rank == 0) printf("%-66s ------ ", cmd_str); free(cmd_str); for (i=0; i<NUM_FORMATS; i++) { #ifdef DEBUG printf("*** testing simple small file with a global attribute..."); #endif nerrs += test_small_atts(filename, cmode[i]|NC_CLOBBER); #ifdef DEBUG printf("*** testing simple small file with fixed dimensions..."); #endif nerrs += test_small_fixed(filename, cmode[i]|NC_CLOBBER); #ifdef DEBUG printf("*** testing simple small file with an unlimited dimension..."); #endif nerrs += test_small_unlim(filename, cmode[i]|NC_CLOBBER); #ifdef DEBUG printf("*** testing small file with one variable..."); #endif nerrs += test_small_one(filename, cmode[i]|NC_CLOBBER); #ifdef DEBUG printf("*** testing small file with one variable and one att..."); #endif nerrs += test_one_with_att(filename, cmode[i]|NC_CLOBBER); #ifdef DEBUG printf("*** testing small file with one record variable, which grows..."); #endif nerrs += test_one_growing(filename, cmode[i]|NC_CLOBBER); #ifdef DEBUG printf("*** testing small file with one growing record " "variable, with attributes added..."); #endif nerrs += test_one_growing_with_att(filename, cmode[i]|NC_CLOBBER); #ifdef DEBUG if (verbose) printf("*** testing small file with two growing record " "variables, with attributes added..."); #endif nerrs += test_two_growing_with_att(filename, cmode[i]|NC_CLOBBER); } /* check if PnetCDF freed all internal malloc */ MPI_Offset malloc_size, sum_size; err = ncmpi_inq_malloc_size(&malloc_size); if (err == NC_NOERR) { MPI_Reduce(&malloc_size, &sum_size, 1, MPI_OFFSET, MPI_SUM, 0, MPI_COMM_WORLD); if (rank == 0 && sum_size > 0) printf("heap memory allocated by PnetCDF internally has %lld bytes yet to be freed\n", sum_size); } MPI_Allreduce(MPI_IN_PLACE, &nerrs, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD); if (rank == 0) { if (nerrs) printf(FAIL_STR,nerrs); else printf(PASS_STR); } MPI_Finalize(); return 0; }
int main(int argc, char **argv) { int i; char testfile[NC_MAX_NAME + 1]; printf("\n*** Testing small files.\n"); /*nc_set_log_level(3);*/ /* 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 = NUM_FORMATS; i >= 1; i--) { switch (i) { case NC_FORMAT_CLASSIC: nc_set_default_format(NC_FORMAT_CLASSIC, NULL); printf("Switching to netCDF classic format.\n"); strcpy(testfile, "tst_small_classic.nc"); break; case NC_FORMAT_64BIT: nc_set_default_format(NC_FORMAT_64BIT, NULL); printf("Switching to 64-bit offset format.\n"); strcpy(testfile, "tst_small_64bit.nc"); break; #ifdef USE_NETCDF4 case NC_FORMAT_NETCDF4_CLASSIC: nc_set_default_format(NC_FORMAT_NETCDF4_CLASSIC, NULL); strcpy(testfile, "tst_small_netcdf4_classic.nc"); printf("Switching to netCDF-4 format (with NC_CLASSIC_MODEL).\n"); break; case NC_FORMAT_NETCDF4: /* actually it's _CLASSIC. */ nc_set_default_format(NC_FORMAT_NETCDF4, NULL); strcpy(testfile, "tst_small_netcdf4.nc"); printf("Switching to netCDF-4 format.\n"); break; #endif default: printf("Unexpected format!\n"); return 2; } printf("*** testing simple small file with a global attribute..."); test_small_atts(testfile); SUMMARIZE_ERR; printf("*** testing simple small file with fixed dimensions..."); test_small_fixed(testfile); SUMMARIZE_ERR; printf("*** testing simple small file with an unlimited dimension..."); test_small_unlim(testfile); SUMMARIZE_ERR; printf("*** testing small file with one variable..."); test_small_one(testfile); SUMMARIZE_ERR; printf("*** testing small file with one variable and one att..."); test_one_with_att(testfile); SUMMARIZE_ERR; printf("*** testing small file with one record variable, which grows..."); test_one_growing(testfile); SUMMARIZE_ERR; printf("*** testing small file with one growing record " "variable, with attributes added..."); test_one_growing_with_att(testfile); SUMMARIZE_ERR; printf("*** testing small file with two growing record " "variables, with attributes added..."); test_two_growing_with_att(testfile); SUMMARIZE_ERR; } FINAL_RESULTS; }