SCALE-RM
Functions
gtool_file_f.c File Reference
#include "gtool_file.h"
Include dependency graph for gtool_file_f.c:

Go to the source code of this file.

Functions

void file_open_ (int32_t *fid, char *fname, int32_t *mode, int32_t *error, int32_t fname_len)
 
void file_set_option_ (int32_t *fid, char *filetype, char *key, char *val, int32_t *error, int32_t filetype_len, int32_t key_len, int32_t val_len)
 
void file_get_datainfo_ (datainfo_t *dinfo, int32_t *fid, char *varname, int32_t *step, int32_t *suppress, int32_t *error, int32_t varname_len)
 
void file_read_data_ (void *var, datainfo_t *dinfo, int32_t *precision, int32_t *error)
 
void file_get_global_attribute_text_ (int32_t *fid, char *key, char *value, int32_t *error, int32_t key_len, int32_t value_len)
 
void file_get_global_attribute_int_ (int32_t *fid, char *key, int32_t *len, int32_t *value, int32_t *error, int32_t key_len)
 
void file_get_global_attribute_float_ (int32_t *fid, char *key, int32_t *len, float *value, int32_t *error, int32_t key_len)
 
void file_get_global_attribute_double_ (int32_t *fid, char *key, int32_t *len, double *value, int32_t *error, int32_t key_len)
 
void file_set_global_attribute_text_ (int32_t *fid, char *key, char *value, int32_t *error, int32_t key_len, int32_t value_len)
 
void file_set_global_attribute_int_ (int32_t *fid, char *key, int32_t *value, int32_t *len, int32_t *error, int32_t key_len)
 
void file_set_global_attribute_float_ (int32_t *fid, char *key, float *value, int32_t *len, int32_t *error, int32_t key_len)
 
void file_set_global_attribute_double_ (int32_t *fid, char *key, double *value, int32_t *len, int32_t *error, int32_t key_len)
 
void file_set_tunits_ (int32_t *fid, char *time_units, int32_t *error, int32_t len)
 
void file_set_tattr_ (int32_t *fid, char *vname, char *key, char *val, int32_t *error, int32_t vname_len, int32_t key_len, int32_t val_len)
 
void 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, int32_t *error, int32_t name_len, int32_t desc_len, int32_t units_len, int32_t dim_name_len)
 
void 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, int32_t *error, int32_t name_len, int32_t desc_len, int32_t units_len, int32_t dim_name_len)
 
void 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, int32_t *error, int32_t varname_len, int32_t desc_len, int32_t units_len, int32_t dims_len)
 
void file_write_data_ (int32_t *fid, int32_t *vid, void *var, real64_t *t_start, real64_t *t_end, int32_t *precision, int32_t *error)
 
void file_close_ (int32_t *fid, int32_t *error)
 

Function Documentation

◆ file_open_()

void file_open_ ( int32_t *  fid,
char *  fname,
int32_t *  mode,
int32_t *  error,
int32_t  fname_len 
)

Definition at line 35 of file gtool_file_f.c.

40 {
41  char _fname[File_HLONG+1];
42  int32_t len;
43 
44  len = fname_len > File_HLONG ? File_HLONG : fname_len;
45  fstr2cstr(_fname, fname, len);
46 
47  *error = file_open( fid, _fname, *mode );
48 }
int32_t file_open(int32_t *fid, char *fname, int32_t mode)
Definition: gtool_netcdf.c:97
#define File_HLONG
Definition: gtool_file.h:13

◆ file_set_option_()

void file_set_option_ ( int32_t *  fid,
char *  filetype,
char *  key,
char *  val,
int32_t *  error,
int32_t  filetype_len,
int32_t  key_len,
int32_t  val_len 
)

Definition at line 50 of file gtool_file_f.c.

References File_HMID, and File_HSHORT.

