# zmq

Definition of ZeroMQ sockets and messages.

## Providers

`is_zmq_slave`

  File : `zmq/utils.irp.f`

      logical :: is_zmq_slave

  If `true`, the current process is a ZeroMQ slave.

`qp_run_address`

  File : `zmq/utils.irp.f`

      character*(128) :: qp_run_address
      integer :: zmq_port_start

  Address of the qp_run socket Example : tcp://130.120.229.139:12345

  Needed by:

  `zmq_socket_pull_tcp_address` |  |

`zmq_context`

  File : `zmq/utils.irp.f`

      integer(ZMQ_PTR)        :: zmq_context
      integer(omp_lock_kind)  :: zmq_lock

  Context for the ZeroMQ library

  Needed by:

  `ao_two_e_integrals_erf_in_map` | `ao_two_e_integrals_in_map` |

`zmq_lock`

  File : `zmq/utils.irp.f`

      integer(ZMQ_PTR)        :: zmq_context
      integer(omp_lock_kind)  :: zmq_lock

  Context for the ZeroMQ library

  Needed by:

  `ao_two_e_integrals_erf_in_map` | `ao_two_e_integrals_in_map` |

`zmq_port_start`

  File : `zmq/utils.irp.f`

      character*(128) :: qp_run_address
      integer :: zmq_port_start

  Address of the qp_run socket Example : tcp://130.120.229.139:12345

  Needed by:

  `zmq_socket_pull_tcp_address` |  |

`zmq_socket_pair_inproc_address`

  File : `zmq/utils.irp.f`

      character*(128) :: zmq_socket_pull_tcp_address
      character*(128) :: zmq_socket_pair_inproc_address
      character*(128) :: zmq_socket_push_tcp_address
      character*(128) :: zmq_socket_pull_inproc_address
      character*(128) :: zmq_socket_push_inproc_address
      character*(128) :: zmq_socket_sub_tcp_address

  Socket which pulls the results (2)

  Needs:

  `qp_run_address` |  |

  Needed by:

  `ao_two_e_integrals_erf_in_map` | `ao_two_e_integrals_in_map` |

`zmq_socket_pull_inproc_address`

  File : `zmq/utils.irp.f`

      character*(128) :: zmq_socket_pull_tcp_address
      character*(128) :: zmq_socket_pair_inproc_address
      character*(128) :: zmq_socket_push_tcp_address
      character*(128) :: zmq_socket_pull_inproc_address
      character*(128) :: zmq_socket_push_inproc_address
      character*(128) :: zmq_socket_sub_tcp_address

  Socket which pulls the results (2)

  Needs:

  `qp_run_address` |  |

  Needed by:

  `ao_two_e_integrals_erf_in_map` | `ao_two_e_integrals_in_map` |

`zmq_socket_pull_tcp_address`

  File : `zmq/utils.irp.f`

      character*(128) :: zmq_socket_pull_tcp_address
      character*(128) :: zmq_socket_pair_inproc_address
      character*(128) :: zmq_socket_push_tcp_address
      character*(128) :: zmq_socket_pull_inproc_address
      character*(128) :: zmq_socket_push_inproc_address
      character*(128) :: zmq_socket_sub_tcp_address

  Socket which pulls the results (2)

  Needs:

  `qp_run_address` |  |

  Needed by:

  `ao_two_e_integrals_erf_in_map` | `ao_two_e_integrals_in_map` |

`zmq_socket_push_inproc_address`

  File : `zmq/utils.irp.f`

      character*(128) :: zmq_socket_pull_tcp_address
      character*(128) :: zmq_socket_pair_inproc_address
      character*(128) :: zmq_socket_push_tcp_address
      character*(128) :: zmq_socket_pull_inproc_address
      character*(128) :: zmq_socket_push_inproc_address
      character*(128) :: zmq_socket_sub_tcp_address

  Socket which pulls the results (2)

  Needs:

  `qp_run_address` |  |

  Needed by:

  `ao_two_e_integrals_erf_in_map` | `ao_two_e_integrals_in_map` |

