{
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "%matplotlib inline"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n# Music example receiver script\n\nPlease note that MUSIC and the recording backend for Arbor are mutually exclusive\nand cannot be enabled at the same time.\n\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "import sys\nimport music\nimport numpy\nfrom itertools import takewhile, dropwhile\n\nsetup = music.Setup()\nstoptime = setup.config(\"stoptime\")\ntimestep = setup.config(\"timestep\")\n\ncomm = setup.comm\nrank = comm.Get_rank()\n\npin = setup.publishContInput(\"in\")\ndata = numpy.array([0.0, 0.0], dtype=numpy.double)\npin.map(data, interpolate=False)\n\nruntime = setup.runtime(timestep)\nmintime = timestep\nmaxtime = stoptime+timestep\nstart = dropwhile(lambda t: t < mintime, runtime)\ntimes = takewhile(lambda t: t < maxtime, start)\nfor time in times:\n    val = data\n    sys.stdout.write(\n        \"t={}\\treceiver {}: received {}\\n\".\n        format(time, rank, val))"
      ]
    }
  ],
  "metadata": {
    "kernelspec": {
      "display_name": "Python 3",
      "language": "python",
      "name": "python3"
    },
    "language_info": {
      "codemirror_mode": {
        "name": "ipython",
        "version": 3
      },
      "file_extension": ".py",
      "mimetype": "text/x-python",
      "name": "python",
      "nbconvert_exporter": "python",
      "pygments_lexer": "ipython3",
      "version": "3.6.12"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}