ARTS 2.5.4 (git: bcd8c674)
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
19// File description
21
29#include "arts.h"
30
31#ifdef ENABLE_NETCDF
32
33#ifndef nc_io_h
34#define nc_io_h
35
36#include <netcdf.h>
37#include "species_tags.h"
38#include "exceptions.h"
39#include "messages.h"
40#include "mystring.h"
41
43// Default file names
45
46void nca_filename(String& filename, const String& varname);
47
48void nca_filename_with_index(String& filename,
49 const Index& file_index,
50 const String& varname);
51
53// Generic IO routines for XML files
55
56template <typename T>
57void nca_read_from_file(const String& filename,
58 T& type,
59 const Verbosity& verbosity);
60
61template <typename T>
62void nca_write_to_file(const String& filename,
63 const T& type,
64 const Verbosity& verbosity);
65
66/*void nc_read_var(const int ncf, const int **ncvar,
67 const Index dims, const String& name);*/
68
69void nca_def_dim(const int ncid,
70 const String& name,
71 const Index nelem,
72 int* ncdim);
73void nca_def_var(const int ncid,
74 const String& name,
75 const nc_type type,
76 const int ndims,
77 const int* dims,
78 int* varid);
79
80int nca_def_ArrayOfIndex(const int ncid,
81 const String& name,
82 const ArrayOfIndex& a);
83
84int nca_def_Vector(const int ncid, const String& name, const Vector& v);
85
86int nca_def_Matrix(const int ncid, const String& name, const Matrix& m);
87
88int nca_def_Tensor4(const int ncid, const String& name, const Tensor4& t);
89
90Index nc_get_dim(const int ncid,
91 const String& name,
92 const bool noerror = false);
93
94void nca_get_data_int(const int ncid, const String& name, int* data);
95
96void nca_get_data_long(const int ncid, const String& name, long* data);
97
98void nca_get_data_double(const int ncid, const String& name, Numeric* data);
99
100void nca_get_dataa_double(const int ncid,
101 const String& name,
102 size_t start,
103 size_t count,
104 Numeric* data);
105
106void nca_get_data_text(const int ncid, const String& name, char* data);
107
108void nca_get_data_ArrayOfIndex(const int ncid,
109 const String& name,
110 ArrayOfIndex& aoi,
111 const bool noerror);
112
113void nca_get_data_ArrayOfArrayOfSpeciesTag(const int ncid,
114 const String& name,
116 const bool noerror);
117
118void nca_get_data_Vector(const int ncid,
119 const String& name,
120 Vector& v,
121 const bool noerror = false);
122
123void nca_get_data_Matrix(const int ncid,
124 const String& name,
125 Matrix& m,
126 const bool noerror = false);
127
128void nca_get_data_Tensor4(const int ncid,
129 const String& name,
130 Tensor4& m,
131 const bool noerror = false);
132
133bool nca_put_var_ArrayOfIndex(const int ncid,
134 const int varid,
135 const ArrayOfIndex& a);
136
137bool nca_put_var_Vector(const int ncid, const int varid, const Vector& v);
138
139bool nca_put_var_Matrix(const int ncid, const int varid, const Matrix& m);
140
141bool nca_put_var_Tensor4(const int ncid, const int varid, const Tensor4& t);
142
143void nca_error(const int err, const String msg);
144
145#endif /* nc_io_h */
146
147#endif /* ENABLE_NETCDF */
The global header file for ARTS.
The Matrix class.
Definition: matpackI.h:1283
The Tensor4 class.
Definition: matpackIV.h:429
The Vector class.
Definition: matpackI.h:922
The declarations of all the exception classes.
NUMERIC Numeric
The type to use for all floating point numbers.
Definition: matpack.h:33
INDEX Index
The type to use for all integer numbers and indices.
Definition: matpack.h:39
Declarations having to do with the four output streams.
This file contains the definition of String, the ARTS string class.
Index nelem(const Lines &l)
Number of lines.
constexpr Rational start(Rational Ju, Rational Jl, Polarization type) noexcept
Gives the lowest M for a polarization type of this transition.
Definition: zeemandata.h:80
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
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:277
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:359
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:214
void nca_filename(String &filename, const String &varname)
Gives the default filename for the NetCDF formats.
Definition: nc_io.cc:53
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:236
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:375
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:327
void nca_error(const int err, const String msg)
Throws a runtime error for the given NetCDF error code.
Definition: nc_io.cc:622
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:343
Index nc_get_dim(const int ncid, const String &name, const bool noerror=false)
Read a dimension from NetCDF file.
Definition: nc_io.cc:300
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:478
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:194
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:256
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:413
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:438
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:604
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:395
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:517
void nca_def_dim(const int ncid, const String &name, const Index nelem, int *ncdim)
Define NetCDF dimension.
Definition: nc_io.cc:174
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:539
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:585
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:497
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
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:566
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
#define v
#define a