`zmq_socket_push_tcp_address`

  File : `zmq/utils.irp.f`

      character*(128) :: zmq_socket_pull_tcp_address
      character*(128) :: zmq_socket_pair_inproc_address
      character*(128) :: zmq_socket_push_tcp_address
      character*(128) :: zmq_socket_pull_inproc_address
      character*(128) :: zmq_socket_push_inproc_address
      character*(128) :: zmq_socket_sub_tcp_address

  Socket which pulls the results (2)

  Needs:

  `qp_run_address` |  |

  Needed by:

  `ao_two_e_integrals_erf_in_map` | `ao_two_e_integrals_in_map` |

`zmq_socket_sub_tcp_address`

  File : `zmq/utils.irp.f`

      character*(128) :: zmq_socket_pull_tcp_address
      character*(128) :: zmq_socket_pair_inproc_address
      character*(128) :: zmq_socket_push_tcp_address
      character*(128) :: zmq_socket_pull_inproc_address
      character*(128) :: zmq_socket_push_inproc_address
      character*(128) :: zmq_socket_sub_tcp_address

  Socket which pulls the results (2)

  Needs:

  `qp_run_address` |  |

  Needed by:

  `ao_two_e_integrals_erf_in_map` | `ao_two_e_integrals_in_map` |

`zmq_state`

  File : `zmq/utils.irp.f`

      character*(128) :: zmq_state

  Threads executing work through the ZeroMQ interface

  Needed by:

  `ao_two_e_integrals_erf_in_map` | `ao_two_e_integrals_in_map` |

## Subroutines / functions

`add_task_to_taskserver:`()

  File : `zmq/utils.irp.f`

      integer function add_task_to_taskserver(zmq_to_qp_run_socket,task)

  Get a task from the task server

  Needs:

  `zmq_state` |  |

`connect_to_taskserver:`()

  File : `zmq/utils.irp.f`

      integer function connect_to_taskserver(zmq_to_qp_run_socket,worker_id,thread)

  Connect to the task server and obtain the worker ID

  Needs:

  `zmq_state` |  |

`disconnect_from_taskserver:`()

  File : `zmq/utils.irp.f`

      integer function disconnect_from_taskserver(zmq_to_qp_run_socket, worker_id)

  Disconnect from the task server

  Needs:

  `zmq_state` |  |

`disconnect_from_taskserver_state:`()

  File : `zmq/utils.irp.f`

      integer function disconnect_from_taskserver_state(zmq_to_qp_run_socket, worker_id, state)

  Disconnect from the task server

  Needs:

  `zmq_state` |  |

`end_parallel_job:`()

  File : `zmq/utils.irp.f`

      subroutine end_parallel_job(zmq_to_qp_run_socket,zmq_socket_pull,name_in)

  End a new parallel job with name ‘name’. The slave tasks execute subroutine ‘slave’

  Needs:

  `zmq_state` | `zmq_context` |

  Called by:

  `ao_two_e_integrals_erf_in_map` `ao_two_e_integrals_in_map` | `h_s2_u_0_nstates_zmq()` `zmq_pt2()` | `zmq_selection()`

  Calls:

  `end_zmq_pull_socket()` `end_zmq_to_qp_run_socket()` | `lowercase()` `omp_set_lock()` | `omp_unset_lock()` `sleep()`

`end_zmq_pair_socket:`()

  File : `zmq/utils.irp.f`

      subroutine end_zmq_pair_socket(zmq_socket_pair)

  Terminate socket on which the results are sent.

  Needs:

  `zmq_context` |  |

  Calls:

  `omp_set_lock()` | `omp_unset_lock()` |

`end_zmq_pull_socket:`()

  File : `zmq/utils.irp.f`

      subroutine end_zmq_pull_socket(zmq_socket_pull)

  Terminate socket on which the results are sent.

  Needs:

  `zmq_context` |  |

  Called by:

  `end_parallel_job()` |  |

  Calls:

  `omp_set_lock()` | `omp_unset_lock()` |

`end_zmq_push_socket:`()

  File : `zmq/utils.irp.f`

      subroutine end_zmq_push_socket(zmq_socket_push,thread)

  Terminate socket on which the results are sent.

  Needs:

  `zmq_context` |  |

  Called by:

  `ao_two_e_integrals_erf_in_map_slave()` `ao_two_e_integrals_in_map_slave()` | `davidson_run_slave()` `run_pt2_slave()` | `run_selection_slave()`

  Calls:

  `omp_set_lock()` | `omp_unset_lock()` |

