SCALE-RM
scale_file.h
Go to the documentation of this file.
1 #ifndef __SCALE_FILE_H__
2 #define __SCALE_FILE_H__
3 
4 #include <stdio.h>
5 #include <stdint.h>
6 #include <stdlib.h>
7 #include <stdbool.h>
8 #include <string.h>
9 #include <math.h>
10 #include <mpi.h>
11 
12 
13 #include "scale_file_const.h"
14 
15 
16 typedef float (real32_t);
17 typedef double(real64_t);
18 
19 /* data item information */
20 typedef struct{
21  char varname[File_HSHORT];
23  char units[File_HSHORT];
24  char standard_name[File_HMID];
25  int32_t datatype;
26  int32_t rank;
27  char dim_name[File_HSHORT*RANK_MAX];
28  int32_t dim_size[RANK_MAX];
29  int32_t step;
30  _Bool has_tdim;
31  real64_t time_start;
32  real64_t time_end;
33  char time_units[File_HMID];
34  char calendar[File_HSHORT];
35  int32_t natts;
36  char att_name[File_HSHORT*ATT_MAX];
37  int32_t att_type[ATT_MAX];
38  int32_t att_len[ATT_MAX];
39  int32_t fid;
40 } datainfo_t;
41 
42 
43 extern int file_open_c( int *fid, // (out)
44  const char *fname, // (in)
45  const int mode, // (in)
46  const int comm); // (in)
47 
48 extern int file_get_dim_length_c( int *len, // (out)
49  const int fid, // (in)
50  const char *dimname, // (in)
51  const bool suppress ); // (in)
52 
53 extern int file_set_option_c( const int fid, // (in)
54  const char *filetype, // (in)
55  const char *key, // (in)
56  const char *val); // (in)
57 
58 extern int file_get_nvars_c( int *nvars, // (out)
59  const int fid); // (in)
60 
61 
62 extern int file_get_varname_c( char *name, // (out)
63  const int fid, // (in)
64  const int vid, // (in)
65  const int len); // (in)
66 
67 extern int file_get_datainfo_c( datainfo_t *dinfo, // (out)
68  const int fid, // (in)
69  const char *varname, // (in)
70  const int step, // (in)
71  const bool suppress ); // (in)
72 
73 extern int file_get_step_size_c( int *len, // (out)
74  const int fid, // (in)
75  const char *varname); // (in)
76 
77 
78 extern int file_read_data_c( void *var, // (out)
79  const datainfo_t *dinfo, // (in)
80  const int precision, // (in)
81  const int ntypes, // (in)
82  const int dtype, // (in)
83  const int *start, // (in)
84  const int *count ); // (in)
85 
86 extern int file_get_attribute_text_c( char *value, // (out)
87  const int fid, // (in)
88  const char *vname, // (in)
89  const char *key, // (in)
90  const bool suppress, // (in)
91  const int len); // (in)
92 
93 extern int file_get_attribute_int_c( int *value, // (out)
94  const int fid, // (in)
95  const char *vname, // (in)
96  const char *key, // (in)
97  const bool suppress, // (in)
98  const int len); // (in)
99 
100 extern int file_get_attribute_float_c( float *value, // (out)
101  const int fid, // (in)
102  const char *vname, // (in)
103  const char *key, // (in)
104  const bool suppress, // (in)
105  const int len); // (in)
106 
107 extern int file_get_attribute_double_c( double *value, // (out)
108  const int fid, // (in)
109  const char *vname, // (in)
110  const char *key, // (in)
111  const bool suppress, // (in)
112  const int len); // (in)
113 
114 extern int file_set_attribute_text_c( const int fid, // (in)
115  const char *vname, // (in)
116  const char *key, // (in)
117  const char *value); // (in)
118 
119 extern int file_set_attribute_int_c( const int fid, // (in)
120  const char *vname, // (in)
121  const char *key, // (in)
122  const int *value, // (in)
123  const int len); // (in)
124 
125 extern int file_set_attribute_float_c( const int fid, // (in)
126  const char *vname, // (in)
127  const char *key, // (in)
128  const float *value, // (in)
129  const int len); // (in)
130 
131 extern int file_set_attribute_double_c( const int fid, // (in)
132  const char *vname, // (in)
133  const char *key, // (in)
134  const double *value, // (in)
135  const int len); // (in)
136 
137 extern int file_add_associatedvariable_c( const int fid, // (in)
138  const char *vname); // (in)
139 
140 extern int file_set_tunits_c( const int fid, // (in)
141  const char *time_units, // (in)
142  const char *calendar); // (in)
143 
144 extern int file_put_axis_c( const int fid, // (in)
145  const char *name, // (in)
146  const char *desc, // (in)
147  const char *units, // (in)
148  const char *dim_name, // (in)
149  const int dtype, // (in)
150  const void *val, // (in)
151  const int size, // (in)
152  const int precision); // (in)
153 
154 extern int file_def_axis_c( const int fid, // (in)
155  const char *name, // (in)
156  const char *desc, // (in)
157  const char *units, // (in)
158  const char *dim_name, // (in)
159  const int dtype, // (in)
160  const int dim_size, // (in)
161  const int bounds); // (in)
162 
163 extern int file_write_axis_c( const int fid, // (in)
164  const char *name, // (in)
165  const void *val, // (in)
166  const int precision, // (in)
167  const int *start, // (in)
168  const int *count); // (in)
169 
170 extern int file_put_associatedcoordinate_c( const int fid, // (in)
171  const char *name, // (in)
172  const char *desc, // (in)
173  const char *units, // (in)
174  const char **dim_names, // (in)
175  const int ndims, // (in)
176  const int dtype, // (in)
177  const void *val, // (in)
178  const int precision); // (in)
179 
180 extern int file_def_associatedcoordinate_c( const int fid, // (in)
181  const char *name, // (in)
182  const char *desc, // (in)
183  const char *units, // (in)
184  const char **dim_names, // (in)
185  const int ndims, // (in)
186  const int dtype); // (in)
187 
188 extern int file_write_associatedcoordinate_c( const int fid, // (in)
189  const char *name, // (in)
190  const void *val, // (in)
191  const int ndims, // (in)
192  const int precision, // (in)
193  const int *start, // (in)
194  const int *count); // (in)
195 
196 extern int file_add_variable_c( int *vid, // (out)
197  const int fid, // (in)
198  const char *varname, // (in)
199  const char *desc, // (in)
200  const char *units, // (in)
201  const char *stdname, // (in)
202  const char **dims, // (in)
203  const int ndims, // (in)
204  const int dtype, // (in)
205  const double tint, // (in)
206  const char *tstats); // (in)
207 
208 extern int file_write_data_c( const int fid, // (in)
209  const int vid, // (in)
210  const void *var, // (in)
211  const double t_start, // (in)
212  const double t_end, // (in)
213  const int ndims, // (in)
214  const int precision, // (in)
215  const int *start, // (in)
216  const int *count); // (in)
217 
218 extern int file_enddef_c( const int fid ); // (in)
219 extern int file_redef_c( const int fid ); // (in)
220 
221 extern int file_attach_buffer_c( const int fid, // (in)
222  const int64_t buf_amount ); // (in)
223 
224 extern int file_detach_buffer_c( const int fid ); // (in)
225 
226 extern int file_flush_c( const int fid ); // (in)
227 
228 extern int file_close_c( const int fid, // (in)
229  const bool abort ); // (in)
230 
231 #endif
datainfo_t
Definition: scale_file.h:20
file_add_associatedvariable_c
int file_add_associatedvariable_c(const int fid, const char *vname)
Definition: scale_file_netcdf.c:1204
file_def_axis_c
int file_def_axis_c(const int fid, const char *name, const char *desc, const char *units, const char *dim_name, const int dtype, const int dim_size, const int bounds)
Definition: scale_file_netcdf.c:1286
datainfo_t::time_end
real64_t time_end
Definition: scale_file.h:32
file_read_data_c
int file_read_data_c(void *var, const datainfo_t *dinfo, const int precision, const int ntypes, const int dtype, const int *start, const int *count)
Definition: scale_file_netcdf.c:697
file_write_associatedcoordinate_c
int file_write_associatedcoordinate_c(const int fid, const char *name, const void *val, const int ndims, const int precision, const int *start, const int *count)
Definition: scale_file_netcdf.c:1500
file_detach_buffer_c
int file_detach_buffer_c(const int fid)
Definition: scale_file_netcdf.c:1854
file_set_attribute_float_c
int file_set_attribute_float_c(const int fid, const char *vname, const char *key, const float *value, const int len)
Definition: scale_file_netcdf.c:1124
file_get_dim_length_c
int file_get_dim_length_c(int *len, const int fid, const char *dimname, const bool suppress)
Definition: scale_file_netcdf.c:258
file_redef_c
int file_redef_c(const int fid)
Definition: scale_file_netcdf.c:1829
file_close_c
int file_close_c(const int fid, const bool abort)
Definition: scale_file_netcdf.c:2006
float
typedef float(real32_t)
datainfo_t::has_tdim
_Bool has_tdim
Definition: scale_file.h:30
file_get_attribute_double_c
int file_get_attribute_double_c(double *value, const int fid, const char *vname, const char *key, const bool suppress, const int len)
Definition: scale_file_netcdf.c:997
file_get_step_size_c
int file_get_step_size_c(int *len, const int fid, const char *varname)
Definition: scale_file_netcdf.c:643
file_get_varname_c
int file_get_varname_c(char *name, const int fid, const int vid, const int len)
Definition: scale_file_netcdf.c:320
file_get_attribute_int_c
int file_get_attribute_int_c(int *value, const int fid, const char *vname, const char *key, const bool suppress, const int len)
Definition: scale_file_netcdf.c:911
RANK_MAX
#define RANK_MAX
Definition: scale_file_const.h:30
datainfo_t::fid
int32_t fid
Definition: scale_file.h:39
datainfo_t::datatype
int32_t datatype
Definition: scale_file.h:25
file_set_attribute_text_c
int file_set_attribute_text_c(const int fid, const char *vname, const char *key, const char *value)
Definition: scale_file_netcdf.c:1040
scale_file_const.h
file_put_associatedcoordinate_c
int file_put_associatedcoordinate_c(const int fid, const char *name, const char *desc, const char *units, const char **dim_names, const int ndims, const int dtype, const void *val, const int precision)
Definition: scale_file_netcdf.c:1397
File_HSHORT
#define File_HSHORT
Definition: scale_file_const.h:2
datainfo_t::rank
int32_t rank
Definition: scale_file.h:26
file_get_datainfo_c
int file_get_datainfo_c(datainfo_t *dinfo, const int fid, const char *varname, const int step, const bool suppress)
Definition: scale_file_netcdf.c:345
file_set_attribute_double_c
int file_set_attribute_double_c(const int fid, const char *vname, const char *key, const double *value, const int len)
Definition: scale_file_netcdf.c:1166
file_write_data_c
int file_write_data_c(const int fid, const int vid, const void *var, const double t_start, const double t_end, const int ndims, const int precision, const int *start, const int *count)
Definition: scale_file_netcdf.c:1882
file_open_c
int file_open_c(int *fid, const char *fname, const int mode, const int comm)
Definition: scale_file_netcdf.c:170
datainfo_t::natts
int32_t natts
Definition: scale_file.h:35
file_get_attribute_float_c
int file_get_attribute_float_c(float *value, const int fid, const char *vname, const char *key, const bool suppress, const int len)
Definition: scale_file_netcdf.c:954
file_attach_buffer_c
int file_attach_buffer_c(const int fid, const int64_t buf_amount)
Definition: scale_file_netcdf.c:1840
file_write_axis_c
int file_write_axis_c(const int fid, const char *name, const void *val, const int precision, const int *start, const int *count)
Definition: scale_file_netcdf.c:1351
File_HMID
#define File_HMID
Definition: scale_file_const.h:3
file_get_attribute_text_c
int file_get_attribute_text_c(char *value, const int fid, const char *vname, const char *key, const bool suppress, const int len)
Definition: scale_file_netcdf.c:864
datainfo_t::time_start
real64_t time_start
Definition: scale_file.h:31
file_def_associatedcoordinate_c
int file_def_associatedcoordinate_c(const int fid, const char *name, const char *desc, const char *units, const char **dim_names, const int ndims, const int dtype)
Definition: scale_file_netcdf.c:1450
ATT_MAX
#define ATT_MAX
Definition: scale_file_const.h:32
file_add_variable_c
int file_add_variable_c(int *vid, const int fid, const char *varname, const char *desc, const char *units, const char *stdname, const char **dims, const int ndims, const int dtype, const double tint, const char *tstats)
Definition: scale_file_netcdf.c:1550
double
typedef double(real64_t)
file_set_tunits_c
int file_set_tunits_c(const int fid, const char *time_units, const char *calendar)
Definition: scale_file_netcdf.c:1227
scale_tracer::description
character(len=h_mid), public description
Definition: scale_tracer.F90:40
datainfo_t::step
int32_t step
Definition: scale_file.h:29
file_put_axis_c
int file_put_axis_c(const int fid, const char *name, const char *desc, const char *units, const char *dim_name, const int dtype, const void *val, const int size, const int precision)
Definition: scale_file_netcdf.c:1237
file_set_option_c
int file_set_option_c(const int fid, const char *filetype, const char *key, const char *val)
Definition: scale_file_netcdf.c:287
file_get_nvars_c
int file_get_nvars_c(int *nvars, const int fid)
Definition: scale_file_netcdf.c:303
file_set_attribute_int_c
int file_set_attribute_int_c(const int fid, const char *vname, const char *key, const int *value, const int len)
Definition: scale_file_netcdf.c:1081
scale_tracer::name
character(len=h_short), public name
Definition: scale_tracer.F90:39
file_enddef_c
int file_enddef_c(const int fid)
Definition: scale_file_netcdf.c:1818
file_flush_c
int file_flush_c(const int fid)
Definition: scale_file_netcdf.c:1867