58 {
59  char _filetype[File_HSHORT+1];
60  char _key[File_HMID+1];
61  char _val[File_HMID+1];
62  int32_t len;
63 
64  len = filetype_len > File_HSHORT ? File_HSHORT : filetype_len;
65  fstr2cstr(_filetype, filetype, len);
66 
67  len = key_len > File_HMID ? File_HMID : key_len;
68  fstr2cstr(_key, key, len);
69 
70  len = val_len > File_HMID ? File_HMID : val_len;
71  fstr2cstr(_val, val, len);
72 
73  *error = file_set_option(*fid, _filetype, _key, _val);
74 }
#define File_HMID
Definition: gtool_file.h:12
#define File_HSHORT
Definition: gtool_file.h:11
int32_t file_set_option(int32_t fid, char *filetype, char *key, char *val)
Definition: gtool_netcdf.c:146

◆ file_get_datainfo_()

void file_get_datainfo_ ( datainfo_t dinfo,
int32_t *  fid,
char *  varname,
int32_t *  step,
int32_t *  suppress,
int32_t *  error,
int32_t  varname_len 
)

Definition at line 76 of file gtool_file_f.c.

83 {
84  char _varname[File_HSHORT+1];
85  int32_t len;
86  int i;
87 
88  len = varname_len > File_HSHORT ? File_HSHORT : varname_len;
89  fstr2cstr(_varname, varname, len);
90 
91  *error = file_get_datainfo( dinfo, *fid, _varname, *step, *suppress );
92 
93  cstr2fstr(dinfo->varname, dinfo->varname, File_HSHORT);
94  cstr2fstr(dinfo->description, dinfo->description, File_HMID);
95  cstr2fstr(dinfo->units, dinfo->units, File_HSHORT);
96  cstr2fstr(dinfo->time_units, dinfo->time_units, File_HMID);
97  for ( i=0; i<MAX_RANK; i++ )
98  cstr2fstr(dinfo->dim_name+i*File_HSHORT, dinfo->dim_name+i*File_HSHORT, File_HSHORT);
99 }
#define File_HMID
Definition: gtool_file.h:12
#define MAX_RANK
Definition: gtool_file.h:34
char dim_name[File_HSHORT *MAX_RANK]
Definition: gtool_file.h:47
char description[File_HMID]
Definition: gtool_file.h:43
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
char time_units[File_HMID]
Definition: gtool_file.h:52
char units[File_HSHORT]
Definition: gtool_file.h:44
char varname[File_HSHORT]
Definition: gtool_file.h:42

◆ file_read_data_()

void file_read_data_ ( void *  var,
datainfo_t dinfo,
int32_t *  precision,
int32_t *  error 
)

Definition at line 100 of file gtool_file_f.c.

104 {
105  int i;
106 
107  fstr2cstr(dinfo->varname, dinfo->varname, File_HSHORT);
108  fstr2cstr(dinfo->description, dinfo->description, File_HMID);
109  fstr2cstr(dinfo->units, dinfo->units, File_HSHORT);
110  fstr2cstr(dinfo->time_units, dinfo->time_units, File_HMID);
111  for ( i=0; i<MAX_RANK; i++ )
112  fstr2cstr(dinfo->dim_name+i*File_HSHORT, dinfo->dim_name+i*File_HSHORT, File_HSHORT);
113 
114  *error = file_read_data( var, dinfo, *precision );
115 }
#define File_HMID
Definition: gtool_file.h:12
#define MAX_RANK
Definition: gtool_file.h:34
char dim_name[File_HSHORT *MAX_RANK]
Definition: gtool_file.h:47
char description[File_HMID]
Definition: gtool_file.h:43
#define File_HSHORT
Definition: gtool_file.h:11
char time_units[File_HMID]
Definition: gtool_file.h:52
char units[File_HSHORT]
Definition: gtool_file.h:44
char varname[File_HSHORT]
Definition: gtool_file.h:42
int32_t file_read_data(void *var, datainfo_t *dinfo, int32_t precision)
Definition: gtool_netcdf.c:245

◆ file_get_global_attribute_text_()

void file_get_global_attribute_text_ ( int32_t *  fid,
char *  key,
char *  value,
int32_t *  error,
int32_t  key_len,
int32_t  value_len 
)

Definition at line 117 of file gtool_file_f.c.