`end_zmq_sub_socket:`()

  File : `zmq/utils.irp.f`

      subroutine end_zmq_sub_socket(zmq_socket_sub)

  Terminate socket on which the results are sent.

  Needs:

  `zmq_context` |  |

  Called by:

  `wait_for_next_state()` | `wait_for_state()` | `wait_for_states()`

  Calls:

  `omp_set_lock()` | `omp_unset_lock()` |

`end_zmq_to_qp_run_socket:`()

  File : `zmq/utils.irp.f`

      subroutine end_zmq_to_qp_run_socket(zmq_to_qp_run_socket)

  Terminate the socket from the application to qp_run

  Called by:

  `ao_two_e_integrals_erf_in_map_collector()` `ao_two_e_integrals_erf_in_map_slave()` `ao_two_e_integrals_in_map_collector()` `ao_two_e_integrals_in_map_slave()` | `davidson_run_slave()` `end_parallel_job()` `pt2_collector()` | `run_pt2_slave()` `run_selection_slave()` `selection_collector()`

`get_task_from_taskserver:`()

  File : `zmq/utils.irp.f`

      integer function get_task_from_taskserver(zmq_to_qp_run_socket,worker_id,task_id,task)

  Get a task from the task server

  Needs:

  `zmq_state` |  |

`get_tasks_from_taskserver:`()

  File : `zmq/utils.irp.f`

      integer function get_tasks_from_taskserver(zmq_to_qp_run_socket,worker_id,task_id,task,n_tasks)

  Get multiple tasks from the task server

  Needs:

  `zmq_state` |  |

`new_parallel_job:`()

  File : `zmq/utils.irp.f`

      subroutine new_parallel_job(zmq_to_qp_run_socket,zmq_socket_pull,name_in)

  Start a new parallel job with name ‘name’. The slave tasks execute subroutine ‘slave’

  Needs:

  `zmq_state` | `zmq_socket_pull_tcp_address` | `zmq_context`

  Called by:

  `ao_two_e_integrals_erf_in_map` `ao_two_e_integrals_in_map` | `h_s2_u_0_nstates_zmq()` `zmq_pt2()` | `zmq_selection()`

  Calls:

  `lowercase()` | `omp_set_lock()` | `omp_unset_lock()`

`new_zmq_pair_socket:`()

  File : `zmq/utils.irp.f`

      function new_zmq_pair_socket(bind)

  Socket on which the collector and the main communicate

  Needs:

  `zmq_socket_pull_tcp_address` | `zmq_context` |

  Calls:

  `omp_set_lock()` | `omp_unset_lock()` |

`new_zmq_pull_socket:`()

  File : `zmq/utils.irp.f`

      function new_zmq_pull_socket()

  Socket on which the results are sent. If thread is 1, use inproc

  Needs:

  `qp_run_address` | `zmq_socket_pull_tcp_address` | `zmq_context`

  Calls:

  `omp_set_lock()` | `omp_unset_lock()` | `sleep()`

`new_zmq_push_socket:`()

  File : `zmq/utils.irp.f`

      function new_zmq_push_socket(thread)

  Socket on which the results are sent. If thread is 1, use inproc

  Needs:

  `zmq_socket_pull_tcp_address` | `zmq_context` |

  Calls:

  `omp_set_lock()` | `omp_unset_lock()` |

`new_zmq_sub_socket:`()

  File : `zmq/utils.irp.f`

      function new_zmq_sub_socket()

  Socket to read the state published by the Task server

  Needs:

  `zmq_socket_pull_tcp_address` | `zmq_context` |

  Calls:

  `omp_set_lock()` | `omp_unset_lock()` |

`new_zmq_to_qp_run_socket:`()

  File : `zmq/utils.irp.f`

      function new_zmq_to_qp_run_socket()

  Socket on which the qp_run process replies

  Needs:

  `qp_run_address` | `zmq_context` |

  Calls:

  `omp_set_lock()` | `omp_unset_lock()` |

`reset_zmq_addresses:`()

  File : `zmq/utils.irp.f`

      subroutine reset_zmq_addresses

  Socket which pulls the results (2)

  Needs:

  `qp_run_address` | `zmq_socket_pull_tcp_address` |

  Called by:

  `switch_qp_run_to_master()` |  |

