ARTS
2.4.0(git:4fb77825)
|
Interactive ARTS workspace. More...
#include <interactive_workspace.h>
Public Member Functions | |
InteractiveWorkspace (const Index verbosity=1, const Index agenda_verbosity=0) | |
const char * | execute_agenda (const Agenda *a) |
Execute agenda. More... | |
const char * | execute_workspace_method (long id, const ArrayOfIndex &output, const ArrayOfIndex &input) |
Execute workspace method. More... | |
void | set_agenda_variable (Index id, const Agenda &src) |
Set agenda variable into workspace. More... | |
void | set_index_variable (Index id, const Index &src) |
Deep-copy of Index variable into workspace. More... | |
void | set_array_of_index_variable (Index id, size_t n, const Index *src) |
Deep-copy of ArrayOfIndex variable into workspace. More... | |
void | set_numeric_variable (Index id, const Numeric &src) |
Deep-copy of Numeric variable into workspace. More... | |
void | set_string_variable (Index id, const char *src) |
Deep-copy of String variable into workspace. More... | |
void | set_array_of_string_variable (Index id, size_t n, const char *const *src) |
Deep-copy of ArrayOfString variable into workspace. More... | |
void | set_vector_variable (Index id, size_t n, const Numeric *src) |
Deep-copy of Vector variable into workspace. More... | |
void | set_matrix_variable (Index id, size_t m, size_t n, const Numeric *src) |
Deep-copy of Matrix variable into workspace. More... | |
void | set_tensor3_variable (Index id, size_t l, size_t m, size_t n, const Numeric *src) |
Deep-copy of Tensor3 variable into workspace. More... | |
void | set_tensor4_variable (Index id, size_t k, size_t l, size_t m, size_t n, const Numeric *src) |
Deep-copy of Tensor4 variable into workspace. More... | |
void | set_tensor5_variable (Index id, size_t k, size_t l, size_t m, size_t n, size_t o, const Numeric *src) |
Deep-copy of Tensor5 variable into workspace. More... | |
void | set_tensor6_variable (Index id, size_t k, size_t l, size_t m, size_t n, size_t o, size_t p, const Numeric *src) |
Deep-copy of Tensor6 variable into workspace. More... | |
void | set_tensor7_variable (Index id, size_t k, size_t l, size_t m, size_t n, size_t o, size_t p, size_t q, const Numeric *src) |
Deep-copy of Tensor5 variable into workspace. More... | |
void | set_sparse_variable (Index id, Index m, Index n, Index nnz, const Numeric *src, const int *row_indices, const int *column_indices) |
Deep-copy of Sparse matrix into workspace. More... | |
void | execute_callback (Index callback_id) |
void | initialize_variable (Index id) |
Initialize workspace variable. More... | |
Index | add_variable (Index group_id, const char *name) |
Push a stack for a new variable to the workspace. More... | |
void | erase_variable (Index i, Index group_id) |
Remove a variable stack from the workspace. More... | |
void | swap (Index i, Index j) |
Remove a variable stack from the workspace. More... | |
bool | is_initialized (Index i) |
Checks existence of the given WSV. More... | |
Static Public Member Functions | |
static void | initialize () |
Workspace intialization. More... | |
static Index | add_callback (Callback *cb) |
Add callback to workspace. More... | |
Private Member Functions | |
void | resize () |
Resize workspace stack. More... | |
Private Member Functions inherited from Workspace | |
Workspace () | |
Construct a new workspace. More... | |
Workspace (const Workspace &workspace) | |
Workspace copy constructor. More... | |
virtual | ~Workspace () |
Destruct the workspace and free all WSVs. More... | |
void | del (Index i) |
Delete WSV. More... | |
void | duplicate (Index i) |
Duplicate WSV. More... | |
void | initialize () |
Reset the size of the workspace. More... | |
bool | is_initialized (Index i) |
Checks existence of the given WSV. More... | |
Index | depth (Index i) |
Return scoping level of the given WSV. More... | |
void * | pop (Index i) |
Remove the topmost WSV from its stack. More... | |
void | pop_free (Index i) |
Remove the topmost WSV from its stack and free its memory. More... | |
void | push (Index i, void *wsv) |
Push a new WSV onto its stack. More... | |
void | push_uninitialized (Index i, void *wsv) |
Put a new WSV onto its stack. More... | |
Index | nelem () |
Get the number of workspace variables. More... | |
Index | add_wsv_inplace (const WsvRecord &wsv) |
Add a new variable to existing workspace and to the static maps. More... | |
void * | operator[] (Index i) |
Retrieve a pointer to the given WSV. More... | |
Static Private Attributes | |
static size_t | n_anonymous_variables_ = 0 |
static std::vector< Callback * > | callbacks_ {} |
Static Private Attributes inherited from Workspace | |
static Array< WsvRecord > | wsv_data |
Global WSV data. More... | |
static map< String, Index > | WsvMap |
Global map associated with wsv_data. More... | |
Additional Inherited Members | |
Static Private Member Functions inherited from Workspace | |
static void | define_wsv_data () |
Define workspace variables. More... | |
static void | define_wsv_map () |
Map WSV names to indices. More... | |
static Index | add_wsv (const WsvRecord &wsv) |
Append a new WSV to the workspace. More... | |
Private Attributes inherited from Workspace | |
String | context |
Debugging context. More... | |
Array< stack< WsvStruct * > > | ws |
Workspace variable container. More... | |
Interactive ARTS workspace.
The InteractiveWorkspace class extends the ARTS Workspace class with features that are required to allow an interactive simulation session.
Definition at line 84 of file interactive_workspace.h.
InteractiveWorkspace::InteractiveWorkspace | ( | const Index | verbosity = 1 , |
const Index | agenda_verbosity = 0 |
||
) |
Definition at line 56 of file interactive_workspace.cc.
References global_data::AgendaMap, Zeeman::end(), Workspace::initialize(), Workspace::operator[](), Verbosity::set_agenda_verbosity(), Verbosity::set_file_verbosity(), Agenda::set_name(), Verbosity::set_screen_verbosity(), ARTS::Var::verbosity(), verbosity_at_launch, Workspace::wsv_data, global_data::WsvGroupMap, and Workspace::WsvMap.
Add callback to workspace.
So that a callback can be executed from within an agenda it must be stored within the workspace. This is done with this method. The returned index can then be inserted as a WSM call into a agenda, which will then trigger execution of the workspace when ARTS executes the given agenda.
[in] | cb | The callback to add to the workspace. |
Definition at line 280 of file interactive_workspace.h.
References callbacks_.
Referenced by agenda_insert_callback().
Push a stack for a new variable to the workspace.
Registers a new variable with and adds a new stack to the given workspace. If name is nullptr, a unique name is created.
group_id | Index of the group of the variable to add to the workspace. |
name | Char pointer to the name of the variable. |
Definition at line 323 of file interactive_workspace.cc.
References WorkspaceMemoryHandler::allocate(), n_anonymous_variables_, Workspace::push(), resize(), global_data::workspace_memory_handler, Workspace::ws, Workspace::wsv_data, and Workspace::WsvMap.
Referenced by add_variable().
Remove a variable stack from the workspace.
Remove the stack given by index id from the workspace. This is used by the C API to control the workspace size.
i | Index of the stack to erase. |
group_id | Index of the group of the variable. |
Definition at line 353 of file interactive_workspace.cc.
References Workspace::WsvStruct::auto_allocated, WorkspaceMemoryHandler::deallocate(), n_anonymous_variables_, global_data::workspace_memory_handler, Workspace::ws, Workspace::WsvStruct::wsv, Workspace::wsv_data, and Workspace::WsvMap.
Referenced by erase_variable().
const char * InteractiveWorkspace::execute_agenda | ( | const Agenda * | a | ) |
Execute agenda.
Executes the given agenda on this workspace.
[in] | a | Pointer to the agenda to execute. |
Definition at line 100 of file interactive_workspace.cc.
References Agenda::execute(), resize(), Workspace::ws, and Workspace::wsv_data.
Referenced by execute_agenda().
|
inline |
Definition at line 265 of file interactive_workspace.h.
References callbacks_.
Referenced by callback_getaway().
const char * InteractiveWorkspace::execute_workspace_method | ( | long | id, |
const ArrayOfIndex & | output, | ||
const ArrayOfIndex & | input | ||
) |
Execute workspace method.
Executes the WSM with given id on this workspace.
[in] | id | Workspace id of the workspace method to execute. |
[in] | output | Array containing the indices of the output variables in which to store the results. |
[in] | input | Array containing the indices of the input variables to the function calls. |
Definition at line 115 of file interactive_workspace.cc.
References CREATE_OUTS, get_wsv_id(), getaways, is_initialized(), MRecord::isInternal(), global_data::md_data, MdRecord::Name(), resize(), MdRecord::SetMethod(), string_buffer, swap(), ARTS::Var::verbosity(), Workspace::ws, and Workspace::wsv_data.
Referenced by execute_workspace_method().
|
static |
Workspace intialization.
This calls the required functions to get the workspace up and running, esentially executing what in called in the ARTS main, when ARTS is used in script mode.
Definition at line 79 of file interactive_workspace.cc.
References callback_getaway(), callback_mr, check_agenda_data(), define_agenda_data(), define_agenda_map(), define_md_data_raw(), define_md_map(), define_md_raw_map(), define_species_data(), define_species_map(), Workspace::define_wsv_data(), define_wsv_group_names(), Workspace::define_wsv_map(), expand_md_data_raw_to_md_data(), getaways, WorkspaceMemoryHandler::initialize(), global_data::md_data, and global_data::workspace_memory_handler.
Referenced by initialize().
void InteractiveWorkspace::initialize_variable | ( | Index | id | ) |
Initialize workspace variable.
If unitialized, initializes the workspace variable. If variable exists it is reinitialized to be empty.
id | Workspace variable index of the variable to (re)initialize. |
Definition at line 317 of file interactive_workspace.cc.
References Workspace::operator[](), and Workspace::pop_free().
Referenced by set_variable_value().
|
inline |
Checks existence of the given WSV.
[in] | i | WSV index. |
Definition at line 118 of file workspace_ng.h.
References Workspace::ws.
Referenced by execute_workspace_method(), get_variable_value(), and swap().
|
private |
Resize workspace stack.
This method resizes the array of stacks that manages the runtime memory of ARTS to match the number of WSV variables.
Definition at line 311 of file interactive_workspace.cc.
References copy(), Array< base >::nelem(), swap(), Workspace::ws, and Workspace::wsv_data.
Referenced by add_variable(), execute_agenda(), and execute_workspace_method().
Set agenda variable into workspace.
Copies the given agenda object into the Agenda variable with the given id in this workspace.
Note: This triggers checking of the agenda which can result in an exception being thrown from the call.
[in] | id | Workspace id of the agenda to set |
[in] | agenda | The agenda to copy into the workspace |
Definition at line 163 of file interactive_workspace.cc.
References global_data::AgendaMap, Agenda::check(), Agenda::name(), Workspace::operator[](), Agenda::set_name(), and verbosity_at_launch.
Referenced by set_variable_value().
Deep-copy of ArrayOfIndex variable into workspace.
[in] | id | Workspace id of the Index variable to set |
[in] | src | Pointer to the c-style index array to copy. |
Definition at line 195 of file interactive_workspace.cc.
References Workspace::operator[]().
void InteractiveWorkspace::set_array_of_string_variable | ( | Index | id, |
size_t | n, | ||
const char *const * | src | ||
) |
Deep-copy of ArrayOfString variable into workspace.
[in] | id | Workspace id of the ArrayOfString variable to set |
[in] | src | Pointer to the null-terminated c-string to copy into the workspace. |
Definition at line 186 of file interactive_workspace.cc.
References Workspace::operator[]().
Deep-copy of Index variable into workspace.
[in] | id | Workspace id of the Index variable to set |
[in] | src | The index value to copy into the workspace. |
Definition at line 174 of file interactive_workspace.cc.
References Workspace::operator[]().
void InteractiveWorkspace::set_matrix_variable | ( | Index | id, |
size_t | m, | ||
size_t | n, | ||
const Numeric * | src | ||
) |
Deep-copy of Matrix variable into workspace.
[in] | id | Workspace id of the Vector variable to set |
[in] | src | Pointer to the two-dimensional c-array of Numeric containing the matrix elements in column-major order. |
Definition at line 215 of file interactive_workspace.cc.
References MatrixView::get_c_array(), Workspace::operator[](), and Matrix::resize().
Deep-copy of Numeric variable into workspace.
[in] | id | Workspace id of the Numeric variable to set |
[in] | src | The index value to copy into the workspace. |
Definition at line 178 of file interactive_workspace.cc.
References Workspace::operator[]().
void InteractiveWorkspace::set_sparse_variable | ( | Index | id, |
Index | m, | ||
Index | n, | ||
Index | nnz, | ||
const Numeric * | src, | ||
const int * | row_indices, | ||
const int * | column_indices | ||
) |
Deep-copy of Sparse matrix into workspace.
Copies a sparse matrix in coordinate format into the workspace.
[in] | id | Workspace id of the Sparse variable to set |
[in] | m | Number of rows of the matrix |
[in] | n | Number of column of the matrix |
[in] | nnz | Number of non-zeros of the matrix |
[in] | src | Pointer to the one-dimensional c-array containing the matrix elements. |
[in] | inner_ptr | Pointer to the c-array of Index containing the row indices of the elements in src. |
[in] | outer_ptr | Pointer to the c-array of Index containing the column indices of the elements in src. |
Definition at line 289 of file interactive_workspace.cc.
References Sparse::insert_elements(), and Workspace::operator[]().
void InteractiveWorkspace::set_string_variable | ( | Index | id, |
const char * | src | ||
) |
Deep-copy of String variable into workspace.
[in] | id | Workspace id of the String variable to set |
[in] | src | Pointer to the null-terminated c-tring to copy into the workspace. |
Definition at line 182 of file interactive_workspace.cc.
References Workspace::operator[]().
void InteractiveWorkspace::set_tensor3_variable | ( | Index | id, |
size_t | l, | ||
size_t | m, | ||
size_t | n, | ||
const Numeric * | src | ||
) |
Deep-copy of Tensor3 variable into workspace.
[in] | id | Workspace id of the Tensor3 variable to set |
[in] | src | Pointer to the three-dimensional c-array of Numeric containing the tensor elements. |
Definition at line 226 of file interactive_workspace.cc.
References Tensor3View::get_c_array(), Workspace::operator[](), and Tensor3::resize().
void InteractiveWorkspace::set_tensor4_variable | ( | Index | id, |
size_t | k, | ||
size_t | l, | ||
size_t | m, | ||
size_t | n, | ||
const Numeric * | src | ||
) |
Deep-copy of Tensor4 variable into workspace.
[in] | id | Workspace id of the Tensor4 variable to set |
[in] | src | Pointer to the four-dimensional c-array of Numeric containing the tensor elements. |
Definition at line 235 of file interactive_workspace.cc.
void InteractiveWorkspace::set_tensor5_variable | ( | Index | id, |
size_t | k, | ||
size_t | l, | ||
size_t | m, | ||
size_t | n, | ||
size_t | o, | ||
const Numeric * | src | ||
) |
Deep-copy of Tensor5 variable into workspace.
[in] | id | Workspace id of the Tensor5 variable to set |
[in] | src | Pointer to the five-dimensional c-array of Numeric containing the tensor elements. |
Definition at line 244 of file interactive_workspace.cc.
void InteractiveWorkspace::set_tensor6_variable | ( | Index | id, |
size_t | k, | ||
size_t | l, | ||
size_t | m, | ||
size_t | n, | ||
size_t | o, | ||
size_t | p, | ||
const Numeric * | src | ||
) |
Deep-copy of Tensor6 variable into workspace.
[in] | id | Workspace id of the Tensor5 variable to set |
[in] | src | Pointer to the six-dimensional c-array of Numeric containing the tensor elements. |
Definition at line 258 of file interactive_workspace.cc.
void InteractiveWorkspace::set_tensor7_variable | ( | Index | id, |
size_t | k, | ||
size_t | l, | ||
size_t | m, | ||
size_t | n, | ||
size_t | o, | ||
size_t | p, | ||
size_t | q, | ||
const Numeric * | src | ||
) |
Deep-copy of Tensor5 variable into workspace.
[in] | id | Workspace id of the Tensor4 variable to set |
[in] | src | Pointer to the four-dimensional c-array of Numeric containing the tensor elements. |
Definition at line 273 of file interactive_workspace.cc.
Deep-copy of Vector variable into workspace.
[in] | id | Workspace id of the ArrayOfString variable to set |
[in] | src | Pointer to the c-array of Numeric containing the vector elements. |
Definition at line 205 of file interactive_workspace.cc.
References Workspace::operator[](), and Vector::resize().
Remove a variable stack from the workspace.
Remove the stack given by index id from the workspace. This is used by the C API to control the workspace size.
i | Index of the stack to erase. |
Definition at line 370 of file interactive_workspace.cc.
References is_initialized(), swap(), and Workspace::ws.
Referenced by execute_workspace_method().
|
staticprivate |
Definition at line 335 of file interactive_workspace.h.
Referenced by add_callback(), and execute_callback().
|
staticprivate |
Definition at line 334 of file interactive_workspace.h.
Referenced by add_variable(), and erase_variable().