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