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 <string.h>
8 #include <math.h>
9 #include <mpi.h>
10 
11 
12 #include "scale_file_const.h"
13 
14 
15 typedef float (real32_t);
16 typedef double(real64_t);
17 
18 /* data item information */
19 typedef struct{
20  char varname[File_HSHORT];
22  char units[File_HSHORT];
23  char standard_name[File_HMID];
24  int32_t datatype;
25  int32_t rank;
26  char dim_name[File_HSHORT*RANK_MAX];
27  int32_t dim_size[RANK_MAX];
28  int32_t step;
29  real64_t time_start;
30  real64_t time_end;
31  char time_units[File_HMID];
32  char calendar[File_HSHORT];
33  int32_t natts;
34  char att_name[File_HSHORT*ATT_MAX];
35  int32_t att_type[ATT_MAX];
36  int32_t att_len[ATT_MAX];
37  int32_t fid;
38 } datainfo_t;
39 
40 
41 extern int32_t file_open_c( int32_t *fid, // (out)
42  const char *fname, // (in)
43  const int32_t mode, // (in)
44  const MPI_Comm comm); // (in)
45 
46 extern int32_t file_get_dim_length_c( const int32_t fid, // (in)
47  const char* dimname, // (in)
48  int32_t *len ); // (out)
49 
50 extern int32_t file_set_option_c( const int32_t fid, // (in)
51  const char *filetype, // (in)
52  const char *key, // (in)
53  const char *val); // (in)
54 
55 extern int32_t file_get_nvars_c( const int32_t fid, // (in)
56  int32_t *nvars ); // (out)
57 
58 extern int32_t file_get_varname_c( const int32_t fid, // (in)
59  const int32_t vid, // (in)
60  char *name, // (out)
61  const int32_t len ); // (in)
62 
63 extern int32_t file_get_datainfo_c( datainfo_t *dinfo, // (out)
64  const int32_t fid, // (in)
65  const char *varname, // (in)
66  const int32_t step, // (in)
67  const int32_t suppress ); // (in)
68 
69 extern int32_t file_get_step_size_c( const int32_t fid, // (in)
70  const char* varname, // (in)
71  int32_t *len ); // (out)
72 
73 extern int32_t file_read_data_c( void *var, // (out)
74  const datainfo_t *dinfo, // (in)
75  const int32_t precision, // (in)
76  const MPI_Offset ntypes, // (in)
77  const MPI_Datatype dtype, // (in)
78  const int32_t *start, // (in)
79  const int32_t *count ); // (in)
80 
81 extern int32_t file_get_attribute_text_c( const int32_t fid, // (in)
82  const char *vname, // (in)
83  const char *key, // (in)
84  const int32_t suppress, // (in)
85  char *value, // (out)
86  const int32_t len); // (in)
87 
88 extern int32_t file_get_attribute_int_c( const int32_t fid, // (in)
89  const char *vname, // (in)
90  const char *key, // (in)
91  const int32_t suppress, // (in)
92  int32_t *value, // (out)
93  const size_t len); // (in)
94 
95 extern int32_t file_get_attribute_float_c( const int32_t fid, // (in)
96  const char *vname, // (in)
97  const char *key, // (in)
98  const int32_t suppress, // (in)
99  float *value, // (out)
100  const size_t len); // (in)
101 
102 extern int32_t file_get_attribute_double_c( const int32_t fid, // (in)
103  const char *vname, // (in)
104  const char *key, // (in)
105  const int32_t suppress, // (in)
106  double *value, // (out)
107  const size_t len); // (in)
108 
109 extern int32_t file_set_attribute_text_c( const int32_t fid, // (in)
110  const char *vname, // (in)
111  const char *key, // (in)
112  const char *value); // (in)
113 
114 extern int32_t file_set_attribute_int_c( const int32_t fid, // (in)
115  const char *vname, // (in)
116  const char *key, // (in)
117  const int32_t *value, // (in)
118  const size_t len); // (in)
119 
120 extern int32_t file_set_attribute_float_c( const int32_t fid, // (in)
121  const char *vname, // (in)
122  const char *key, // (in)
123  const float *value, // (in)
124  const size_t len); // (in)
125 
126 extern int32_t file_set_attribute_double_c( const int32_t fid, // (in)
127  const char *vname, // (in)
128  const char *key, // (in)
129  const double *value, // (in)
130  const size_t len); // (in)
131 
132 extern int32_t file_add_associatedvariable_c( const int32_t fid, // (in)
133  const char *vname); // (in)
134 
135 extern int32_t file_set_tunits_c( const int32_t fid, // (in)
136  const char *time_units, // (in)
137  const char *calendar); // (in)
138 
139 extern int32_t file_put_axis_c( const int32_t fid, // (in)
140  const char *name, // (in)
141  const char *desc, // (in)
142  const char *units, // (in)
143  const char *dim_name, // (in)
144  const int32_t dtype, // (in)
145  const void *val, // (in)
146  const int32_t size, // (in)
147  const int32_t precision); // (in)
148 
149 extern int32_t file_def_axis_c( const int32_t fid, // (in)
150  const char *name, // (in)
151  const char *desc, // (in)
152  const char *units, // (in)
153  const char *dim_name, // (in)
154  const int32_t dtype, // (in)
155  const int32_t dim_size, // (in)
156  const int32_t bounds); // (in)
157 
158 extern int32_t file_write_axis_c( const int32_t fid, // (in)
159  const char *name, // (in)
160  const void *val, // (in)
161  const int32_t precision, // (in)
162  const MPI_Offset *start, // (in)
163  const MPI_Offset *count); // (in)
164 
165 extern int32_t file_put_associatedcoordinate_c( const int32_t fid, // (in)
166  const char *name, // (in)
167  const char *desc, // (in)
168  const char *units, // (in)
169  const char **dim_names, // (in)
170  const int32_t ndims, // (in)
171  const int32_t dtype, // (in)
172  const void *val, // (in)
173  const int32_t precision); // (in)
174 
175 extern int32_t file_def_associatedcoordinate_c( const int32_t fid, // (in)
176  const char *name, // (in)
177  const char *desc, // (in)
178  const char *units, // (in)
179  const char **dim_names, // (in)
180  const int32_t ndims, // (in)
181  const int32_t dtype); // (in)
182 
183 extern int32_t file_write_associatedcoordinate_c( const int32_t fid, // (in)
184  const char *name, // (in)
185  const void *val, // (in)
186  const int32_t precision, // (in)
187  const MPI_Offset *start, // (in)
188  const MPI_Offset *count); // (in)
189 
190 extern int32_t file_add_variable_c( const int32_t fid, // (in)
191  const char *varname, // (in)
192  const char *desc, // (in)
193  const char *units, // (in)
194  const char *stdname, // (in)
195  const char **dims, // (in)
196  const int32_t ndims, // (in)
197  const int32_t dtype, // (in)
198  const real64_t tint, // (in)
199  const int32_t tavg, // (in)
200  int32_t *vid); // (out)
201 
202 extern int32_t file_write_data_c( const int32_t fid, // (in)
203  const int32_t vid, // (in)
204  const void *var, // (in)
205  const real64_t t_start, // (in)
206  const real64_t t_end, // (in)
207  const int32_t precision, // (in)
208  const int32_t ndims, // (in)
209  const int32_t *start, // (in)
210  const int32_t *count); // (in)
211 
212 extern int32_t file_enddef_c( const int32_t fid ); // (in)
213 extern int32_t file_redef_c( const int32_t fid ); // (in)
214 
215 extern int32_t file_attach_buffer_c( const int32_t fid, // (in)
216  const int64_t buf_amount ); // (in)
217 
218 extern int32_t file_detach_buffer_c( const int32_t fid ); // (in)
219 
220 extern int32_t file_flush_c( const int32_t fid ); // (in)
221 
222 extern int32_t file_close_c( const int32_t fid, // (in)
223  const int32_t abort ); // (in)
224 
225 #endif
file_put_associatedcoordinate_c
int32_t file_put_associatedcoordinate_c(const int32_t fid, const char *name, const char *desc, const char *units, const char **dim_names, const int32_t ndims, const int32_t dtype, const void *val, const int32_t precision)
Definition: scale_file_netcdf.c:1381
datainfo_t
Definition: scale_file.h:19
file_get_nvars_c
int32_t file_get_nvars_c(const int32_t fid, int32_t *nvars)
Definition: scale_file_netcdf.c:296
file_set_attribute_text_c
int32_t file_set_attribute_text_c(const int32_t fid, const char *vname, const char *key, const char *value)
Definition: scale_file_netcdf.c:1028
datainfo_t::time_end
real64_t time_end
Definition: scale_file.h:30
file_write_axis_c
int32_t file_write_axis_c(const int32_t fid, const char *name, const void *val, const int32_t precision, const MPI_Offset *start, const MPI_Offset *count)
Definition: scale_file_netcdf.c:1339
file_set_option_c
int32_t file_set_option_c(const int32_t fid, const char *filetype, const char *key, const char *val)
Definition: scale_file_netcdf.c:280
file_flush_c
int32_t file_flush_c(const int32_t fid)
Definition: scale_file_netcdf.c:1843
file_get_dim_length_c
int32_t file_get_dim_length_c(const int32_t fid, const char *dimname, int32_t *len)
Definition: scale_file_netcdf.c:256
file_add_associatedvariable_c
int32_t file_add_associatedvariable_c(const int32_t fid, const char *vname)
Definition: scale_file_netcdf.c:1192
file_def_axis_c
int32_t file_def_axis_c(const int32_t fid, const char *name, const char *desc, const char *units, const char *dim_name, const int32_t dtype, const int32_t dim_size, const int32_t bounds)
Definition: scale_file_netcdf.c:1274
file_add_variable_c
int32_t file_add_variable_c(const int32_t fid, const char *varname, const char *desc, const char *units, const char *stdname, const char **dims, const int32_t ndims, const int32_t dtype, const real64_t tint, const int32_t tavg, int32_t *vid)
Definition: scale_file_netcdf.c:1526
file_close_c
int32_t file_close_c(const int32_t fid, const int32_t abort)
Definition: scale_file_netcdf.c:1982
file_attach_buffer_c
int32_t file_attach_buffer_c(const int32_t fid, const int64_t buf_amount)
Definition: scale_file_netcdf.c:1816
float
typedef float(real32_t)
RANK_MAX
#define RANK_MAX
Definition: scale_file_const.h:30
datainfo_t::fid
int32_t fid
Definition: scale_file.h:37
file_get_step_size_c
int32_t file_get_step_size_c(const int32_t fid, const char *varname, int32_t *len)
Definition: scale_file_netcdf.c:633
file_set_attribute_double_c
int32_t file_set_attribute_double_c(const int32_t fid, const char *vname, const char *key, const double *value, const size_t len)
Definition: scale_file_netcdf.c:1154
datainfo_t::datatype
int32_t datatype
Definition: scale_file.h:24
scale_file_const.h
file_redef_c
int32_t file_redef_c(const int32_t fid)
Definition: scale_file_netcdf.c:1805
file_get_varname_c
int32_t file_get_varname_c(const int32_t fid, const int32_t vid, char *name, const int32_t len)
Definition: scale_file_netcdf.c:313
File_HSHORT
#define File_HSHORT
Definition: scale_file_const.h:2
datainfo_t::rank
int32_t rank
Definition: scale_file.h:25
file_write_associatedcoordinate_c
int32_t file_write_associatedcoordinate_c(const int32_t fid, const char *name, const void *val, const int32_t precision, const MPI_Offset *start, const MPI_Offset *count)
Definition: scale_file_netcdf.c:1484
file_set_attribute_int_c
int32_t file_set_attribute_int_c(const int32_t fid, const char *vname, const char *key, const int32_t *value, const size_t len)
Definition: scale_file_netcdf.c:1069
file_open_c
int32_t file_open_c(int32_t *fid, const char *fname, const int32_t mode, const MPI_Comm comm)
Definition: scale_file_netcdf.c:170
file_set_attribute_float_c
int32_t file_set_attribute_float_c(const int32_t fid, const char *vname, const char *key, const float *value, const size_t len)
Definition: scale_file_netcdf.c:1112
file_get_attribute_int_c
int32_t file_get_attribute_int_c(const int32_t fid, const char *vname, const char *key, const int32_t suppress, int32_t *value, const size_t len)
file_get_attribute_double_c
int32_t file_get_attribute_double_c(const int32_t fid, const char *vname, const char *key, const int32_t suppress, double *value, const size_t len)
Definition: scale_file_netcdf.c:985
datainfo_t::natts
int32_t natts
Definition: scale_file.h:33
file_get_datainfo_c
int32_t file_get_datainfo_c(datainfo_t *dinfo, const int32_t fid, const char *varname, const int32_t step, const int32_t suppress)
Definition: scale_file_netcdf.c:338
file_read_data_c
int32_t file_read_data_c(void *var, const datainfo_t *dinfo, const int32_t precision, const MPI_Offset ntypes, const MPI_Datatype dtype, const int32_t *start, const int32_t *count)
Definition: scale_file_netcdf.c:687
File_HMID
#define File_HMID
Definition: scale_file_const.h:3
datainfo_t::time_start
real64_t time_start
Definition: scale_file.h:29
ATT_MAX
#define ATT_MAX
Definition: scale_file_const.h:32
file_put_axis_c
int32_t file_put_axis_c(const int32_t fid, const char *name, const char *desc, const char *units, const char *dim_name, const int32_t dtype, const void *val, const int32_t size, const int32_t precision)
Definition: scale_file_netcdf.c:1225
double
typedef double(real64_t)
scale_tracer::description
character(len=h_mid), public description
Definition: scale_tracer.F90:39
datainfo_t::step
int32_t step
Definition: scale_file.h:28
file_get_attribute_text_c
int32_t file_get_attribute_text_c(const int32_t fid, const char *vname, const char *key, const int32_t suppress, char *value, const int32_t len)
Definition: scale_file_netcdf.c:852
file_get_attribute_float_c
int32_t file_get_attribute_float_c(const int32_t fid, const char *vname, const char *key, const int32_t suppress, float *value, const size_t len)
Definition: scale_file_netcdf.c:942
file_set_tunits_c
int32_t file_set_tunits_c(const int32_t fid, const char *time_units, const char *calendar)
Definition: scale_file_netcdf.c:1215
file_def_associatedcoordinate_c
int32_t file_def_associatedcoordinate_c(const int32_t fid, const char *name, const char *desc, const char *units, const char **dim_names, const int32_t ndims, const int32_t dtype)
Definition: scale_file_netcdf.c:1434
scale_tracer::name
character(len=h_short), public name
Definition: scale_tracer.F90:38
file_detach_buffer_c
int32_t file_detach_buffer_c(const int32_t fid)
Definition: scale_file_netcdf.c:1830
file_write_data_c
int32_t file_write_data_c(const int32_t fid, const int32_t vid, const void *var, const real64_t t_start, const real64_t t_end, const int32_t precision, const int32_t ndims, const int32_t *start, const int32_t *count)
Definition: scale_file_netcdf.c:1858
file_enddef_c
int32_t file_enddef_c(const int32_t fid)
Definition: scale_file_netcdf.c:1794