123 {
124  char _key[File_HLONG+1];
125  char _value[File_HLONG+1];
126  int32_t len;
127 
128  len = key_len > File_HLONG ? File_HLONG : key_len;
129  fstr2cstr(_key, key, len);
130 
131  *error = file_get_global_attribute_text( *fid, _key, _value, value_len );
132 
133  len = value_len > File_HLONG ? File_HLONG : value_len;
134  cstr2fstr(value, _value, len);
135 }
int32_t file_get_global_attribute_text(int32_t fid, char *key, char *value, int32_t len)
Definition: gtool_netcdf.c:294
#define File_HLONG
Definition: gtool_file.h:13

◆ file_get_global_attribute_int_()

void file_get_global_attribute_int_ ( int32_t *  fid,
char *  key,
int32_t *  len,
int32_t *  value,
int32_t *  error,
int32_t  key_len 
)

Definition at line 137 of file gtool_file_f.c.

143 {
144  char _key[File_HLONG+1];
145  int32_t l;
146 
147  l = key_len > File_HLONG ? File_HLONG : key_len;
148  fstr2cstr(_key, key, l);
149 
150  *error = file_get_global_attribute_int( *fid, _key, value, (size_t)*len );
151 }
int32_t file_get_global_attribute_int(int32_t fid, char *key, int32_t *value, size_t len)
#define File_HLONG
Definition: gtool_file.h:13

◆ file_get_global_attribute_float_()

void file_get_global_attribute_float_ ( int32_t *  fid,
char *  key,
int32_t *  len,
float value,
int32_t *  error,
int32_t  key_len 
)

Definition at line 153 of file gtool_file_f.c.

159 {
160  char _key[File_HLONG+1];
161  int32_t l;
162 
163  l = key_len > File_HLONG ? File_HLONG : key_len;
164  fstr2cstr(_key, key, l);
165 
166  *error = file_get_global_attribute_float( *fid, _key, value, (size_t)*len );
167 }
int32_t file_get_global_attribute_float(int32_t fid, char *key, float *value, size_t len)
Definition: gtool_netcdf.c:332
#define File_HLONG
Definition: gtool_file.h:13

◆ file_get_global_attribute_double_()

void file_get_global_attribute_double_ ( int32_t *  fid,
char *  key,
int32_t *  len,
double value,
int32_t *  error,
int32_t  key_len 
)

Definition at line 169 of file gtool_file_f.c.

175 {
176  char _key[File_HLONG+1];
177  int32_t l;
178 
179  l = key_len > File_HLONG ? File_HLONG : key_len;
180  fstr2cstr(_key, key, l);
181 
182  *error = file_get_global_attribute_double( *fid, _key, value, (size_t)*len );
183 }
int32_t file_get_global_attribute_double(int32_t fid, char *key, double *value, size_t len)
Definition: gtool_netcdf.c:350
#define File_HLONG
Definition: gtool_file.h:13

◆ file_set_global_attribute_text_()

void file_set_global_attribute_text_ ( int32_t *  fid,
char *  key,
char *  value,
int32_t *  error,
int32_t  key_len,
int32_t  value_len 
)

Definition at line 185 of file gtool_file_f.c.

191 {
192  char _key[File_HLONG+1];
193  char _value[File_HLONG+1];
194  int32_t len;
195 
196  len = key_len > File_HLONG ? File_HLONG : key_len;
197  fstr2cstr(_key, key, len);
198 
199  len = value_len > File_HLONG ? File_HLONG : value_len;
200  fstr2cstr(_value, value, len);
201 
202  *error = file_set_global_attribute_text( *fid, _key, _value );
203 }
int32_t file_set_global_attribute_text(int32_t fid, char *key, char *value)
Definition: gtool_netcdf.c:368
#define File_HLONG
Definition: gtool_file.h:13

◆ file_set_global_attribute_int_()

void file_set_global_attribute_int_ ( int32_t *  fid,
char *  key,
int32_t *  value,
int32_t *  len,
int32_t *  error,
int32_t  key_len 
)

Definition at line 205 of file gtool_file_f.c.

211 {
212  char _key[File_HLONG+1];
213 
214  key_len = key_len > File_HLONG ? File_HLONG : key_len;
215  fstr2cstr(_key, key, key_len);
216 
217  *error = file_set_global_attribute_int( *fid, _key, value, (size_t)*len );
218 }
int32_t file_set_global_attribute_int(int32_t fid, char *key, int32_t *value, size_t len)
#define File_HLONG
Definition: gtool_file.h:13

