TECA
The Toolkit for Extreme Climate Analysis
teca_algorithm Class Referenceabstract

The interface to TECA pipeline architecture. More...

#include <teca_algorithm.h>

Inheritance diagram for teca_algorithm:
Collaboration diagram for teca_algorithm:

Public Member Functions

 teca_algorithm (const teca_algorithm &src)=delete
 
 teca_algorithm (teca_algorithm &&src)=delete
 
teca_algorithmoperator= (const teca_algorithm &src)=delete
 
teca_algorithmoperator= (teca_algorithm &&src)=delete
 
virtual const char * get_class_name () const =0
 return the name of the class. More...
 
void set_communicator (MPI_Comm comm)
 
MPI_Comm get_communicator ()
 get the active communicator More...
 
virtual teca_algorithm_output_port get_output_port (unsigned int port=0)
 
void set_input_connection (const teca_algorithm_output_port &port)
 set an input to this algorithm More...
 
virtual void set_input_connection (unsigned int id, const teca_algorithm_output_port &port)
 set an input to this algorithm More...
 
virtual void remove_input_connection (unsigned int id)
 remove input connections More...
 
void clear_input_connections ()
 remove all input connections More...
 
const_p_teca_dataset get_output_data (unsigned int port=0)
 
void pop_cache (unsigned int port=0, int top=0)
 
void set_cache_size (unsigned int n)
 set the cache size. the default is 1. (threadsafe) More...
 
virtual int update ()
 execute the pipeline from this instance up. More...
 
virtual int update (unsigned int port)
 execute the pipeline from this instance up. More...
 
virtual teca_metadata update_metadata (unsigned int port=0)
 get meta data considering this instance up. More...
 
void set_executive (p_teca_algorithm_executive exe)
 set the executive More...
 
p_teca_algorithm_executive get_executive ()
 get the executive More...
 
virtual void to_stream (std::ostream &s) const
 
virtual void from_stream (std::istream &s)
 deserialize from the stream. More...
 
verbose

if set to a non-zero value, rank 0 will send status information to the terminal. The default setting of zero results in no output.

void set_verbose (const int &v)
 
const int & get_verbose () const
 

Protected Member Functions

void set_number_of_input_connections (unsigned int n)
 
void set_number_of_output_ports (unsigned int n)
 
virtual void set_modified ()
 
void set_modified (unsigned int port)
 an overload to set_modified by port More...
 
virtual teca_metadata get_output_metadata (unsigned int port, const std::vector< teca_metadata > &input_md)
 
virtual std::vector< teca_metadataget_upstream_request (unsigned int port, const std::vector< teca_metadata > &input_md, const teca_metadata &request)
 
virtual const_p_teca_dataset execute (unsigned int port, const std::vector< const_p_teca_dataset > &input_data, const teca_metadata &request)
 
virtual teca_metadata get_cache_key (unsigned int port, const teca_metadata &request) const
 
virtual teca_metadata get_output_metadata (teca_algorithm_output_port &current)
 
virtual const_p_teca_dataset request_data (teca_algorithm_output_port &port, const teca_metadata &request)
 
virtual int validate_cache (teca_algorithm_output_port &current)
 
virtual void clear_modified (teca_algorithm_output_port current)
 
const_p_teca_dataset get_output_data (unsigned int port, const teca_metadata &request)
 
int cache_output_data (unsigned int port, const teca_metadata &request, const_p_teca_dataset &data)
 
void clear_cache (unsigned int port)
 clear the cache on the given output port More...
 
unsigned int get_number_of_input_connections ()
 get the number of input connections More...
 
teca_algorithm_output_portget_input_connection (unsigned int i)
 
void clear_modified (unsigned int port)
 clear the modified flag on the i'th output More...
 
int get_modified (unsigned int port) const
 return the output port's modified flag value More...
 

Protected Attributes

int verbose
 

Friends

class teca_threaded_algorithm
 
class teca_data_request
 

Detailed Description

The interface to TECA pipeline architecture.

All sources/readers filters, sinks/writers will implement this interface.

Member Function Documentation

◆ cache_output_data()

int teca_algorithm::cache_output_data ( unsigned int  port,
const teca_metadata request,
const_p_teca_dataset &  data 
)
protected

add or update the given request , dataset pair in the cache. see also get_cache_key. (threadsafe)

◆ clear_cache()

void teca_algorithm::clear_cache ( unsigned int  port)
protected

clear the cache on the given output port

◆ clear_input_connections()

void teca_algorithm::clear_input_connections ( )

remove all input connections

◆ clear_modified() [1/2]

virtual void teca_algorithm::clear_modified ( teca_algorithm_output_port  current)
protectedvirtual

