当前位置: 首页>>代码示例>>C++>>正文


C++ NcVar::endAtt方法代码示例

本文整理汇总了C++中NcVar::endAtt方法的典型用法代码示例。如果您正苦于以下问题:C++ NcVar::endAtt方法的具体用法?C++ NcVar::endAtt怎么用?C++ NcVar::endAtt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NcVar的用法示例。


在下文中一共展示了NcVar::endAtt方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: testFile


//.........这里部分代码省略.........
      
   // nc_set_log_level(3);
   try
   { 
      NcFile f("tst_file.nc",NcFile::Replace);
      NcGroup *root = f.getRootGroup();
      
      NcDim *latDim = root->addDim(string("lat"),NLAT);
      
      NcDim *lonDim = root->addDim(string("lon"),NLON);
      NcVar *latVar = root->addVar(string("latVar"),ncDouble,latDim);
 
      NcVar *lonVar = root->addVar(string("lonVar"),ncFloat,lonDim);
      NcVar *outIntsVar = root->addVar(string("outintsVar"),ncInt,latDim);
      NcVar *charArrVar = root->addVar(string("CharArray"),ncString,latDim);
      
      latVar->addAtt(string(UNITS),ncChar,string("degrees_north"));
      lonVar->addAtt(string(UNITS),ncChar,string("degrees_south"));
      
      outIntsVar->put(&outInts[0],NLAT,0,0,0,0); 
      charArrVar->put(&chararray[0],NLAT,0,0,0,0);
      
      latVar->put(&lats[0],NLAT,0,0,0,0);
      lonVar->put(&lons[0],NLON,0,0,0,0);
      
      NcVar *presVar = root->addVar(string("press"),ncFloat,latDim,lonDim);
      NcVar *tempVar = root->addVar(string("temp"),ncFloat,latDim,lonDim);
      presVar->addAtt(string("UNITS:"),ncChar,string(pres_units));
      tempVar->addAtt(string("UNITS:"),ncChar,string(temp_units));
      
      presVar->put(&pres_out[0][0],NLAT,NLON,0,0,0);
      tempVar->put(&temp_out[0][0],NLAT,NLON,0,0,0);

      //NcValues *ncvalues = presVar->getValues();
      
      {  //another scope for variables 
	 NcGroup::varIterator variableItr;
	 variableItr = root->beginVar();
	 while(variableItr != root->endVar())
	 {
	    variableItr++;
	 }
	
	 NcVar::attIterator varAttItr;
	 varAttItr = latVar->beginAtt();
	 while(varAttItr != latVar->endAtt())
	 {
	    varAttItr++;
	 }
	
      }
   }
   catch(NcException e)   
   {
      cout<<"FAILURE***"<<endl;
      e.what();
      return 1;
   }
   try
   {
       
      NcFile f1("tst_file.nc",NcFile::ReadOnly);

      NcGroup * root =f1.getRootGroup();
       
      NcGroup::dimIterator dimItr;            //get an iterator to move over the dimensions
      dimItr = root->beginDim();              //created in the file
	 
      while(dimItr != root->endDim())
	 dimItr++;
	 
      NcGroup::attIterator attItr;
      attItr= root->beginAtt();
      while(attItr !=root->endAtt())
	 attItr++;
      
      NcGroup::varIterator variableItr;
      NcVar::attIterator varAttItr;

      variableItr = root->beginVar();
	
      while(variableItr != root->endVar())
      {
	 varAttItr = variableItr->beginAtt();
	 while(varAttItr != variableItr->endAtt())
	    varAttItr++;
	 variableItr++;
      }

   }
   catch(NcException e)   
   {
      cout<<"FAILURE***"<<endl;
      e.what();
      return 1;
   }
  
   cout<<" OK***"<<endl;
   return 0;
}
开发者ID:mmase,项目名称:wgrib2,代码行数:101,代码来源:tst_suite.cpp


注:本文中的NcVar::endAtt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。