资源简介
NetCDF files are self-describing, network-transparent, directly
accessible, and extendible. `Self-describing' means that a netCDF file
includes information about the data it contains. `Network-transparent'
means that a netCDF file is represented in a form that can be accessed
by computers with different ways of storing integers, characters, and
floating-point numbers. `Direct-access' means that a small subset of a
large dataset may be accessed efficiently, without first reading through
all the preceding data. `Extendible' means that data can be appended to
a netCDF dataset without copying it or redefining its structure.
代码片段和文件信息
/*********************************************************************
* Copyright 2005 UCAR/Unidata See COPYRIGHT file for copying and
* redistribution conditions.
*
* This runs the C++ tests for netCDF.
*
* $Id: nctst.cppv 1.28 2007/04/02 21:01:12 ed Exp $
*********************************************************************/
#include
#include
using namespace std;
#include
#include “netcdfcpp.h“
const char LAT[] = “lat“;
const char LON[] = “lon“;
const char FRTIME[] = “frtime“;
const char TIMELEN1[] = “timelen“;
const char P_NAME[] = “P“;
const char PRES_MAX_WIND[] = “pressure at maximum wind“;
const char LONG_NAME[] = “long_name“;
const char UNITS[] = “units“;
const char VALID_RANGE[] = “valid_range“;
const char FILL_VALUE[] = “_FillValue“;
const char DEGREES_NORTH[] = “degrees_north“;
const char LONGITUDE[] = “longitude“;
const char LATITUDE[] = “latitude“;
const char HECTOPASCALS[] = “hectopascals“;
const char DEGREES_EAST[] = “degrees_east“;
const char HOURS[] = “hours“;
const char FORECAST_TIME[] = “forecast time“;
const char REFERENCE_TIME[] = “reference time“;
const char REFTIME[] = “reftime“;
const char TEXT_TIME[] = “text_time“;
const char SCALARV[] = “scalarv“;
const char SCALAR_ATT[] = “scalar_att“;
const int SCALAR_VALUE = 1;
const char HISTORY[] = “history“;
const char title[] = “title“;
const char HISTORY_STR[] = “created by Unidata LDM from NPS broadcast“;
const char title_STR[] = “NMC Global Product Set: Pressure at Maximum Wind“;
const int NC_ERR = 2;
const int NLATS = 4;
const int NLONS = 3;
const int NFRTIMES = 2;
const int TIMESTRINGLEN = 20;
const int NRANGES = 2;
// These are data values written out by the gen() function and read
// in again and checked by the read() function.
static float range[] = {0. 1500.};
static float lats[NLATS] = {-90 -87.5 -85 -82.5};
static float lons[NLONS] = {-180 -175 -170};
static int frtimes[NFRTIMES] = {12 18};
static const char* s = “1992-3-21 12:00“;
static float fill_value = -9999.0;
static float P_data[NFRTIMES][NLATS][NLONS] = {
{{950 951 952} {953 954 955} {956 957 958} {959 960 961}}
{{962 963 964} {965 966 967} {968 969 970} {971 972 973}}
};
// Check a string attribute to make sure it has the correct value.
int
check_string_att(NcAtt *att const char *theName const char *value)
{
if (!att->is_valid() || strncmp(att->name() theName strlen(theName)) ||
att->type() != ncChar || att->num_vals() != (long)strlen(value))
return NC_ERR;
char *value_in = att->as_string(0);
if (strncmp(value_in value strlen(value)))
return NC_ERR;
delete value_in;
return 0;
}
// Check the units and long_name attributes of a var to make sure they
// are what is expected.
int
check_u_ln_atts(NcVar *var const char *units const char *long_name)
{
NcAtt *att;
if (!(att = var->get_att(UNITS)))
return NC_ERR;
if (check_string_att(att UNITS units))
return NC_E
评论
共有 条评论