driver function that clears the modified flag on the named port and all of it's upstream connections.

◆ clear_modified() [2/2]

void teca_algorithm::clear_modified ( unsigned int  port)
protected

clear the modified flag on the i'th output

◆ execute()

virtual const_p_teca_dataset teca_algorithm::execute ( unsigned int  port,
const std::vector< const_p_teca_dataset > &  input_data,
const teca_metadata request 
)
protectedvirtual

implementations must override this method and produce the output dataset for the port named in the first argument. The second argument is a list of all of the input datasets. See also get_request. The third argument contains a request from the consumer which can specify information such as arrays, subset region, timestep etc. The implementation is free to handle the request as it sees fit.

Reimplemented in teca_threaded_algorithm, teca_vertical_reduction, and teca_cf_time_axis_reader.

◆ from_stream()

virtual void teca_algorithm::from_stream ( std::istream &  s)
virtual

deserialize from the stream.

◆ get_cache_key()

virtual teca_metadata teca_algorithm::get_cache_key ( unsigned int  port,
const teca_metadata request 
) const
protectedvirtual

implementations may choose to override this method to gain control of keys used in the cache. By default the passed in request is used as the key. This override gives implementor the chance to filter the passed in request.

◆ get_class_name()

virtual const char* teca_algorithm::get_class_name ( ) const
pure virtual

return the name of the class.

Implemented in teca_programmable_algorithm, teca_table_reader, teca_cf_reader, teca_cf_writer, teca_threaded_programmable_algorithm, teca_cartesian_mesh_source, teca_multi_cf_reader, teca_array_collection_reader, teca_wrf_reader, teca_threaded_algorithm, teca_elevation_mask, teca_tc_candidates, teca_2d_component_area, teca_connected_components, teca_programmable_reduce, teca_bayesian_ar_detect, teca_component_area_filter, teca_valid_value_mask, teca_normalize_coordinates, teca_apply_binary_mask, teca_tc_trajectory, teca_latitude_damper, teca_table_remove_rows, teca_cartesian_mesh_regrid, teca_evaluate_expression, teca_table_calendar, teca_dataset_diff, teca_time_axis_convolution, teca_unpack_data, teca_cartesian_mesh_reader, teca_cartesian_mesh_coordinate_transform, teca_integrated_vapor_transport, teca_table_writer, teca_integrated_water_vapor, teca_binary_segmentation, teca_tc_wind_radii, teca_cartesian_mesh_subset, teca_table_region_mask, teca_tc_classify, teca_indexed_dataset_cache, teca_table_reduce, teca_vertical_reduction, teca_dataset_capture, teca_cartesian_mesh_writer, teca_mask, teca_simple_moving_average, teca_dataset_source, teca_cf_time_axis_data_reduce, teca_descriptive_statistics, teca_shape_file_mask, teca_cf_time_axis_reader, teca_table_sort, teca_table_to_stream, teca_component_statistics, teca_face_to_cell_centering, teca_l2_norm, teca_laplacian, teca_rename_variables, teca_vertical_coordinate_transform, teca_vorticity, and teca_bayesian_ar_detect_parameters.

◆ get_communicator()

MPI_Comm teca_algorithm::get_communicator ( )

get the active communicator

◆ get_executive()

p_teca_algorithm_executive teca_algorithm::get_executive ( )

get the executive

◆ get_input_connection()

teca_algorithm_output_port& teca_algorithm::get_input_connection ( unsigned int  i)
protected

get the output port associated with this algorithm's i'th input connection.

◆ get_modified()

int teca_algorithm::get_modified ( unsigned int  port) const
protected

return the output port's modified flag value

◆ get_number_of_input_connections()

unsigned int teca_algorithm::get_number_of_input_connections ( )
protected

get the number of input connections

◆ get_output_data() [1/2]

const_p_teca_dataset teca_algorithm::get_output_data ( unsigned int  port,
const teca_metadata request 
)
protected

search the given port's cache for the dataset associated with the given request. see also get_cache_key. (threadsafe)

◆ get_output_data() [2/2]

const_p_teca_dataset teca_algorithm::get_output_data ( unsigned int  port = 0)

access the cached data produced by this algorithm. when no request is specified the dataset on the top(most recent) of the cache is returned. When a request is specified it may optionally be filtered by the implementations cache key filter. see also get_cache_key (threadsafe)

◆ get_output_metadata() [1/2]

virtual teca_metadata teca_algorithm::get_output_metadata ( teca_algorithm_output_port current)
protectedvirtual

driver function that manage meta data reporting phase of pipeline execution.

◆ get_output_metadata() [2/2]

virtual teca_metadata teca_algorithm::get_output_metadata ( unsigned int  port,
const std::vector< teca_metadata > &  input_md 
)
protectedvirtual

