ARTS  2.2.66
nc_io.h
Go to the documentation of this file.
1 /* Copyright (C) 2012 Oliver Lemke <olemke@core-dump.info>
2 
3  This program is free software; you can redistribute it and/or modify it
4  under the terms of the GNU General Public License as published by the
5  Free Software Foundation; either version 2, or (at your option) any
6  later version.
7 
8  This program is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  GNU General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License
14  along with this program; if not, write to the Free Software
15  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
16  USA. */
17 
18 
20 // File description
22 
30 #include "arts.h"
31 
32 #ifdef ENABLE_NETCDF
33 
34 #ifndef nc_io_h
35 #define nc_io_h
36 
37 #include <netcdf.h>
38 #include "mystring.h"
39 #include "exceptions.h"
40 #include "messages.h"
41 #include "abs_species_tags.h"
42 
43 
45 // Default file names
47 
48 void nca_filename(String& filename, const String& varname);
49 
50 void nca_filename_with_index(String& filename, const Index& file_index, const String& varname);
51 
52 
54 // Generic IO routines for XML files
56 
57 template<typename T>
58 void nca_read_from_file(const String& filename, T& type, const Verbosity& verbosity);
59 
60 
61 template<typename T>
62 void nca_write_to_file(const String& filename, const T& type, const Verbosity& verbosity);
63 
64 
65 /*void nc_read_var(const int ncf, const int **ncvar,
66  const Index dims, const String& name);*/
67 
68 void nca_def_dim(const int ncid, const String& name, const Index nelem, int* ncdim);
69 void nca_def_var(const int ncid, const String& name, const nc_type type, const int ndims,
70  const int* dims, int* varid);
71 
72 int nca_def_ArrayOfIndex(const int ncid, const String& name, const ArrayOfIndex& a);
73 
74 int nca_def_Vector(const int ncid, const String& name, const Vector& v);
75 
76 int nca_def_Matrix(const int ncid, const String& name, const Matrix& m);
77 
78 int nca_def_Tensor4(const int ncid, const String& name, const Tensor4& t);
79 
80 Index nc_get_dim(const int ncid, const String& name, const bool noerror = false);
81 
82 void nca_get_data_int(const int ncid, const String& name, int* data);
83 
84 void nca_get_data_long(const int ncid, const String& name, long* data);
85 
86 void nca_get_data_double(const int ncid, const String& name, Numeric* data);
87 
88 void nca_get_dataa_double(const int ncid, const String& name,
89  size_t start, size_t count, Numeric* data);
90 
91 void nca_get_data_text(const int ncid, const String& name, char* data);
92 
93 void nca_get_data_ArrayOfIndex(const int ncid,
94  const String& name,
95  ArrayOfIndex& aoi,
96  const bool noerror);
97 
98 void nca_get_data_ArrayOfArrayOfSpeciesTag(const int ncid,
99  const String& name,
101  const bool noerror);
102 
103 void nca_get_data_Vector(const int ncid, const String& name, Vector& v, const bool noerror = false);
104 
105 void nca_get_data_Matrix(const int ncid, const String& name, Matrix& m, const bool noerror = false);
106 
107 void nca_get_data_Tensor4(const int ncid, const String& name, Tensor4& m, const bool noerror = false);
108 
109 bool nca_put_var_ArrayOfIndex(const int ncid, const int varid, const ArrayOfIndex& a);
110 
111 bool nca_put_var_Vector(const int ncid, const int varid, const Vector& v);
112 
113 bool nca_put_var_Matrix(const int ncid, const int varid, const Matrix& m);
114 
115 bool nca_put_var_Tensor4(const int ncid, const int varid, const Tensor4& t);
116 
117 void nca_error(const int err, const String msg);
118 
119 #endif /* nc_io_h */
120 
121 #endif /* ENABLE_NETCDF */
122 
INDEX Index
The type to use for all integer numbers and indices.
Definition: matpack.h:35
bool nca_put_var_Tensor4(const int ncid, const int varid, const Tensor4 &t)
Write variable of type Tensor4 to NetCDF file.
Definition: nc_io.cc:651
Declarations having to do with the four output streams.
void nca_get_data_text(const int ncid, const String &name, char *data)
Read variable of type array of char from NetCDF file.
Definition: nc_io.cc:434
The Vector class.
Definition: matpackI.h:556
The Tensor4 class.
Definition: matpackIV.h:383
int nca_def_Matrix(const int ncid, const String &name, const Matrix &m)
Define NetCDF dimensions and variable for a Matrix.
Definition: nc_io.cc:282
int nca_def_Tensor4(const int ncid, const String &name, const Tensor4 &t)
Define NetCDF dimensions and variable for a Tensor4.
Definition: nc_io.cc:307
void nca_get_data_int(const int ncid, const String &name, int *data)
Read variable of type int from NetCDF file.
Definition: nc_io.cc:361
void nca_filename(String &filename, const String &varname)
Gives the default filename for the NetCDF formats.
Definition: nc_io.cc:55
The implementation for String, the ARTS string class.
Definition: mystring.h:63
void nca_read_from_file(const String &filename, T &type, const Verbosity &verbosity)
Reads a variable from a NetCDF file.
Definition: nc_io.cc:105
void nca_def_var(const int ncid, const String &name, const nc_type type, const int ndims, const int *dims, int *varid)
Define NetCDF variable.
Definition: nc_io.cc:216
The global header file for ARTS.
void nca_get_data_Vector(const int ncid, const String &name, Vector &v, const bool noerror=false)
Read variable of type Vector from NetCDF file.
Definition: nc_io.cc:521
int nca_def_Vector(const int ncid, const String &name, const Vector &v)
Define NetCDF dimensions and variable for a Vector.
Definition: nc_io.cc:258
The declarations of all the exception classes.
void nca_get_data_Matrix(const int ncid, const String &name, Matrix &m, const bool noerror=false)
Read variable of type Matrix from NetCDF file.
Definition: nc_io.cc:539
void nca_error(const int err, const String msg)
Throws a runtime error for the given NetCDF error code.
Definition: nc_io.cc:671
bool nca_put_var_ArrayOfIndex(const int ncid, const int varid, const ArrayOfIndex &a)
Write variable of type ArrayOfIndex to NetCDF file.
Definition: nc_io.cc:578
NUMERIC Numeric
The type to use for all floating point numbers.
Definition: matpack.h:29
The Matrix class.
Definition: matpackI.h:788
bool nca_put_var_Vector(const int ncid, const int varid, const Vector &v)
Write variable of type Vector to NetCDF file.
Definition: nc_io.cc:607
bool nca_put_var_Matrix(const int ncid, const int varid, const Matrix &m)
Write variable of type Matrix to NetCDF file.
Definition: nc_io.cc:629
void nca_get_data_double(const int ncid, const String &name, Numeric *data)
Read variable of type double from NetCDF file.
Definition: nc_io.cc:397
void nca_def_dim(const int ncid, const String &name, const Index nelem, int *ncdim)
Define NetCDF dimension.
Definition: nc_io.cc:197
void nca_get_data_ArrayOfIndex(const int ncid, const String &name, ArrayOfIndex &aoi, const bool noerror)
Read variable of type ArrayOfIndex from NetCDF file.
Definition: nc_io.cc:454
This can be used to make arrays out of anything.
Definition: array.h:40
void nca_get_data_ArrayOfArrayOfSpeciesTag(const int ncid, const String &name, ArrayOfArrayOfSpeciesTag &aast, const bool noerror)
Read variable of type ArrayOfArrayOfSpeciesTag from NetCDF file.
Definition: nc_io.cc:480
void nca_get_dataa_double(const int ncid, const String &name, size_t start, size_t count, Numeric *data)
Read variable of type array of double from NetCDF file.
Definition: nc_io.cc:415
void nca_get_data_long(const int ncid, const String &name, long *data)
Read variable of type long from NetCDF file.
Definition: nc_io.cc:379
void nca_filename_with_index(String &filename, const Index &file_index, const String &varname)
Gives the default filename, with file index, for the NetCDF formats.
Definition: nc_io.cc:76
Header file for stuff related to absorption species tags.
int nca_def_ArrayOfIndex(const int ncid, const String &name, const ArrayOfIndex &a)
Define NetCDF dimensions and variable for an ArrayOfIndex.
Definition: nc_io.cc:234
void nca_get_data_Tensor4(const int ncid, const String &name, Tensor4 &m, const bool noerror=false)
Read variable of type Tensor4 from NetCDF file.
Definition: nc_io.cc:558
void nca_write_to_file(const String &filename, const T &type, const Verbosity &verbosity)
Writes a variable to a NetCDF file.
Definition: nc_io.cc:151
Index nc_get_dim(const int ncid, const String &name, const bool noerror=false)
Read a dimension from NetCDF file.
Definition: nc_io.cc:334
This file contains the definition of String, the ARTS string class.