本文整理汇总了C++中Var::hasInput方法的典型用法代码示例。如果您正苦于以下问题:C++ Var::hasInput方法的具体用法?C++ Var::hasInput怎么用?C++ Var::hasInput使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Var
的用法示例。
在下文中一共展示了Var::hasInput方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mapTimeDim
void bi::InputNetCDFBuffer::map() {
int ncDim, ncVar;
Var* var;
std::string name;
VarType type;
int i, k, id;
/* ns dimension */
nsDim = nc_inq_dimid(ncid, "ns");
if (nsDim >= 0) {
BI_ERROR_MSG(ns < (int )nc_inq_dimlen(ncid, nsDim),
"Given index " << ns << " outside range of ns dimension");
}
/* np dimension */
npDim = nc_inq_dimid(ncid, "np");
if (npDim >= 0) {
BI_ERROR_MSG(np < 0 || np < (int )nc_inq_dimlen(ncid, npDim),
"Given index " << np << " outside range of np dimension");
}
/* record dimensions, time and coordinate variables */
int nvars = nc_inq_nvars(ncid);
for (i = 0; i < nvars; ++i) {
ncVar = i;
name = nc_inq_varname(ncid, i);
if (name.find("time") == 0) {
/* is a time variable */
ncDim = mapTimeDim(ncVar);
if (ncDim >= 0) {
BOOST_AUTO(iter, std::find(recDims.begin(), recDims.end(), ncDim));
if (iter == recDims.end()) {
/* newly encountered record dimension */
recDims.push_back(ncDim);
timeVars.push_back(ncVar);
coordVars.push_back(-1);
} else {
/* record dimension encountered before */
k = std::distance(recDims.begin(), iter);
BI_ASSERT_MSG(timeVars[k] < 0,
"Time variables " << nc_inq_varname(ncid, timeVars[k]) << " and " << name << " cannot share the same record dimension " << nc_inq_dimname(ncid, *iter));
timeVars[k] = ncVar;
}
}
} else if (name.find("coord") == 0) {
/* is a coordinate variable */
ncDim = mapCoordDim(ncVar);
if (ncDim >= 0) {
BOOST_AUTO(iter, std::find(recDims.begin(), recDims.end(), ncDim));
if (iter == recDims.end()) {
/* newly encountered record dimension */
recDims.push_back(ncDim);
timeVars.push_back(-1);
coordVars.push_back(ncVar);
} else {
/* record dimension encountered before */
k = std::distance(recDims.begin(), iter);
BI_ASSERT_MSG(coordVars[k] < 0,
"Coordinate variables " << nc_inq_varname(ncid, coordVars[k]) << " and " << name << " cannot share the same record dimension " << nc_inq_dimname(ncid, *iter));
coordVars[k] = ncVar;
}
}
}
}
/* model variables */
for (i = 0; i < NUM_VAR_TYPES; ++i) {
type = static_cast<VarType>(i);
/* initialise NetCDF variables for this type */
vars[type].resize(m.getNumVars(type), -1);
/* map model variables */
for (id = 0; id < m.getNumVars(type); ++id) {
var = m.getVar(type, id);
if (var->hasInput()) {
BOOST_AUTO(pair, mapVarDim(var));
k = pair.first;
ncVar = pair.second;
if (ncVar >= 0) {
vars[type][id] = ncVar;
}
modelVars.insert(std::make_pair(k, var));
}
}
}
/* preload random access tables */
std::multimap<real,int> seq;
std::vector<size_t> starts(recDims.size(), 0), lens(recDims.size(), 0);
real tnxt;
for (k = 0; k < int(recDims.size()); ++k) {
if (timeVars[k] >= 0 && modelVars.count(k) > 0) {
/* ^ ignores record dimensions with no associated time or model
* variables */
readTime(timeVars[k], starts[k], &lens[k], &tnxt);
seq.insert(std::make_pair(tnxt, k));
//.........这里部分代码省略.........