`switch_qp_run_to_master:`()

  File : `zmq/utils.irp.f`

      subroutine switch_qp_run_to_master

  Address of the master qp_run socket Example : tcp://130.120.229.139:12345

  Needs:

  `is_zmq_slave` | `qp_run_address` |

  Called by:

  `run_slave_cipsi()` |  |

  Calls:

  `getenv()` | `reset_zmq_addresses()` |

`task_done_to_taskserver:`()

  File : `zmq/utils.irp.f`

      integer function task_done_to_taskserver(zmq_to_qp_run_socket, worker_id, task_id)

  Get a task from the task server

  Needs:

  `zmq_state` |  |

`tasks_done_to_taskserver:`()

  File : `zmq/utils.irp.f`

      integer function tasks_done_to_taskserver(zmq_to_qp_run_socket, worker_id, task_id, n_tasks)

  Get a task from the task server

  Needs:

  `zmq_state` |  |

`wait_for_next_state:`()

  File : `zmq/utils.irp.f`

      subroutine wait_for_next_state(state)

  Calls:

  `end_zmq_sub_socket()` |  |

`wait_for_state:`()

  File : `zmq/utils.irp.f`

      subroutine wait_for_state(state_wait,state)

  Wait for the ZMQ state to be ready

  Calls:

  `end_zmq_sub_socket()` |  |

`wait_for_states:`()

  File : `zmq/utils.irp.f`

      subroutine wait_for_states(state_wait,state,n)

  Wait for the ZMQ state to be ready

  Called by:

  `run_slave_main()` |  |

  Calls:

  `end_zmq_sub_socket()` |  |

`zmq_abort:`()

  File : `zmq/utils.irp.f`

      integer function zmq_abort(zmq_to_qp_run_socket)

  Aborts a running parallel computation

  Calls:

  `sleep()` |  |

`zmq_delete_task:`()

  File : `zmq/utils.irp.f`

      integer function zmq_delete_task(zmq_to_qp_run_socket,zmq_socket_pull,task_id,more)

  When a task is done, it has to be removed from the list of tasks on the qp_run queue. This guarantees that the results have been received in the pull.

  Needs:

  `zmq_state` |  |

`zmq_delete_tasks:`()

  File : `zmq/utils.irp.f`

      integer function zmq_delete_tasks(zmq_to_qp_run_socket,zmq_socket_pull,task_id,n_tasks,more)

  When a task is done, it has to be removed from the list of tasks on the qp_run queue. This guarantees that the results have been received in the pull.

  Needs:

  `zmq_state` |  |

`zmq_delete_tasks_async_recv:`()

  File : `zmq/utils.irp.f`

      integer function zmq_delete_tasks_async_recv(zmq_to_qp_run_socket,zmq_socket_pull,task_id,n_tasks,more)

  When a task is done, it has to be removed from the list of tasks on the qp_run queue. This guarantees that the results have been received in the pull.

`zmq_delete_tasks_async_send:`()

  File : `zmq/utils.irp.f`

      integer function zmq_delete_tasks_async_send(zmq_to_qp_run_socket,zmq_socket_pull,task_id,n_tasks,more)

  When a task is done, it has to be removed from the list of tasks on the qp_run queue. This guarantees that the results have been received in the pull.

  Needs:

  `zmq_state` |  |

`zmq_get8_dvector:`()

  File : `zmq/put_get.irp.f`

      integer function zmq_get8_dvector(zmq_to_qp_run_socket, worker_id, name, x, size_x)

  Get a float vector from the qp_run scheduler

  Needs:

  `zmq_state` | `mpi_master` |

`zmq_get8_ivector:`()

  File : `zmq/put_get.irp.f`

      integer function zmq_get8_ivector(zmq_to_qp_run_socket, worker_id, name, x, size_x)

  Get a vector of integers from the qp_run scheduler

  Needs:

  `zmq_state` | `mpi_master` |

`zmq_get_dmatrix:`()

  File : `zmq/put_get.irp.f`

      integer function zmq_get_dmatrix(zmq_to_qp_run_socket, worker_id, name, x, size_x1, size_x2, sze)

  Get a float vector from the qp_run scheduler

  Needs:

  `zmq_state` | `mpi_master` |

`zmq_get_dvector:`()

  File : `zmq/put_get.irp.f`

      integer function zmq_get_dvector(zmq_to_qp_run_socket, worker_id, name, x, size_x)

  Get a float vector from the qp_run scheduler

  Needs:

  `zmq_state` | `mpi_master` |

