1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
| #include <iostream>
#include <netcdfcpp.h>
#include <vector>
using namespace std;
static const int NX = 12;
static const int NY = 6;
static const int NC_ERR = 2;
int main(void)
{
int dataOut[NX][NY];
for(int i = 0; i < NX; i++)
for(int j = 0; j < NY; j++)
dataOut[i][j] = i * NY + j;
NcFile dataFile("chaine.nc", NcFile::Replace);
if (!dataFile.is_valid())
{
cout << "Couldn't open file!\n";
return NC_ERR;
}
NcDim* xDim = dataFile.add_dim("x", NX);
NcDim* yDim = dataFile.add_dim("y", NY);
NcVar *monChar1 = dataFile.add_var("monChar1", ncChar, xDim, yDim);
vector<string> dataOut1Vec;
string str = "az";
str.resize(6);
dataOut1Vec.push_back(str);
str = "aa";
str.resize(6);
dataOut1Vec.push_back(str);
str = "aaa";
str.resize(6);
dataOut1Vec.push_back(str);
str = "aaaa";
str.resize(6);
dataOut1Vec.push_back(str);
str = "aaa";
str.resize(6);
dataOut1Vec.push_back(str);
str = "aa";
str.resize(6);
dataOut1Vec.push_back(str);
str = "a";
str.resize(6);
dataOut1Vec.push_back(str);
str = "1aaaa";
str.resize(6);
dataOut1Vec.push_back(str);
str = "aa";
str.resize(6);
dataOut1Vec.push_back(str);
str = "aa";
str.resize(6);
dataOut1Vec.push_back(str);
str = "aa";
str.resize(6);
dataOut1Vec.push_back(str);
str = "aa";
str.resize(6);
dataOut1Vec.push_back(str);
for(int i=0 ; i<12 ;i++)
monChar1->put_rec(xDim, &(dataOut1Vec[i][0]), i);
return 0;
} |
Partager