/********************************************************************* * * Copyright (C) 2014, Northwestern University and Argonne National Laboratory * See COPYRIGHT notice in top-level directory. * *********************************************************************/ /* $Id$ */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * This example tests nonblocking varn APIs, including * ncmpi_iput_varn_longlong(), ncmpi_iget_varn_longlong(), ncmpi_iput_varn(), * and ncmpi_iget_varn(). * It first writes a sequence of requests with arbitrary array indices and * lengths to four variables of type NC_INT64, and reads back. * * The compile and run commands are given below, together with an ncmpidump of * the output file. * * % mpicc -O2 -o i_varn_int64 i_varn_int64.c -lpnetcdf * % mpiexec -n 4 ./i_varn_int64 /pvfs2/wkliao/testfile.nc * % ncmpidump /pvfs2/wkliao/testfile.nc * netcdf testfile { * // file format: CDF-5 (big variables) * dimensions: * Y = 4 ; * X = 10 ; * variables: * int64 var0(Y, X) ; * int64 var1(Y, X) ; * int64 var2(Y, X) ; * int64 var3(Y, X) ; * data: * * var0 = * 1, 1, 1, 3, 3, 0, 0, 2, 3, 3, * 0, 2, 2, 2, 1, 3, 3, 2, 2, 2, * 3, 3, 2, 1, 1, 1, 0, 0, 3, 3, * 0, 0, 0, 2, 3, 3, 3, 1, 1, 1 ; * * var1 = * 2, 2, 2, 0, 0, 1, 1, 3, 0, 0, * 1, 3, 3, 3, 2, 0, 0, 3, 3, 3, * 0, 0, 3, 2, 2, 2, 1, 1, 0, 0, * 1, 1, 1, 3, 0, 0, 0, 2, 2, 2 ; * * var2 = * 3, 3, 3, 1, 1, 2, 2, 0, 1, 1, * 2, 0, 0, 0, 3, 1, 1, 0, 0, 0, * 1, 1, 0, 3, 3, 3, 2, 2, 1, 1, * 2, 2, 2, 0, 1, 1, 1, 3, 3, 3 ; * * var3 = * 0, 0, 0, 2, 2, 3, 3, 1, 2, 2, * 3, 1, 1, 1, 0, 2, 2, 1, 1, 1, * 2, 2, 1, 0, 0, 0, 3, 3, 2, 2, * 3, 3, 3, 1, 2, 2, 2, 0, 0, 0 ; * } * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #include #include #include /* strcpy(), strncpy() */ #include /* getopt() */ #include #include #define NY 4 #define NX 10 #define NDIMS 2 #define ERR {if(err!=NC_NOERR){printf("Error at line %d in %s: %s\n", __LINE__,__FILE__, ncmpi_strerror(err));nerrs++;}} #define ERRS(n,a) { \ int _i; \ for (_i=0; _i<(n); _i++) { \ if ((a)[_i] != NC_NOERR) { \ printf("Error at line %d in %s: err[%d] %s\n", __LINE__, __FILE__, _i, \ ncmpi_strerror((a)[_i])); \ nerrs++; \ } \ } \ } static MPI_Offset *** calloc_3D(size_t z, size_t y, size_t x) { if (z*y*x == 0) return NULL; int _j, _k; MPI_Offset ***buf = (MPI_Offset***) malloc(z * sizeof(MPI_Offset**)); MPI_Offset **bufy = (MPI_Offset**) malloc(z*y * sizeof(MPI_Offset*)); MPI_Offset *bufx = (MPI_Offset*) calloc(z*y*x, sizeof(MPI_Offset)); for (_k=0; _k= 4) nreqs = 0; /* calculate length of each varn request, number of segments in each * varn request, and allocate write buffer */ for (i=0; i= 4) nerrs += check_contents(ncid, varid); /* read using get_varn API and check contents */ for (i=0; i= 4) nerrs += check_contents(ncid, varid); /* test flexible get API, using a noncontiguous buftype */ for (i=0; i 0) printf("heap memory allocated by PnetCDF internally has %lld bytes yet to be freed\n", sum_size); } MPI_Finalize(); return (nerrs > 0); }