Option Definition/Generation

define_opt()

Public: Defines process option.

  • $1 - Option name.

  • $2 - Value associated to the option being defined.

  • $3 - Name of variable that will store the information about the option to be added.

Examples:

define_opt "-o" "${value}" "optlist"

The function does not return any value

define_infile_opt()

Public: Defines process option whose value is a file path, resolved relative to the .sh defining the process.

  • $1 - Option name.

  • $2 - File path associated to the option being defined (relative or absolute).

  • $3 - Name of variable that will store the information about the option to be added.

  • $4 - Name of the process this option is being defined for.

Examples:

define_infile_opt "-f" "config/settings.txt" "optlist" "${process_name}"

The function does not return any value

define_indir_opt()

Public: Defines process option whose value is a directory path, resolved relative to the .sh defining the process.

  • $1 - Option name.

  • $2 - Directory path associated to the option being defined (relative or absolute).

  • $3 - Name of variable that will store the information about the option to be added.

  • $4 - Name of the process this option is being defined for.

Examples:

define_indir_opt "-d" "reference" "optlist" "${process_name}"

The function does not return any value

define_flag()

Public: Defines process flag.

  • $1 - Name of flag given in the command line.

  • $2 - Name of the variable that will store the newly added option.

Examples:

define_flag "${cmdline}" "-o" "optlist"

The function does not return any value

define_cmdline_opt()

Public: Defines process option from command-line option.

  • $1 - Command-line options taken as input of the define_opts or generate_opts method.

  • $2 - Name of option given in the command line.

  • $3 - Name of the variable that will store the newly added option.

Examples:

define_cmdline_opt "${cmdline}" "-o" "optlist"

The function does not return any value

define_cmdline_opt_if_given()

Public: Defines process option only if it was given through the command-line.

  • $1 - Command-line options taken as input of the define_opts or generate_opts method.

  • $2 - Name of option given in the command line.

  • $3 - Name of the variable that will store the newly added option.

Examples:

define_cmdline_opt_if_given "${cmdline}" "-o" "optlist"

The function does not return any value

define_cmdline_infile_opt()

Public: Defines process option from a command-line option, verifying that it names an existing file and normalizing it to an absolute path.

  • $1 - Command-line options taken as input of the define_opts or generate_opts method.

  • $2 - Name of option given in the command line.

  • $3 - Name of the variable that will store the newly added option.

Examples:

define_cmdline_infile_opt "${cmdline}" "-f" "optlist"

The function does not return any value

define_cmdline_infile_opt_if_given()

Public: Defines process option from a command-line option that names an existing file, only if the option was given through the command line; verifies the file exists and normalizes it to an absolute path.

  • $1 - Command-line options taken as input of the define_opts or generate_opts method.

  • $2 - Name of option given in the command line.

  • $3 - Name of the variable that will store the newly added option.

Examples:

define_cmdline_infile_opt_if_given "${cmdline}" "-f" "optlist"

The function does not return any value

define_cmdline_indir_opt()

Public: Defines process option from a command-line option, verifying that it names an existing directory and normalizing it to an absolute path.

  • $1 - Command-line options taken as input of the define_opts or generate_opts method.

  • $2 - Name of option given in the command line.

  • $3 - Name of the variable that will store the newly added option.

Examples:

define_cmdline_indir_opt "${cmdline}" "-d" "optlist"

The function does not return any value

define_cmdline_indir_opt_if_given()

Public: Defines process option from a command-line option that names an existing directory, only if the option was given through the command line; verifies the directory exists and normalizes it to an absolute path.

  • $1 - Command-line options taken as input of the define_opts or generate_opts method.

  • $2 - Name of option given in the command line.

  • $3 - Name of the variable that will store the newly added option.

Examples:

define_cmdline_indir_opt_if_given "${cmdline}" "-d" "optlist"

The function does not return any value

define_cmdline_flag_if_given()

Public: Defines process flag only if it was given through the command-line.

  • $1 - Command-line options taken as input of the define_opts or generate_opts method.

  • $2 - Name of option given in the command line.

  • $3 - Name of the variable that will store the newly added option.

Examples:

define_cmdline_flag_if_given "${cmdline}" "-o" "optlist"

The function does not return any value

define_procspec_opt()

Public: Defines process option from a process specification attribute (computational or additional). The attribute is searched for first among the process’s computational specs (cpus, mem, time, nodes, account, partition, throttle) and, if not found there, among its additional specs (processdeps, force, alias, ext_alias); aborts if found in neither.

  • $1 - Process specification, as given to the define_opts method.

  • $2 - Name of the option to be added.

  • $3 - Name of the process specification attribute (e.g. “cpus”, “mem”).

  • $4 - Name of the variable that will store the newly added option.

Examples:

define_procspec_opt "${process_spec}" "-cpus" "cpus" "optlist"

The function does not return any value

define_fifo_opt()

Public: Defines fifo option for process.

  • $1 - Option name.

  • $2 - Name of fifo.

  • $3 - Name of variable that will store the information about the option to be added.

  • $4… - (optional) “–mirror”, and “–control” or “–external” (see debasher::define_fifo_opt).

This function should only be defined in one of the processes connected by the FIFO. More specifically, in the process defining an output option, except for a tagged fifo whose writer is outside the program.

Examples:

define_fifo_opt "-outf" "${fifoname}" "optlist"

The function does not return any value

define_fifo_opt_generator()

Public: Defines a fifo option generator.

  • $1 - Option name.

  • $2 - Name of fifo.

  • $3 - Index of the task whose options the generator is producing.

  • $4 - Name of variable that will store the information about the option to be added.

  • $5… - (optional) “–mirror”, and “–control” or “–external” (see debasher::define_fifo_opt).

The same function as define_fifo_opt, kept for the modules that call it; it ignores the task index it is given (see debasher::define_fifo_opt_generator).

Examples:

define_fifo_opt_generator "-outf" "${fifoname}" "${task_idx}" "optlist"

The function does not return any value

define_opt_from_proc_out()

Public: Defines process option from the output of another process.

  • $1 - Option name.

  • $2 - Name of process that will be connected with current one.

  • $3 - Name of output option belonging to the the process to be connected.

  • $4 - Name of the variable to store the new option.

Examples:

define_opt_from_proc_out "-in" "process_to_be_connected" "-out" optlist

The function does not return any value

define_opt_from_proc_task_out()

Public: Defines process option from the output of another process.

  • $1 - Option name.

  • $2 - Name of process that will be connected with current one.

  • $3 - Task index of the process to be connected.

  • $4 - Name of output option belonging to the the process to be connected.

  • $5 - Name of the variable to store the new option.

Examples:

define_opt_from_proc_task_out "-in" "process_to_be_connected" "process_task_index_to_be_connected" "-out" optlist

The function does not return any value

get_process_num_tasks()

Public: Gets the number of tasks of a process of the program.

  • $1 - Name of the process.

A process whose number of tasks is that of another process, or whose task reads every task of another process, asks for it instead of computing it again. The options of the processes without an option generator are defined before those of the processes with one, so an option generator can ask for the number of tasks of any process, and a process without one only for that of an option generator. When the answer is not known yet, the _generate_opts_size method of the process gives it, so its task shaping options have to be given. The number of tasks is usually read in a command substitution, whose failure has to stop the method that reads it.

Examples:

get_process_num_tasks "producer"

local n
n=$(get_process_num_tasks "worker") || return 1

The function prints the number of tasks of the process, or nothing, returning 1, if it cannot be known.

define_value_desc_opt()

Public: Defines process option storing a value descriptor.

  • $1 - Option name.

  • $2 - Name of variable that will store the information about the option to be added.

The process writes its value with write_value_to_desc. A process that reads it, through an option defined with define_opt_from_proc_out, gets the value itself from read_opt_value_from_func_args, which reads the descriptor on its own.

Examples:

define_value_desc_opt "-o" "optlist"

The function does not return any value

get_absolute_shdirname()

Public: Obtains the absolute path of a shared directory.

  • $1 - Name of the shared directory (as given to define_shared_dir).

Examples:

local abs_shrdir=$(get_absolute_shdirname "data")

The function prints the absolute path of the shared directory to the standard output.

define_opt_from_shared_dir()

Public: Defines process option whose value is the absolute path of a shared directory, or of a shared subdirectory of it.

  • $1 - Option name.

  • $2 - Name of the shared directory (as given to define_shared_dir).

  • $3 - Name of variable that will store the information about the option to be added.

  • $4… - (optional) “–subdir <subpath>” (see debasher::define_opt_from_shared_dir).

Examples:

define_opt_from_shared_dir "-datadir" "data" "optlist"
define_opt_from_shared_dir "-outd" "data" "optlist" --subdir "${task_idx}"

The function does not return any value

save_opt_list()

Public: Saves option list for a given process.

  • $1 - Name of variable storing the option list.

Examples:

save_opt_list optlist

The function does not return any value