ARTS  2.2.66
m_nc.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 
27 #ifndef m_nc_h
28 #define m_nc_h
29 
30 #include "arts.h"
31 
32 #include "exceptions.h"
33 #include "workspace_ng.h"
34 #include "agenda_class.h"
35 
36 
37 #ifdef ENABLE_NETCDF
38 
39 #include "nc_io.h"
40 
41 /* Workspace method: Doxygen documentation will be auto-generated */
42 template<typename T> void
43 ReadNetCDF (// WS Generic Input:
44  T& v,
45  const String& v_name _U_,
46  const String& f,
47  // WS Generic Input Names:
48  const String& f_name _U_,
49  const Verbosity& verbosity)
50 
51 {
52  nca_read_from_file (f, v, verbosity);
53 }
54 
55 /* Workspace method: Doxygen documentation will be auto-generated */
56 template<typename T> void
57 WriteNetCDF (// WS Generic Input:
58  const T& v,
59  const String& f,
60  // WS Generic Input Names:
61  const String& v_name,
62  const String& f_name _U_,
63  const Verbosity& verbosity)
64 
65 {
66  String filename = f;
67 
68  // Create default filename if empty
69  nca_filename (filename, v_name);
70 
71  nca_write_to_file (filename, v, verbosity);
72 }
73 
74 /* Workspace method: Doxygen documentation will be auto-generated */
75 template<typename T> void
76 WriteNetCDFIndexed (//WS Input:
77  const Index& file_index,
78  // WS Generic Input:
79  const T& v,
80  const String& f,
81  // WS Generic Input Names:
82  const String& v_name,
83  const String& f_name,
84  const Verbosity& verbosity)
85 
86 {
87  String filename = f;
88 
89  // Create default filename if empty
90  nca_filename_with_index (filename, file_index, v_name);
91 
92  WriteNetCDF(v, filename, v_name, f_name, verbosity);
93 }
94 
95 #else // NetCDF not enabled
96 
97 /* Workspace method: Doxygen documentation will be auto-generated */
98 template<typename T> void
99 ReadNetCDF (// WS Generic Input:
100  T&,
101  const String&,
102  const String&,
103  // WS Generic Input Names:
104  const String&,
105  const Verbosity&)
106 
107 {
108  throw runtime_error("This version of ARTS was compiled without NetCDF support.");
109 }
110 
111 /* Workspace method: Doxygen documentation will be auto-generated */
112 template<typename T> void
113 WriteNetCDF (// WS Generic Input:
114  const T&,
115  const String&,
116  // WS Generic Input Names:
117  const String&,
118  const String&,
119  const Verbosity&)
120 
121 {
122  throw runtime_error("This version of ARTS was compiled without NetCDF support.");
123 }
124 
125 /* Workspace method: Doxygen documentation will be auto-generated */
126 template<typename T> void
127 WriteNetCDFIndexed (//WS Input:
128  const Index&,
129  // WS Generic Input:
130  const T&,
131  const String&,
132  // WS Generic Input Names:
133  const String&,
134  const String&,
135  const Verbosity&)
136 
137 {
138  throw runtime_error("This version of ARTS was compiled without NetCDF support.");
139 }
140 
141 #endif // ENABLE_NETCDF
142 
143 /* Workspace method: Doxygen documentation will be auto-generated */
144 template<typename T> void
146  // WS Generic Input:
147  T& v,
148  const String& v_name,
149  const String& f,
150  // WS Generic Input Names:
151  const String& f_name,
152  const Verbosity& verbosity)
153 
154 {
155  ReadNetCDF (v, f, v_name, f_name, verbosity);
156 }
157 
158 /* Workspace method: Doxygen documentation will be auto-generated */
159 void
161  // WS Generic Input:
162  const Agenda& v,
163  const String& f,
164  // WS Generic Input Names:
165  const String& v_name,
166  const String& f_name,
167  const Verbosity& verbosity)
168 {
169  WriteNetCDF (v, f, v_name, f_name, verbosity);
170 }
171 
172 #endif // m_nc_h
173 
INDEX Index
The type to use for all integer numbers and indices.
Definition: matpack.h:35
void nca_filename(String &filename, const String &varname)
Gives the default filename for the NetCDF formats.
Definition: nc_io.cc:55
This file contains basic functions to handle NetCDF data files.
void ReadNetCDF(T &v, const String &v_name, const String &f, const String &f_name, const Verbosity &verbosity)
WORKSPACE METHOD: ReadNetCDF.
Definition: m_nc.h:43
The Agenda class.
Definition: agenda_class.h:44
void WriteNetCDFIndexed(const Index &file_index, const T &v, const String &f, const String &v_name, const String &f_name, const Verbosity &verbosity)
WORKSPACE METHOD: WriteNetCDFIndexed.
Definition: m_nc.h:76
This file contains the declaration and partly the implementation of the workspace class...
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
The global header file for ARTS.
Declarations for agendas.
The declarations of all the exception classes.
void WriteNetCDF(const T &v, const String &f, const String &v_name, const String &f_name, const Verbosity &verbosity)
WORKSPACE METHOD: WriteNetCDF.
Definition: m_nc.h:57
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
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
Workspace class.
Definition: workspace_ng.h:47
#define _U_
Definition: config.h:167