`zmq_get_i8matrix:`()

  File : `zmq/put_get.irp.f`

      integer function zmq_get_i8matrix(zmq_to_qp_run_socket, worker_id, name, x, size_x1, size_x2, sze)

  Get a float vector from the qp_run scheduler

  Needs:

  `zmq_state` | `mpi_master` |

`zmq_get_imatrix:`()

  File : `zmq/put_get.irp.f`

      integer function zmq_get_imatrix(zmq_to_qp_run_socket, worker_id, name, x, size_x1, size_x2, sze)

  Get a float vector from the qp_run scheduler

  Needs:

  `zmq_state` | `mpi_master` |

`zmq_get_int:`()

  File : `zmq/put_get.irp.f`

      integer function zmq_get_int(zmq_to_qp_run_socket, worker_id, name, x)

  Get a vector of integers from the qp_run scheduler

  Needs:

  `zmq_state` | `mpi_master` |

`zmq_get_int_nompi:`()

  File : `zmq/put_get.irp.f`

      integer function zmq_get_int_nompi(zmq_to_qp_run_socket, worker_id, name, x)

  Get a vector of integers from the qp_run scheduler

  Needs:

  `zmq_state` |  |

`zmq_get_ivector:`()

  File : `zmq/put_get.irp.f`

      integer function zmq_get_ivector(zmq_to_qp_run_socket, worker_id, name, x, size_x)

  Get a vector of integers from the qp_run scheduler

  Needs:

  `zmq_state` | `mpi_master` |

`zmq_port:`()

  File : `zmq/utils.irp.f`

      function zmq_port(ishift)

  Return the value of the ZMQ port from the corresponding integer

  Needs:

  `qp_run_address` |  |

`zmq_put8_dvector:`()

  File : `zmq/put_get.irp.f`

      integer function zmq_put8_dvector(zmq_to_qp_run_socket, worker_id, name, x, size_x)

  Put a float vector on the qp_run scheduler

  Needs:

  `zmq_state` |  |

`zmq_put8_ivector:`()

  File : `zmq/put_get.irp.f`

      integer function zmq_put8_ivector(zmq_to_qp_run_socket, worker_id, name, x, size_x)

  Put a vector of integers on the qp_run scheduler

  Needs:

  `zmq_state` |  |

`zmq_put_dmatrix:`()

  File : `zmq/put_get.irp.f`

      integer function zmq_put_dmatrix(zmq_to_qp_run_socket, worker_id, name, x, size_x1, size_x2, sze)

  Put a float vector on the qp_run scheduler

  Needs:

  `zmq_state` |  |

`zmq_put_dvector:`()

  File : `zmq/put_get.irp.f`

      integer function zmq_put_dvector(zmq_to_qp_run_socket, worker_id, name, x, size_x)

  Put a float vector on the qp_run scheduler

  Needs:

  `zmq_state` |  |

`zmq_put_i8matrix:`()

  File : `zmq/put_get.irp.f`

      integer function zmq_put_i8matrix(zmq_to_qp_run_socket, worker_id, name, x, size_x1, size_x2, sze)

  Put a float vector on the qp_run scheduler

  Needs:

  `zmq_state` |  |

`zmq_put_imatrix:`()

  File : `zmq/put_get.irp.f`

      integer function zmq_put_imatrix(zmq_to_qp_run_socket, worker_id, name, x, size_x1, size_x2, sze)

  Put a float vector on the qp_run scheduler

  Needs:

  `zmq_state` |  |

`zmq_put_int:`()

  File : `zmq/put_get.irp.f`

      integer function zmq_put_int(zmq_to_qp_run_socket, worker_id, name, x)

  Put a vector of integers on the qp_run scheduler

  Needs:

  `zmq_state` |  |

`zmq_put_ivector:`()

  File : `zmq/put_get.irp.f`

      integer function zmq_put_ivector(zmq_to_qp_run_socket, worker_id, name, x, size_x)

  Put a vector of integers on the qp_run scheduler

  Needs:

  `zmq_state` |  |

`zmq_set_running:`()

  File : `zmq/utils.irp.f`

      integer function zmq_set_running(zmq_to_qp_run_socket)

  Set the job to Running in QP-run