SCALE-RM
gtool_file.h
Go to the documentation of this file.
1 #ifndef __FILE_SCALE_H__
2 #define __FILE_SCALE_H__
3 
4 #include <stdio.h>
5 #include <stdint.h>
6 #include <stdlib.h>
7 #include <string.h>
8 #include <math.h>
9 
10 /* character length */
11 #define File_HSHORT 16
12 #define File_HMID 64
13 #define File_HLONG 256
14 
15 /* data type */
16 #define File_REAL4 0
17 #define File_REAL8 1
18 #define File_INTEGER2 2
19 #define File_INTEGER4 3
20 #define File_INTEGER8 4
21 
22 /* action type */
23 #define File_FREAD 0
24 #define File_FWRITE 1
25 #define File_FAPPEND 2
26 
27 /* return type */
28 #define ERROR_CODE -1
29 #define SUCCESS_CODE 0
30 #define ALREADY_CLOSED_CODE 1
31 #define ALREADY_EXISTED_CODE 2
32 
33 /* limit of dimension */
34 #define MAX_RANK 10
35 
36 
37 typedef float (real32_t);
38 typedef double(real64_t);
39 
40 /* data item information */
41 typedef struct{
42  char varname[File_HSHORT];
43  char description[File_HMID];
44  char units[File_HSHORT];
45  int32_t datatype;
46  int32_t rank;
47  char dim_name[File_HSHORT*MAX_RANK];
48  int32_t dim_size[MAX_RANK];
49  int32_t step;
50  real64_t time_start;
51  real64_t time_end;
52  char time_units[File_HMID];
53  int32_t fid;
54 } datainfo_t;
55 
56 
57 extern int32_t file_open( int32_t *fid, // (out)
58  char *fname, // (in)
59  int32_t mode); // (in)
60 
61 extern int32_t file_set_option( int32_t fid, // (in)
62  char *filetype, // (in)
63  char *key, // (in)
64  char *val); // (in)
65 
66 extern int32_t file_get_datainfo( datainfo_t *dinfo, // (out)
67  int32_t fid, // (in)
68  char *varname, // (in)
69  int32_t step, // (in)
70  int32_t suppress);// (in)
71 
72 extern int32_t file_read_data( void *var, // (out)
73  datainfo_t *dinfo, // (in)
74  int32_t precision); // (in)
75 
76 extern int32_t file_get_global_attribute_text( int32_t fid, // (in)
77  char *key, // (in)
78  char *value, // (out)
79  int32_t len); // (in)
80 
81 extern int32_t file_get_global_attribute_int( int32_t fid, // (in)
82  char *key, // (in)
83  int32_t *value, // (out)
84  size_t len); // (in)
85 
86 extern int32_t file_get_global_attribute_float( int32_t fid, // (in)
87  char *key, // (in)
88  float *value, // (out)
89  size_t len); // (in)
90 
91 extern int32_t file_get_global_attribute_double( int32_t fid, // (in)
92  char *key, // (in)
93  double *value, // (out)
94  size_t len); // (in)
95 
96 extern int32_t file_set_global_attribute_text( int32_t fid, // (in)
97  char *key, // (in)
98  char *value); // (in)
99 
100 extern int32_t file_set_global_attribute_int( int32_t fid, // (in)
101  char *key, // (in)
102  int32_t *value, // (in)
103  size_t len); // (in)
104 
105 extern int32_t file_set_global_attribute_float( int32_t fid, // (in)
106  char *key, // (in)
107  float *value, // (in)
108  size_t len); // (in)
109 
110 extern int32_t file_set_global_attribute_double( int32_t fid, // (in)
111  char *key, // (in)
112  double *value, // (in)
113  size_t len); // (in)
114 
115 extern int32_t file_set_tunits( int32_t fid, // (in)
116  char *time_units); // (in)
117 
118 extern int32_t file_set_tattr( int32_t fid, // (in)
119  char *vname, // (in)
120  char *key, // (in)
121  char *val); // (in)
122 
123 extern int32_t file_put_axis( int32_t fid, // (in)
124  char *name, // (in)
125  char *desc, // (in)
126  char *units, // (in)
127  char *dim_name, // (in)
128  int32_t dtype, // (in)
129  void *val, // (in)
130  int32_t size, // (in)
131  int32_t precision); // (in)
132 
133 extern int32_t file_put_associated_coordinates( int32_t fid, // (in)
134  char *name, // (in)
135  char *desc, // (in)
136  char *units, // (in)
137  char **dim_names, // (in)
138  int32_t ndims, // (in)
139  int32_t dtype, // (in)
140  void *val, // (in)
141  int32_t precision); // (in)
142 
143 extern int32_t file_add_variable( int32_t *vid, // (out)
144  int32_t fid, // (in)
145  char *varname, // (in)
146  char *desc, // (in)
147  char *units, // (in)
148  char **dims, // (in)
149  int32_t ndims, // (in)
150  int32_t dtype, // (in)
151  real64_t tint, // (in)
152  int32_t tavg); // (in)
153 
154 extern int32_t file_write_data( int32_t fid, // (in)
155  int32_t vid, // (in)
156  void *var, // (in)
157  real64_t t_start, // (in)
158  real64_t t_end, // (in)
159  int32_t precision); // (in)
160 
161 extern int32_t file_close( int32_t fid ); // (in)
162 
163 #endif
int32_t file_set_tunits(int32_t fid, char *time_units)
Definition: gtool_netcdf.c:439
#define File_HMID
Definition: gtool_file.h:12
int32_t step
Definition: gtool_file.h:49
#define MAX_RANK
Definition: gtool_file.h:34
int32_t file_set_tattr(int32_t fid, char *vname, char *key, char *val)
Definition: gtool_netcdf.c:447
int32_t file_set_global_attribute_text(int32_t fid, char *key, char *value)
Definition: gtool_netcdf.c:368
int32_t file_set_global_attribute_double(int32_t fid, char *key, double *value, size_t len)
Definition: gtool_netcdf.c:421
int32_t file_set_global_attribute_float(int32_t fid, char *key, float *value, size_t len)
Definition: gtool_netcdf.c:403
int32_t file_get_global_attribute_int(int32_t fid, char *key, int32_t *value, size_t len)
int32_t file_get_global_attribute_float(int32_t fid, char *key, float *value, size_t len)
Definition: gtool_netcdf.c:332
int32_t file_get_datainfo(datainfo_t *dinfo, int32_t fid, char *varname, int32_t step, int32_t suppress)
Definition: gtool_netcdf.c:162
#define File_HSHORT
Definition: gtool_file.h:11
int32_t file_set_global_attribute_int(int32_t fid, char *key, int32_t *value, size_t len)
real64_t time_start
Definition: gtool_file.h:50
int32_t file_get_global_attribute_double(int32_t fid, char *key, double *value, size_t len)
Definition: gtool_netcdf.c:350
int32_t file_open(int32_t *fid, char *fname, int32_t mode)
Definition: gtool_netcdf.c:97
typedef float(real32_t)
int32_t file_put_axis(int32_t fid, char *name, char *desc, char *units, char *dim_name, int32_t dtype, void *val, int32_t size, int32_t precision)
Definition: gtool_netcdf.c:473
int32_t file_write_data(int32_t fid, int32_t vid, void *var, real64_t t_start, real64_t t_end, int32_t precision)
Definition: gtool_netcdf.c:778
int32_t fid
Definition: gtool_file.h:53
int32_t file_get_global_attribute_text(int32_t fid, char *key, char *value, int32_t len)
Definition: gtool_netcdf.c:294
real64_t time_end
Definition: gtool_file.h:51
int32_t file_put_associated_coordinates(int32_t fid, char *name, char *desc, char *units, char **dim_names, int32_t ndims, int32_t dtype, void *val, int32_t precision)
Definition: gtool_netcdf.c:524
int32_t file_read_data(void *var, datainfo_t *dinfo, int32_t precision)
Definition: gtool_netcdf.c:245
int32_t file_add_variable(int32_t *vid, int32_t fid, char *varname, char *desc, char *units, char **dims, int32_t ndims, int32_t dtype, real64_t tint, int32_t tavg)
Definition: gtool_netcdf.c:579
int32_t datatype
Definition: gtool_file.h:45
int32_t file_close(int32_t fid)
Definition: gtool_netcdf.c:852
typedef double(real64_t)
int32_t file_set_option(int32_t fid, char *filetype, char *key, char *val)
Definition: gtool_netcdf.c:146
int32_t rank
Definition: gtool_file.h:46