mirror of
https://github.com/Unidata/netcdf-c.git
synced 2024-11-27 07:30:33 +08:00
Updated an old benchmark script and ref files to accomodate updated metadata reported by ncdump.
This commit is contained in:
parent
1c11fc5d59
commit
dd557c1919
@ -1,4 +1,4 @@
|
||||
/** \file
|
||||
/** \file
|
||||
|
||||
This program benchmarks creating a netCDF file and reading records.
|
||||
|
||||
@ -8,6 +8,7 @@ redistribution conditions.
|
||||
|
||||
#include <config.h>
|
||||
#include <nc_tests.h>
|
||||
#include "err_macros.h"
|
||||
#include <netcdf.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@ -28,7 +29,7 @@ int main(int argc, char **argv)
|
||||
int g, grp, numgrp;
|
||||
char gname[16];
|
||||
int v, var, numvar, vn, vleft, nvars;
|
||||
|
||||
|
||||
int stat; /* return status */
|
||||
|
||||
/* dimension ids */
|
||||
@ -73,7 +74,7 @@ int main(int argc, char **argv)
|
||||
temperature_2m_dims[1] = forecast_dim;
|
||||
temperature_2m_dims[2] = latitude_dim;
|
||||
temperature_2m_dims[3] = longitude_dim;
|
||||
if (nc_def_var(ncid, "temperature_2m", NC_FLOAT, RANK_temperature_2m,
|
||||
if (nc_def_var(ncid, "temperature_2m", NC_FLOAT, RANK_temperature_2m,
|
||||
temperature_2m_dims, &temperature_2m_id)) ERR;
|
||||
|
||||
/* assign per-variable attributes */
|
||||
@ -89,6 +90,6 @@ int main(int argc, char **argv)
|
||||
if (nc_close(ncid)) ERR;
|
||||
|
||||
if (gettimeofday(&start_time, NULL)) ERR;
|
||||
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
@ -6,15 +6,21 @@ dimensions:
|
||||
variables:
|
||||
float var_contiguous(dim1, dim2, dim3) ;
|
||||
var_contiguous:_Storage = "contiguous" ;
|
||||
var_contiguous:_Endianness = "little" ;
|
||||
float var_chunked(dim1, dim2, dim3) ;
|
||||
var_chunked:_Storage = "chunked" ;
|
||||
var_chunked:_ChunkSizes = 2, 3, 1 ;
|
||||
var_chunked:_Endianness = "little" ;
|
||||
float var_compressed(dim1, dim2, dim3) ;
|
||||
var_compressed:_Storage = "chunked" ;
|
||||
var_compressed:_ChunkSizes = 2, 3, 1 ;
|
||||
var_compressed:_DeflateLevel = 1 ;
|
||||
var_compressed:_Endianness = "little" ;
|
||||
|
||||
// global attributes:
|
||||
:_NCProperties = "version=1|netcdflibversion=4.4.2-development|hdf5libversion=1.8.17" ;
|
||||
:_SuperblockVersion = 0 ;
|
||||
:_IsNetcdf4 = 1 ;
|
||||
:_Format = "netCDF-4 classic model" ;
|
||||
data:
|
||||
|
||||
|
@ -6,14 +6,20 @@ dimensions:
|
||||
variables:
|
||||
float var_contiguous(dim1, dim2, dim3) ;
|
||||
var_contiguous:_Storage = "contiguous" ;
|
||||
var_contiguous:_Endianness = "little" ;
|
||||
float var_chunked(dim1, dim2, dim3) ;
|
||||
var_chunked:_Storage = "chunked" ;
|
||||
var_chunked:_ChunkSizes = 8, 10, 13 ;
|
||||
var_chunked:_Endianness = "little" ;
|
||||
float var_compressed(dim1, dim2, dim3) ;
|
||||
var_compressed:_Storage = "chunked" ;
|
||||
var_compressed:_ChunkSizes = 8, 10, 13 ;
|
||||
var_compressed:_DeflateLevel = 1 ;
|
||||
var_compressed:_Endianness = "little" ;
|
||||
|
||||
// global attributes:
|
||||
:_NCProperties = "version=1|netcdflibversion=4.4.2-development|hdf5libversion=1.8.17" ;
|
||||
:_SuperblockVersion = 0 ;
|
||||
:_IsNetcdf4 = 1 ;
|
||||
:_Format = "netCDF-4 classic model" ;
|
||||
}
|
||||
|
@ -39,4 +39,4 @@ cachepre=0.0
|
||||
diff tst_chunks3.cdl ref_chunks2.cdl
|
||||
echo '*** SUCCESS!!!'
|
||||
|
||||
exit 0
|
||||
exit 0
|
||||
|
@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
#include <nc_tests.h>
|
||||
#include "err_macros.h"
|
||||
#include "netcdf.h"
|
||||
#include <unistd.h>
|
||||
#include <time.h>
|
||||
@ -50,7 +51,7 @@ main(int argc, char **argv)
|
||||
{
|
||||
|
||||
#define BUFSIZE 1000000 /* access data in megabyte sized pieces */
|
||||
#define THETAU_FILE "/machine/downloads/AR5_sample_data/thetao_O1.SRESA1B_2.CCSM.ocnm.2000-01_cat_2099-12.nc"
|
||||
#define THETAU_FILE "/machine/downloads/AR5_sample_data/thetao_O1.SRESA1B_2.CCSM.ocnm.2000-01_cat_2099-12.nc"
|
||||
#define NDIMS_DATA 4
|
||||
printf("\n*** Running some AR-5 benchmarks.\n");
|
||||
printf("*** testing various chunksizes for thetau file...\n");
|
||||
@ -89,7 +90,7 @@ main(int argc, char **argv)
|
||||
/* /\* if (nc_out_vara_double(ncid, varid, start, count, data)) ERR; *\/ */
|
||||
/* /\* } *\/ */
|
||||
/* /\* if (nvals < 0) ERR; *\/ */
|
||||
|
||||
|
||||
/* if (nc_close(ncid)) ERR; */
|
||||
/* if (nc_close(ncid_out)) ERR; */
|
||||
}
|
||||
|
@ -2,13 +2,14 @@
|
||||
Copyright 2005 University Corporation for Atmospheric Research/Unidata
|
||||
See COPYRIGHT file for conditions of use.
|
||||
|
||||
Test internal netcdf-4 file code.
|
||||
Test internal netcdf-4 file code.
|
||||
$Id: tst_files3.c,v 1.5 2010/02/02 17:19:28 ed Exp $
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <stdio.h>
|
||||
#include <nc_tests.h>
|
||||
#include "err_macros.h"
|
||||
#include "netcdf.h"
|
||||
#include <hdf5.h>
|
||||
#include <unistd.h>
|
||||
@ -17,7 +18,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#define NDIMS1 1
|
||||
#define NDIMS 3
|
||||
#define NDIMS 3
|
||||
#define FILE_NAME "tst_files3.nc"
|
||||
#define X_LEN 120
|
||||
#define Y_LEN 64
|
||||
@ -38,7 +39,7 @@ int dump_file2(const float *data, int docompression, int usedefdim)
|
||||
if (nc_def_dim(ncid, "lat", Y_LEN, &dimids[1])) ERR_RET;
|
||||
if (nc_def_dim(ncid, "lon", Z_LEN, &dimids[2])) ERR_RET;
|
||||
if (nc_def_var(ncid, "test", NC_FLOAT, NDIMS, dimids, &var)) ERR_RET;
|
||||
if (docompression)
|
||||
if (docompression)
|
||||
if (nc_def_var_deflate(ncid, var, 1, 1, 1)) ERR_RET;
|
||||
if (nc_enddef(ncid)) ERR_RET;
|
||||
for (start[0] = 0; start[0] < X_LEN; start[0]++)
|
||||
@ -62,7 +63,7 @@ int dump_file(const float *data, int docompression, int usedefdim)
|
||||
if (nc_def_dim(ncid, "lat", Y_LEN, &dimids[1])) ERR_RET;
|
||||
if (nc_def_dim(ncid, "lon", Z_LEN, &dimids[2])) ERR_RET;
|
||||
if (nc_def_var(ncid, "test", NC_FLOAT, NDIMS, dimids, &var)) ERR_RET;
|
||||
if (docompression)
|
||||
if (docompression)
|
||||
if (nc_def_var_deflate(ncid, var, 1, 1, 1)) ERR_RET;
|
||||
if (nc_enddef(ncid)) ERR_RET;
|
||||
if (nc_put_vars_float(ncid, var, start, count, stride, data)) ERR_RET;
|
||||
@ -84,7 +85,7 @@ int dump_file3(const float *data, int docompression, int usedefdim)
|
||||
if (nc_def_dim(ncid, "lat", Y_LEN, &dimids[1])) ERR_RET;
|
||||
if (nc_def_dim(ncid, "lon", Z_LEN, &dimids[2])) ERR_RET;
|
||||
if (nc_def_var(ncid, "test", NC_FLOAT, NDIMS, dimids, &var)) ERR_RET;
|
||||
if (docompression)
|
||||
if (docompression)
|
||||
if (nc_def_var_deflate(ncid, var, 1, 1, 1)) ERR_RET;
|
||||
if (nc_enddef(ncid)) ERR_RET;
|
||||
if (nc_put_vars_float(ncid, var, start, count, stride, data)) ERR_RET;
|
||||
@ -109,7 +110,7 @@ int dump_hdf_file(const float *data, int docompression)
|
||||
/* create property for dataset */
|
||||
propid = H5Pcreate(H5P_DATASET_CREATE);
|
||||
|
||||
if (docompression)
|
||||
if (docompression)
|
||||
{
|
||||
if (H5Pset_layout(propid, H5D_CHUNKED) < 0) ERR;
|
||||
if (H5Pset_chunk(propid, NDIMS, dims) < 0) ERR;
|
||||
@ -127,7 +128,7 @@ int dump_hdf_file(const float *data, int docompression)
|
||||
CHUNK_CACHE_SIZE, CHUNK_CACHE_PREEMPTION) < 0) ERR;
|
||||
|
||||
/* Create the dataset. */
|
||||
if ((dataset_id = H5Dcreate2(file_id, "dset", H5T_NATIVE_FLOAT, file_spaceid,
|
||||
if ((dataset_id = H5Dcreate2(file_id, "dset", H5T_NATIVE_FLOAT, file_spaceid,
|
||||
H5P_DEFAULT, propid, access_plistid)) < 0) ERR;
|
||||
|
||||
/* if ((file_spaceid = H5Dget_space(dataset_id)) < 0) ERR;*/
|
||||
@ -138,9 +139,9 @@ int dump_hdf_file(const float *data, int docompression)
|
||||
for (start[0] = 0; start[0] < X_LEN; start[0]++)
|
||||
for (start[1] = 0; start[1] < Y_LEN; start[1]++)
|
||||
{
|
||||
if (H5Sselect_hyperslab(file_spaceid, H5S_SELECT_SET, start, NULL,
|
||||
if (H5Sselect_hyperslab(file_spaceid, H5S_SELECT_SET, start, NULL,
|
||||
count, NULL) < 0) ERR_RET;
|
||||
if (H5Dwrite(dataset_id, H5T_NATIVE_FLOAT, mem_spaceid, file_spaceid,
|
||||
if (H5Dwrite(dataset_id, H5T_NATIVE_FLOAT, mem_spaceid, file_spaceid,
|
||||
xfer_plistid, data) < 0) ERR_RET;
|
||||
}
|
||||
|
||||
@ -166,7 +167,7 @@ get_mem_used2(int *mem_used)
|
||||
{
|
||||
char buf[30];
|
||||
FILE *pf;
|
||||
|
||||
|
||||
snprintf(buf, 30, "/proc/%u/statm", (unsigned)getpid());
|
||||
pf = fopen(buf, "r");
|
||||
if (pf) {
|
||||
@ -177,7 +178,7 @@ get_mem_used2(int *mem_used)
|
||||
unsigned lib;/* library */
|
||||
unsigned data;/* data/stack */
|
||||
/*unsigned dt; dirty pages (unused in Linux 2.6)*/
|
||||
fscanf(pf, "%u %u %u %u %u %u", &size, &resident, &share,
|
||||
fscanf(pf, "%u %u %u %u %u %u", &size, &resident, &share,
|
||||
&text, &lib, &data);
|
||||
*mem_used = data;
|
||||
}
|
||||
@ -190,7 +191,7 @@ int main(void)
|
||||
{
|
||||
float data[X_LEN * Y_LEN * Z_LEN];
|
||||
int i;
|
||||
|
||||
|
||||
printf("\n*** Testing netcdf-4 file functions with caching.\n");
|
||||
|
||||
/* Initialize data. */
|
||||
@ -201,7 +202,7 @@ int main(void)
|
||||
int mem_used, mem_used1;
|
||||
|
||||
printf("*** testing netcdf-4 writes...\n");
|
||||
for (i = 0; i < NUM_TRIES; i++)
|
||||
for (i = 0; i < NUM_TRIES; i++)
|
||||
{
|
||||
get_mem_used2(&mem_used);
|
||||
if (dump_file3(data, 1, 0)) ERR_RET;
|
||||
|
@ -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_h_files3.c,v 1.2 2010/02/05 17:06:28 ed Exp $
|
||||
*/
|
||||
|
||||
#include <nc_tests.h>
|
||||
#include "err_macros.h"
|
||||
#include "netcdf.h"
|
||||
#include <unistd.h>
|
||||
#include <time.h>
|
||||
@ -26,7 +27,7 @@ get_mem_used2(int *mem_used)
|
||||
{
|
||||
char buf[30];
|
||||
FILE *pf;
|
||||
|
||||
|
||||
snprintf(buf, 30, "/proc/%u/statm", (unsigned)getpid());
|
||||
pf = fopen(buf, "r");
|
||||
if (pf) {
|
||||
@ -37,7 +38,7 @@ get_mem_used2(int *mem_used)
|
||||
unsigned lib;/* library */
|
||||
unsigned data;/* data/stack */
|
||||
/*unsigned dt; dirty pages (unused in Linux 2.6)*/
|
||||
fscanf(pf, "%u %u %u %u %u %u", &size, &resident, &share,
|
||||
fscanf(pf, "%u %u %u %u %u %u", &size, &resident, &share,
|
||||
&text, &lib, &data);
|
||||
*mem_used = data;
|
||||
}
|
||||
@ -75,7 +76,7 @@ main(int argc, char **argv)
|
||||
/* if ((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0) ERR; */
|
||||
/* if ((fileid = H5Fopen(FILE_NAME2, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) ERR; */
|
||||
/* if ((grpid = H5Gopen(fileid, "/")) < 0) ERR; */
|
||||
|
||||
|
||||
/* if ((datasetid = H5Dopen2(grpid, obj_name2, H5P_DEFAULT)) < 0) ERR; */
|
||||
/* num_scales = H5DSget_num_scales(datasetid, 0); */
|
||||
|
||||
@ -143,7 +144,7 @@ main(int argc, char **argv)
|
||||
/* H5F_LIBVER_LATEST) < 0) ERR; */
|
||||
/* if ((fileid = H5Fopen(FILE_NAME2, H5F_ACC_RDONLY, fapl_id)) < 0) ERR; */
|
||||
/* if ((grpid = H5Gopen(fileid, "/")) < 0) ERR; */
|
||||
|
||||
|
||||
/* if (H5Gget_num_objs(grpid, &num_obj) < 0) ERR; */
|
||||
/* if (num_obj > MAX_OBJ) ERR; */
|
||||
/* for (i = 0; i < num_obj; i++) */
|
||||
@ -195,7 +196,7 @@ main(int argc, char **argv)
|
||||
/* if (H5Pclose(access_pid)) ERR; */
|
||||
/* if (H5Sclose(spaceid)) ERR; */
|
||||
/* } */
|
||||
|
||||
|
||||
/* get_mem_used2(&mem_used1); */
|
||||
|
||||
/* /\* Close everything. *\/ */
|
||||
|
@ -1,12 +1,13 @@
|
||||
/** \file
|
||||
|
||||
Performance test from KNMI.
|
||||
|
||||
|
||||
Copyright 2009, UCAR/Unidata. See \ref copyright file for copying and
|
||||
redistribution conditions.
|
||||
*/
|
||||
|
||||
#include <nc_tests.h>
|
||||
#include "err_macros.h"
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
@ -38,7 +39,7 @@ complain(int stat)
|
||||
return stat;
|
||||
}
|
||||
|
||||
static int
|
||||
static int
|
||||
read_file(char *filename)
|
||||
{
|
||||
#define CWP "cwp"
|
||||
@ -73,7 +74,7 @@ read_file(char *filename)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
int c, header = 0, verbose = 0, timeseries = 0;
|
||||
@ -91,10 +92,9 @@ main(int argc, char **argv)
|
||||
struct timeval start_time, end_time, diff_time;
|
||||
|
||||
printf("\n*** Testing netcdf-4 vs. netcdf-3 performance.\n");
|
||||
if (complain(read_file(FILE_NAME_1))) ERR;
|
||||
if (complain(read_file(FILE_NAME_2))) ERR;
|
||||
if (complain(read_file(FILE_NAME_1))) ERR;
|
||||
if (complain(read_file(FILE_NAME_2))) ERR;
|
||||
|
||||
SUMMARIZE_ERR;
|
||||
FINAL_RESULTS;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user