IODA Bundle
odb2netcdf_main.cc
Go to the documentation of this file.
1 #include <unistd.h>
2 
3 #include <iostream>
4 #include <string>
5 
6 #include <netcdfcpp.h>
7 
8 #include "odb_api/odbcapi.h"
9 #include "odb_api/CommandLineParser.h"
10 #include "odb_api/ODBModule.h"
11 
12 #include "Odb2NetCDF.h"
13 #include "Odb2NetcdfModule.h"
14 
15 /// @author Anne Fouilloux
16 
17 using namespace std;
18 using namespace eckit;
19 using namespace odc;
20 using namespace odc::tool;
21 
22 static const string usage = "Usage: odb2netcdf -i [odb_filename|odb_filename_prefix] [-2d] -o netcdf_filename";
23 
24 int main(int argc, char *argv[])
25 {
26  odb_start_with_args(argc, argv);
27 
28  CommandLineParser args(argc, argv);
29  args.registerOptionWithArgument("-i");
30  args.registerOptionWithArgument("-o");
31 
32  bool twoD (args.optionIsSet("-2d"));
33  string input (args.optionArgument<string>("-i", "")),
34  output (args.optionArgument<string>("-o", ""));
35 
36  if (input.size() && output.size())
37  {
38  if (twoD)
39  {
40  Odb2NetCDF_2D converter (input, output);
41  converter.convert();
42  }
43  else
44  {
45  Odb2NetCDF_1D converter (input, output);
46  converter.convert();
47  }
48  return 0;
49  }
50 
51  cerr << usage << endl;
52 
53  return 1;
54 }
55 
virtual void convert()
Definition: Odb2NetCDF.cc:77
virtual void convert()
Definition: Odb2NetCDF.cc:133
Definition: ColumnInfo.h:23
Definition: encode.cc:30
int main(int argc, char *argv[])
static const string usage
void odb_start_with_args(int argc, char *argv[])
Definition: odccapi.cc:85