◆ file_set_global_attribute_float_()

void file_set_global_attribute_float_ ( int32_t *  fid,
char *  key,
float value,
int32_t *  len,
int32_t *  error,
int32_t  key_len 
)

Definition at line 220 of file gtool_file_f.c.

226 {
227  char _key[File_HLONG+1];
228  int32_t l;
229 
230  l = key_len > File_HLONG ? File_HLONG : key_len;
231  fstr2cstr(_key, key, l);
232 
233  *error = file_set_global_attribute_float( *fid, _key, value, (size_t)*len );
234 }
int32_t file_set_global_attribute_float(int32_t fid, char *key, float *value, size_t len)
Definition: gtool_netcdf.c:403
#define File_HLONG
Definition: gtool_file.h:13

◆ file_set_global_attribute_double_()

void file_set_global_attribute_double_ ( int32_t *  fid,
char *  key,
double value,
int32_t *  len,
int32_t *  error,
int32_t  key_len 
)

Definition at line 236 of file gtool_file_f.c.

242 {
243  char _key[File_HLONG+1];
244  int32_t l;
245 
246  l = key_len > File_HLONG ? File_HLONG : key_len;
247  fstr2cstr(_key, key, l);
248 
249  *error = file_set_global_attribute_double( *fid, _key, value, (size_t)*len );
250 }
int32_t file_set_global_attribute_double(int32_t fid, char *key, double *value, size_t len)
Definition: gtool_netcdf.c:421
#define File_HLONG
Definition: gtool_file.h:13

◆ file_set_tunits_()

void file_set_tunits_ ( int32_t *  fid,
char *  time_units,
int32_t *  error,
int32_t  len 
)

Definition at line 252 of file gtool_file_f.c.

References File_HMID.

256 {
257  char _time_units[File_HMID+1];
258 
259  len = len > File_HMID ? File_HMID : len;
260  fstr2cstr(_time_units, time_units, len);
261 
262  *error = file_set_tunits( *fid, _time_units );
263 }
int32_t file_set_tunits(int32_t fid, char *time_units)
Definition: gtool_netcdf.c:439
#define File_HMID
Definition: gtool_file.h:12

◆ file_set_tattr_()

void file_set_tattr_ ( int32_t *  fid,
char *  vname,
char *  key,
char *  val,
int32_t *  error,
int32_t  vname_len,
int32_t  key_len,
int32_t  val_len 
)

Definition at line 265 of file gtool_file_f.c.

References File_HLONG, and File_HSHORT.

273 {
274  char _vname[File_HSHORT+1];
275  char _key[File_HSHORT+1];
276  char _val[File_HLONG+1];
277  int32_t len;
278 
279  len = vname_len > File_HLONG ? File_HLONG : vname_len;
280  fstr2cstr(_vname, vname, len);
281 
282  len = key_len > File_HLONG ? File_HLONG : key_len;
283  fstr2cstr(_key, key, len);
284 
285  len = val_len > File_HLONG ? File_HLONG : val_len;
286  fstr2cstr(_val, val, len);
287 
288  *error = file_set_tattr( *fid, _vname, _key, _val );
289 }
int32_t file_set_tattr(int32_t fid, char *vname, char *key, char *val)
Definition: gtool_netcdf.c:447
#define File_HSHORT
Definition: gtool_file.h:11
#define File_HLONG
Definition: gtool_file.h:13

◆ file_put_axis_()

void 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,
int32_t *  error,
int32_t  name_len,
int32_t  desc_len,
int32_t  units_len,
int32_t  dim_name_len 
)

Definition at line 291 of file gtool_file_f.c.

305 {
306  char _name[File_HSHORT+1];
307  char _desc[File_HMID+1];
308  char _units[File_HMID+1];
309  char _dim_name[File_HSHORT+1];
310  int len;
311 
312  len = name_len > File_HSHORT ? File_HSHORT : name_len;
313  fstr2cstr(_name, name, len);
314 
315  len = desc_len > File_HMID ? File_HMID : desc_len;
316  fstr2cstr(_desc, desc, len);
317 
318  len = units_len > File_HMID ? File_HMID : units_len;
319  fstr2cstr(_units, units, len);
320 
321  len = dim_name_len > File_HSHORT ? File_HSHORT : dim_name_len;
322  fstr2cstr(_dim_name, dim_name, len);
323 
324  *error = file_put_axis( *fid, _name, _desc, _units, _dim_name, *dtype, val, *size, *precision );
325 }
#define File_HMID
Definition: gtool_file.h:12
#define File_HSHORT
Definition: gtool_file.h:11
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

