FileWriterNetCDF.h
1.8 KB
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
#ifndef FILEWRITERNETCDF_H
#define FILEWRITERNETCDF_H
#include "netcdf.h"
#include "FileWriterAbstract.h"
namespace TREPS
{
namespace File
{
class FileWriterNetCDFClass : public FileWriterAbstractClass
{
public :
FileWriterNetCDFClass(void);
~FileWriterNetCDFClass(void);
//create NetCDF file and add general attributes
bool init(const char *file_path, const map<string,string> *attributes);
//write fields and data to NetCDF file
bool writeData(const DataRecordListClass *data, t_TimeFormat timeFormat,
const char *timePattern, const t_FieldList *fields);
//save NetCDF file
bool save(void);
//close NetCDF file
bool close(void);
//test if the file is opened
bool isOpened(void);
private :
//NetCDF identifier
int ncid;
//get NetCDF variable definition
bool getNetCDFVarTypeDef(const t_Field *field, const DataRecordListClass *data, nc_type &ncType, long &numElts);
//write a dimension in NetCDF file
bool writeDim(const t_Dimension *dim, int &dimid);
//write an unlimited dim in NetCDF file
bool writeUnlimitedDim(t_TimeFormat timeFormat, const char *timePattern, int &unlimitedDimId);
//write a field in NetCDF file
bool writeField(const t_Field *field, const DataRecordListClass *data, int unlimitedDimId);
//write field data in NetCDF file
bool writeFieldData(const t_Field *field, const DataRecordListClass *data,
int typeSize, long numElts, int varId);
//convert data to NetCDF buffer
bool convertData(const t_Field *field, DataRecordClass *record, const char *key,
nc_type ncType, long numElts, void *buffer);
//bool writeData(const t_Field *field, DataRecordClass *record, const char *key, nc_type ncType,
// long numElts, int varId, const size_t index[]);
};
}
}
#endif