ARTS  2.4.0(git:4fb77825)
make_workspace_memory_handler_cc.cc
Go to the documentation of this file.
1 /* Copyright (C) 2020 Simon Pfreundschuh <simon.pfreundschuh@chalmers.se>
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 
19 #include <iostream>
20 #include <stdexcept>
21 #include "array.h"
22 #include "arts.h"
23 #include "file.h"
24 #include "global_data.h"
25 #include "matpackI.h"
26 
27 int main() {
28  try {
31 
32  ofstream ofs;
33  open_output_file(ofs, "workspace_memory_handler.cc");
34 
35  ofs << "/*! \\file workspace_memory_handler.cc\n"
36  << " *\n"
37  << " * \\brief Defines global workspace_handler_objects and its \n"
38  << " * dispatch functions.\n\n"
39  << " * <b>DO NOT EDIT!</b>\n\n"
40  << " * \\date " << __DATE__ << ", " << __TIME__ << "\n"
41  << " */\n\n";
42 
43  ofs << "#include \"workspace_memory_handler.h\"\n"
44  << "#include <iostream>\n"
45  << "#include \"matpackII.h\"\n"
46  << "#include \"m_general.h\"\n"
47  << "#include \"supergeneric.h\"\n"
48  << "#include \"artstime.h\"\n"
49  << "#include \"ppath.h\"\n"
50  << "#include \"gas_abs_lookup.h\"\n"
51  << "#include \"linemixing_hitran.h\"\n"
52  << "#include \"optproperties.h\"\n"
53  << "#include \"gridded_fields.h\"\n"
54  << "#include \"jacobian.h\"\n"
55  << "#include \"agenda_class.h\"\n"
56  << "#include \"mc_interp.h\"\n"
57  << "#include \"mc_antenna.h\"\n"
58  << "#include \"cia.h\"\n"
59  << "#include \"propagationmatrix.h\"\n"
60  << "#include \"transmissionmatrix.h\"\n"
61  << "#include \"covariance_matrix.h\"\n"
62  << "#include \"telsem.h\"\n"
63  << "#include \"tessem.h\"\n"
64  << "#include \"hitran_xsec.h\"\n"
65  << "#include \"absorptionlines.h\"\n"
66  << "\n";
67 
68  ofs << "// Allocation and deallocation routines for workspace groups\n";
69  for (Index i = 0; i < wsv_group_names.nelem(); ++i) {
70  ofs << "void *allocate_wsvg_" << wsv_group_names[i] << "(){\n"
71  << " return (void *)new " << wsv_group_names[i] << ";\n}\n"
72  << "void deallocate_wsvg_" << wsv_group_names[i]
73  << "(void *vp)\n"
74  << " { delete (" << wsv_group_names[i] << " *)vp;\n}\n"
75  << "void *duplicate_wsvg_" << wsv_group_names[i]
76  << "(void *vp) {"
77  << " return (new " << wsv_group_names[i] << "(*("
78  << wsv_group_names[i] << " *)vp));\n}\n\n";
79  }
80 
81  ofs << " /// Initialization dispatch functions.\n"
82  << "void WorkspaceMemoryHandler::initialize() {\n"
83  << " allocation_ptrs_.resize(" << wsv_group_names.size() << ");\n"
84  << " deallocation_ptrs_.resize(" << wsv_group_names.size() << ");\n"
85  << " duplication_ptrs_.resize(" << wsv_group_names.size() << ");\n\n";
86 
87  for (Index i = 0; i < wsv_group_names.nelem(); ++i) {
88  ofs << " allocation_ptrs_[" << i << "] = allocate_wsvg_" << wsv_group_names[i]
89  << ";\n"
90  << " deallocation_ptrs_[" << i << "] = deallocate_wsvg_" << wsv_group_names[i]
91  << ";\n"
92  << " duplication_ptrs_[" << i << "] = duplicate_wsvg_" << wsv_group_names[i]
93  << ";\n";
94  }
95  ofs << "}\n";
96  } catch (const std::runtime_error &x) {
97  cout << "Something went wrong. Message text:\n";
98  cout << x.what() << '\n';
99  return 1;
100  }
101 
102  return 0;
103 }
main
int main()
Definition: make_workspace_memory_handler_cc.cc:27
array.h
This file contains the definition of Array.
matpackI.h
Implementation of Matrix, Vector, and such stuff.
define_wsv_group_names
void define_wsv_group_names()
Define the array of workspace variable group names.
Definition: groups.cc:77
global_data.h
open_output_file
void open_output_file(ofstream &file, const String &name)
Open a file for writing.
Definition: file.cc:93
file.h
This file contains basic functions to handle ASCII files.
ARTS::Var::x
Vector x(Workspace &ws) noexcept
Definition: autoarts.h:7346
Index
INDEX Index
The type to use for all integer numbers and indices.
Definition: matpack.h:39
global_data::wsv_group_names
const ArrayOfString wsv_group_names
The names associated with Wsv groups as Strings.
Definition: global_data.h:93
Array::nelem
Index nelem() const
Number of elements.
Definition: array.h:195
arts.h
The global header file for ARTS.