◆ file_put_associated_coordinates_()

void 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,
int32_t *  error,
int32_t  name_len,
int32_t  desc_len,
int32_t  units_len,
int32_t  dim_name_len 
)

Definition at line 327 of file gtool_file_f.c.

341 {
342  char _name[File_HSHORT+1];
343  char _desc[File_HMID+1];
344  char _units[File_HMID+1];
345  char **_dim_names;
346  int len;
347  int i;
348 
349  len = name_len > File_HSHORT ? File_HSHORT : name_len;
350  fstr2cstr(_name, name, len);
351 
352  len = desc_len > File_HMID ? File_HMID : desc_len;
353  fstr2cstr(_desc, desc, len);
354 
355  len = units_len > File_HMID ? File_HMID : units_len;
356  fstr2cstr(_units, units, len);
357 
358  _dim_names = (char**) malloc(sizeof(char*)*(*ndims));
359  len = dim_name_len > File_HSHORT ? File_HSHORT : dim_name_len;
360  for ( i=0; i<*ndims; i++ ) {
361  _dim_names[i] = (char*) malloc(sizeof(char)*(File_HSHORT+1));
362  fstr2cstr(_dim_names[i], dim_names+i*dim_name_len, len);
363  }
364  *error = file_put_associated_coordinates( *fid, _name, _desc, _units, _dim_names, *ndims, *dtype, val, *precision );
365 }
#define File_HMID
Definition: gtool_file.h:12
#define File_HSHORT
Definition: gtool_file.h:11
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

◆ file_add_variable_()

void 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,
int32_t *  error,
int32_t  varname_len,
int32_t  desc_len,
int32_t  units_len,
int32_t  dims_len 
)

Definition at line 367 of file gtool_file_f.c.

382 {
383  char _varname[File_HSHORT+1];
384  char _desc[File_HMID+1];
385  char _units[File_HMID+1];
386  char **_dims;
387  int len;
388  int i;
389 
390  len = varname_len > File_HSHORT ? File_HSHORT : varname_len;
391  fstr2cstr(_varname, varname, len);
392 
393  len = desc_len > File_HMID ? File_HMID : desc_len;
394  fstr2cstr(_desc, desc, len);
395 
396  len = units_len > File_HMID ? File_HMID : units_len;
397  fstr2cstr(_units, units, len);
398 
399  _dims = (char**) malloc(sizeof(char*)*(*ndims));
400  len = dims_len > File_HSHORT ? File_HSHORT : dims_len;
401  for ( i=0; i<*ndims; i++ ) {
402  _dims[i] = (char*) malloc(sizeof(char)*(File_HSHORT+1));
403  fstr2cstr(_dims[i], dims+i*dims_len, len);
404  }
405 
406  *error = file_add_variable( vid, *fid, _varname, _desc, _units, _dims, *ndims, *dtype, *tint, *tavg );
407 
408  for ( i=0; i<*ndims; i++ )
409  free( _dims[i] );
410  free( _dims );
411 }
#define File_HMID
Definition: gtool_file.h:12
#define File_HSHORT
Definition: gtool_file.h:11
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

◆ file_write_data_()

void file_write_data_ ( int32_t *  fid,
int32_t *  vid,
void *  var,
real64_t *  t_start,
real64_t *  t_end,
int32_t *  precision,
int32_t *  error 
)

Definition at line 413 of file gtool_file_f.c.

References file_write_data().

420 {
421  *error = file_write_data( *fid, *vid, var, *t_start, *t_end, *precision );
422 }
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
Here is the call graph for this function:

◆ file_close_()

void file_close_ ( int32_t *  fid,
int32_t *  error 
)

Definition at line 424 of file gtool_file_f.c.

References file_close().

426 {
427  *error = file_close( *fid );
428 }
int32_t file_close(int32_t fid)
Definition: gtool_netcdf.c:852
Here is the call graph for this function: