ARTS  2.4.0(git:4fb77825)
arts_api.h
Go to the documentation of this file.
1 /* Copyright (C) 2017 Simon Pfreundschuh <simon.pfreundschuh@chalmers.se>
2 
3  This program is free software; you can redistribute it and/or
4  modify it under the terms of the GNU General Public License as
5  published by the Free Software Foundation; either version 2 of the
6  License, or (at your option) any 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 #ifndef _ARTS_ARTS_API_H_
30 #define _ARTS_ARTS_API_H_
31 
32 #define DLL_PUBLIC __attribute__((visibility("default")))
33 
34 #include "covariance_matrix.h"
35 #include "interactive_workspace.h"
36 
37 extern "C" {
38 
40 // Structs Definitions
42 
46  const char *name;
48  const char *description;
50  long group;
51 };
52 
64  const void *ptr;
78  long dimensions[7];
84  const int *inner_ptr;
90  const int *outer_ptr;
91 };
92 
97 struct MethodStruct {
99  long id;
105  const char *name;
111  const char *description;
116  unsigned long n_out;
121  const long *out;
126  unsigned long n_g_out;
132  const long *g_out_types;
137  unsigned long n_in;
142  const long *in;
147  unsigned long n_g_in;
153  const long *g_in_types;
154 };
155 
159  long major;
161  long minor;
163  long revision;
164 };
165 
166 
178  long indices[2];
179 
185  long position[2];
186 
191  long dimensions[2];
192 
200  const void *ptr;
201 
207  long nnz;
208 
215  const int *inner_ptr;
222  const int *outer_ptr;
223 };
224 
226 // Setup and Finalization.
228 
237 void include_path_push(const char *path);
238 
245 void include_path_pop();
246 
255 void data_path_push(const char *path);
256 
263 void data_path_pop();
264 
271 void initialize();
272 
278 void finalize();
279 
285 const char *get_error();
286 
293 void set_basename(const char *name);
294 
296 // Parsing and executing agendas.
298 
313 Agenda *parse_agenda(const char *filename);
314 
323 Agenda *create_agenda(const char *name);
324 
337  const Index id,
338  unsigned long n_args_out,
339  const long *args_out,
340  unsigned long n_args_in,
341  const long *args_in);
342 
348 void agenda_insert_callback(Agenda *a, void (*f)(InteractiveWorkspace *));
349 
363  Agenda *a,
364  long id,
365  long group_id);
366 
376 void agenda_append(Agenda *dst, const Agenda *src);
377 
384 void agenda_clear(Agenda *a);
385 
396 const char *execute_agenda(InteractiveWorkspace *workspace, const Agenda *a);
397 
403 void destroy_agenda(Agenda *a);
404 
406 // Creating Workspaces
408 
415  const Index agenda_verbosity = 0);
416 
419 void destroy_workspace(InteractiveWorkspace *workspace);
420 
422 // Accessing WSV Group Information
424 
427 unsigned long get_number_of_groups();
428 
431 const char *get_group_name(int i);
432 
434 // Accessing and Executing WSMs
436 
439 unsigned long get_number_of_methods();
440 
444 
453 const char *get_method_g_in(Index i, Index j);
454 
462 const char *get_method_g_in_default(Index i, Index j);
463 
468 const char *get_g_in_nodef() {
469  return NODEF;
470 }
471 
480 const char *get_method_g_out(Index i, Index j);
481 
496 const char *execute_workspace_method(InteractiveWorkspace *workspace,
497  long id,
498  unsigned long n_args_out,
499  const long *args_out,
500  unsigned long n_args_in,
501  const long *args_in);
502 
513 const char *method_print_doc(long id);
514 
516 // Accessing and Manipulating WSVs
518 
525 long lookup_workspace_variable(const char *s);
526 
529 unsigned long get_number_of_variables();
530 
538 
548  Index id,
549  Index group_id);
550 
561  Index id);
562 
577  long block_index,
578  bool inverse);
579 
610 const char *set_variable_value(InteractiveWorkspace *workspace,
611  long id,
612  long group_id,
613  VariableValueStruct value);
627 long add_variable(InteractiveWorkspace *workspace,
628  long group_id,
629  const char *name);
630 
642 void erase_variable(InteractiveWorkspace *workspace, long id, long group_id);
643 
653 }
654 
655 #endif // _ARTS_ARTS_API_
erase_variable
DLL_PUBLIC void erase_variable(InteractiveWorkspace *workspace, long id, long group_id)
Erase variable from workspace.
Definition: arts_api.cc:644
MethodStruct::g_in_types
const long * g_in_types
Generic input types.
Definition: arts_api.h:153
agenda_insert_callback
DLL_PUBLIC void agenda_insert_callback(Agenda *a, void(*f)(InteractiveWorkspace *))
Insert callback into agenda.
Definition: arts_api.cc:149
MethodStruct::n_g_in
unsigned long n_g_in
Number of generic input variables.
Definition: arts_api.h:147
VersionStruct::revision
long revision
Revision number.
Definition: arts_api.h:163
get_number_of_variables
DLL_PUBLIC unsigned long get_number_of_variables()
Number of defined WSVs.
Definition: arts_api.cc:293
set_basename
DLL_PUBLIC void set_basename(const char *name)
Set the ARTS basename.
Definition: arts_api.cc:68
initialize
DLL_PUBLIC void initialize()
Initalize ARTS runtime.
Definition: arts_api.cc:60
get_method_g_out
DLL_PUBLIC const char * get_method_g_out(Index i, Index j)
Get name value of generic output argument.
Definition: arts_api.cc:258
get_g_in_nodef
DLL_PUBLIC const char * get_g_in_nodef()
Get string defining missing default parameter.
Definition: arts_api.h:468
lookup_workspace_variable
DLL_PUBLIC long lookup_workspace_variable(const char *s)
Lookup workspace variable by name.
Definition: arts_api.cc:285
MethodStruct::n_g_out
unsigned long n_g_out
Number of generic output variables.
Definition: arts_api.h:126
get_method_g_in
DLL_PUBLIC const char * get_method_g_in(Index i, Index j)
Get name of generic input argument.
Definition: arts_api.cc:246
ARTS::Var::verbosity
Verbosity verbosity(Workspace &ws) noexcept
Definition: autoarts.h:7112
include_path_pop
DLL_PUBLIC void include_path_pop()
Remove last include path.
Definition: arts_api.cc:54
data_path_push
DLL_PUBLIC void data_path_push(const char *path)
Add data path.
Definition: arts_api.cc:56
parse_agenda
DLL_PUBLIC Agenda * parse_agenda(const char *filename)
Parse Controlfile.
Definition: arts_api.cc:73
CovarianceMatrix
Definition: covariance_matrix.h:226
get_method
DLL_PUBLIC MethodStruct get_method(Index i)
Return MethodStruct describing method with index i.
Definition: arts_api.cc:211
get_variable
DLL_PUBLIC VariableStruct get_variable(Index i)
Get WSV by index.
Definition: arts_api.cc:295
get_group_name
DLL_PUBLIC const char * get_group_name(int i)
Get pointer to name of given group.
Definition: arts_api.cc:204
agenda_append
DLL_PUBLIC void agenda_append(Agenda *dst, const Agenda *src)
Append agendas.
Definition: arts_api.cc:171
VersionStruct::major
long major
Major version number of ARTS.
Definition: arts_api.h:159
get_version
DLL_PUBLIC VersionStruct get_version()
Get ARTS Version.
Definition: arts_api.cc:649
VariableStruct::description
const char * description
Pointer to the c_str of the description of the variable.
Definition: arts_api.h:48
set_variable_value
DLL_PUBLIC const char * set_variable_value(InteractiveWorkspace *workspace, long id, long group_id, VariableValueStruct value)
Sets the value of a WSV in a given workspace.
Definition: arts_api.cc:512
MethodStruct::id
long id
The WSMs index in md_data.
Definition: arts_api.h:99
get_variable_value
DLL_PUBLIC VariableValueStruct get_variable_value(InteractiveWorkspace *workspace, Index id, Index group_id)
Get value WSV in given workspace.
Definition: arts_api.cc:300
DLL_PUBLIC
#define DLL_PUBLIC
Definition: arts_api.h:32
create_workspace
DLL_PUBLIC InteractiveWorkspace * create_workspace(const Index verbosity=1, const Index agenda_verbosity=0)
Create new workspace.
Definition: arts_api.cc:191
covariance_matrix.h
Header files of CovarianceMatrix class.
execute_workspace_method
DLL_PUBLIC const char * execute_workspace_method(InteractiveWorkspace *workspace, long id, unsigned long n_args_out, const long *args_out, unsigned long n_args_in, const long *args_in)
Execute workspace method.
Definition: arts_api.cc:262
VariableValueStruct::inner_ptr
const int * inner_ptr
Additional array data for sparse matrices.
Definition: arts_api.h:84
Agenda
The Agenda class.
Definition: agenda_class.h:44
VariableValueStruct::ptr
const void * ptr
Data pointer.
Definition: arts_api.h:64
get_error
DLL_PUBLIC const char * get_error()
Get most recent error.
Definition: arts_api.cc:66
destroy_agenda
DLL_PUBLIC void destroy_agenda(Agenda *a)
Destroy Agenda.
Definition: arts_api.cc:186
VariableStruct
Representation of ARTS WSVs.
Definition: arts_api.h:44
CovarianceMatrixBlockStruct::nnz
long nnz
Number of non-zero elements.
Definition: arts_api.h:207
get_number_of_groups
DLL_PUBLIC unsigned long get_number_of_groups()
Return number of WSV groups.
Definition: arts_api.cc:202
execute_agenda
DLL_PUBLIC const char * execute_agenda(InteractiveWorkspace *workspace, const Agenda *a)
Execute Agenda.
Definition: arts_api.cc:180
get_covariance_matrix_block
DLL_PUBLIC CovarianceMatrixBlockStruct get_covariance_matrix_block(CovarianceMatrix *m, long block_index, bool inverse)
Return block of covariance matrix.
Definition: arts_api.cc:467
MethodStruct::in
const long * in
Input variables.
Definition: arts_api.h:142
VariableValueStruct
Representation of ARTS values.
Definition: arts_api.h:58
NODEF
#define NODEF
Definition: methods.h:35
get_variable_data_pointer
DLL_PUBLIC void * get_variable_data_pointer(InteractiveWorkspace *workspace, Index id)
Get data pointer to the WSV variable.
Definition: arts_api.cc:463
include_path_push
DLL_PUBLIC void include_path_push(const char *path)
Add include path.
Definition: arts_api.cc:50
add_variable
DLL_PUBLIC long add_variable(InteractiveWorkspace *workspace, long group_id, const char *name)
Add variable of given type to workspace.
Definition: arts_api.cc:637
VersionStruct
ARTS version.
Definition: arts_api.h:157
CovarianceMatrixBlockStruct::dimensions
long dimensions[2]
Block size.
Definition: arts_api.h:191
MethodStruct::out
const long * out
Output variables.
Definition: arts_api.h:121
CovarianceMatrixBlockStruct::ptr
const void * ptr
Element pointer.
Definition: arts_api.h:200
get_method_g_in_default
DLL_PUBLIC const char * get_method_g_in_default(Index i, Index j)
Get default value of generic input argument.
Definition: arts_api.cc:250
VariableValueStruct::initialized
bool initialized
Initialization status.
Definition: arts_api.h:69
CovarianceMatrixBlockStruct::outer_ptr
const int * outer_ptr
Outer pointer for sparse matrices.
Definition: arts_api.h:222
VariableValueStruct::outer_ptr
const int * outer_ptr
Additional array data for sparse matrices.
Definition: arts_api.h:90
agenda_add_method
DLL_PUBLIC void agenda_add_method(Agenda *a, const Index id, unsigned long n_args_out, const long *args_out, unsigned long n_args_in, const long *args_in)
Add method to agenda.
get_number_of_methods
DLL_PUBLIC unsigned long get_number_of_methods()
Return number of WSMs.
Definition: arts_api.cc:209
CovarianceMatrixBlockStruct::position
long position[2]
Start indices of block.
Definition: arts_api.h:185
CovarianceMatrixBlockStruct
Covariance matrix block.
Definition: arts_api.h:172
MethodStruct::name
const char * name
Method name.
Definition: arts_api.h:105
method_print_doc
DLL_PUBLIC const char * method_print_doc(long id)
Print method documentation.
Definition: arts_api.cc:274
MethodStruct::g_out_types
const long * g_out_types
Generic output types.
Definition: arts_api.h:132
VersionStruct::minor
long minor
Minor version number of this ARTS major version.
Definition: arts_api.h:161
create_agenda
DLL_PUBLIC Agenda * create_agenda(const char *name)
Create Agenda.
Definition: arts_api.cc:88
CovarianceMatrixBlockStruct::inner_ptr
const int * inner_ptr
Inner pointer for sparse matrices.
Definition: arts_api.h:215
MethodStruct::description
const char * description
Method description.
Definition: arts_api.h:111
finalize
DLL_PUBLIC void finalize()
Finalize ARTS runtime.
Definition: arts_api.cc:62
agenda_insert_set
DLL_PUBLIC void agenda_insert_set(InteractiveWorkspace *ws, Agenda *a, long id, long group_id)
Insert a set method into an agenda.
Definition: arts_api.cc:94
destroy_workspace
DLL_PUBLIC void destroy_workspace(InteractiveWorkspace *workspace)
Destroy given workspace.
Definition: arts_api.cc:196
VariableValueStruct::dimensions
long dimensions[7]
Dimensions of array data.
Definition: arts_api.h:78
VariableStruct::group
long group
The Index value representing the group this variable belongs to.
Definition: arts_api.h:50
MethodStruct::n_in
unsigned long n_in
Number of non-generic input variables.
Definition: arts_api.h:137
MethodStruct::n_out
unsigned long n_out
Number of non-generic output variables.
Definition: arts_api.h:116
MethodStruct
Representation of workspace methods.
Definition: arts_api.h:97
data_path_pop
DLL_PUBLIC void data_path_pop()
Remove last data path.
Definition: arts_api.cc:58
Index
INDEX Index
The type to use for all integer numbers and indices.
Definition: matpack.h:39
VariableStruct::name
const char * name
Pointer to the c_str of the name of the variable.
Definition: arts_api.h:46
agenda_clear
DLL_PUBLIC void agenda_clear(Agenda *a)
Clear Agenda.
Definition: arts_api.cc:178
CovarianceMatrixBlockStruct::indices
long indices[2]
Quantity indices.
Definition: arts_api.h:178
interactive_workspace.h
This file contains all declarations of the ARTS C API.
InteractiveWorkspace
Interactive ARTS workspace.
Definition: interactive_workspace.h:84