c++读取NetCdf文件

来源:百度知道 编辑:UC知道 时间:2024/05/19 18:30:25
怎么用c++读取NetCdf文件呢??我知道有接口可以做,netcdf-4.0提供了些接口和函数,可我却没有办法把这些函数整合起来,问问大家怎么办啊!非常着急!我的qq67136925,欢迎大家一起讨论Netcdf,Netcdf技术群
36563503

一般读取文件的方法(如*.txt|*.dat):
#include <fstream>
char add[]="文件路径":
void read(char addres[],string &s)
{
fstream infile(addres,ios::in);
if(! infile)
{
cerr<<" 文件打开失败"<<endl;
exit(1);
}
infile>>s;
infile.close();
}

#include <iostream>
#include <netcdfcpp.h>
using namespace std;
// We are reading 2D data, a 6 x 12 grid.
static const int NX = 6;
static const int NY = 12;
// Return this in event of a problem.
static const int NC_ERR = 2;
int main(void)
{
// This is the array we will read.
int dataIn[NX][NY];
// Open&nbs