implementations must override this method to provide information to downstream consumers about what data will be produced on each output port. The port to provide information about is named in the first argument the second argument contains a list of the metadata describing data on all of the inputs.

Reimplemented in teca_index_reduce, teca_vertical_reduction, and teca_cf_time_axis_reader.

◆ get_output_port()

virtual teca_algorithm_output_port teca_algorithm::get_output_port ( unsigned int  port = 0)
virtual

get an output port from the algorithm. to be used during pipeline building

◆ get_upstream_request()

virtual std::vector<teca_metadata> teca_algorithm::get_upstream_request ( unsigned int  port,
const std::vector< teca_metadata > &  input_md,
const teca_metadata request 
)
protectedvirtual

implementations must override this method and generate a set of requests describing the data required on the inputs to produce data for the named output port, given the upstream meta data and request. If no data is needed on an input then the list should contain a null request.

Reimplemented in teca_index_reduce, and teca_vertical_reduction.

◆ get_verbose()

const int& teca_algorithm::get_verbose ( ) const
inline

Get the value of the verbose algorithm property

◆ pop_cache()

void teca_algorithm::pop_cache ( unsigned int  port = 0,
int  top = 0 
)

remove a dataset from the top/bottom of the cache. the top of the cache has the most recently created dataset. top or bottom is selected via the boolean argument. (threadsafe)

◆ remove_input_connection()

virtual void teca_algorithm::remove_input_connection ( unsigned int  id)
virtual

remove input connections

◆ set_cache_size()

void teca_algorithm::set_cache_size ( unsigned int  n)

set the cache size. the default is 1. (threadsafe)

◆ set_communicator()

void teca_algorithm::set_communicator ( MPI_Comm  comm)

set the communicator to use at this stage of the pipeline this has no influence on other stages. We duplicate the passed in communicator providing an isolated communication space for subsequent operations. By default the communicator is initialized to MPI_COMM_WORLD, here it is not duplicated. Thus to put an algorithm into a unique communication space one should explicitly set a communicator. When an algorithm should not use MPI, for instance when it is in a nested pipeline, one may set the communicator to MPI_COMM_SELF.

◆ set_executive()

void teca_algorithm::set_executive ( p_teca_algorithm_executive  exe)

set the executive

◆ set_input_connection() [1/2]

void teca_algorithm::set_input_connection ( const teca_algorithm_output_port port)
inline

set an input to this algorithm

◆ set_input_connection() [2/2]

virtual void teca_algorithm::set_input_connection ( unsigned int  id,
const teca_algorithm_output_port port 
)
virtual

set an input to this algorithm

Reimplemented in teca_tc_wind_radii, and teca_bayesian_ar_detect.

◆ set_modified() [1/2]

virtual void teca_algorithm::set_modified ( )
protectedvirtual

set the modified flag on the given output port's cache. should be called when user modifies properties on the object that require the output to be regenerated.

Reimplemented in teca_cartesian_mesh_coordinate_transform, teca_shape_file_mask, and teca_cf_time_axis_reader.

◆ set_modified() [2/2]

void teca_algorithm::set_modified ( unsigned int  port)
protected

an overload to set_modified by port

◆ set_number_of_input_connections()

void teca_algorithm::set_number_of_input_connections ( unsigned int  n)
protected

Set the number of input connections. implementations should call this from their constructors to setup the internal caches and data structures required for execution.

◆ set_number_of_output_ports()

void teca_algorithm::set_number_of_output_ports ( unsigned int  n)
protected

Set the number of output ports. implementations should call this from their constructors to setup the internal caches and data structures required for execution.

◆ set_verbose()

void teca_algorithm::set_verbose ( const int &  v)
inline

Set the value of the verbose algorithm property

◆ to_stream()

virtual void teca_algorithm::to_stream ( std::ostream &  s) const
virtual

serialize the configuration to a stream. this should store the public user modifiable properties so that runtime configuration may be saved and restored.

Reimplemented in teca_tc_candidates.

◆ update() [1/2]

virtual int teca_algorithm::update ( )
virtual

execute the pipeline from this instance up.

◆ update() [2/2]

virtual int teca_algorithm::update ( unsigned int  port)
virtual

execute the pipeline from this instance up.

◆ update_metadata()

virtual teca_metadata teca_algorithm::update_metadata ( unsigned int  port = 0)
virtual

get meta data considering this instance up.

◆ validate_cache()

virtual int teca_algorithm::validate_cache ( teca_algorithm_output_port current)
protectedvirtual

driver function that clears the output data cache where modified flag has been set from the current port upstream.


The documentation for this class was generated from the following file: