#!/usr/bin/python
#This script was generated by the AMUSE framework
import sys
import os

from mpi4py import rc
rc.initialize = False
from mpi4py import MPI


if __name__ == '__main__':

    if len(sys.argv) > 1:

        portnumber = int(sys.argv[1])
        host = sys.argv[2]
        usempi= sys.argv[3]

        if usempi=="true":
            MPI.Init()

        try:
            syspath = ('/home/niels/workspace/amuse/sandbox/ndrost/remote_simple','/home/niels/.local/lib/python2.7/site-packages/Sphinx-1.3a0dev_20140313-py2.7.egg','/home/niels/.local/lib/python2.7/site-packages/snowballstemmer-1.1.0-py2.7.egg','/home/niels/.local/lib/python2.7/site-packages/docutils-0.11-py2.7.egg','/usr/local/lib/python2.7/dist-packages/docopt-0.6.1-py2.7.egg','/home/niels/workspace/amuse/sandbox/ndrost/remote_simple','/home/niels/workspace/amuse/test','/home/niels/workspace/amuse/src','/home/niels/workspace/opencl-pcraster/python','/usr/lib/python2.7','/usr/lib/python2.7/plat-linux2','/usr/lib/python2.7/lib-tk','/usr/lib/python2.7/lib-old','/usr/lib/python2.7/lib-dynload','/home/niels/.local/lib/python2.7/site-packages','/usr/local/lib/python2.7/dist-packages','/usr/lib/python2.7/dist-packages','/usr/lib/python2.7/dist-packages/PIL','/usr/lib/python2.7/dist-packages/gst-0.10','/usr/lib/python2.7/dist-packages/gtk-2.0','/usr/lib/pymodules/python2.7')
            existing_syspath = set(sys.path)
            for x in syspath:
                if not x in existing_syspath:
                      sys.path.append(x)
    
            from amuse.rfi import core
    
            from simple import simpleImplementation
            from simple import simpleInterface
    
            instance = simpleImplementation()
    
            from amuse.rfi.python_code import PythonImplementation
    
            x = PythonImplementation(instance, simpleInterface)
    
            x.start_socket(portnumber, host)
        finally:  
            if usempi:
                MPI.Finalize()

    else:

        MPI.Init()

        try:
            syspath = ('/home/niels/workspace/amuse/sandbox/ndrost/remote_simple','/home/niels/.local/lib/python2.7/site-packages/Sphinx-1.3a0dev_20140313-py2.7.egg','/home/niels/.local/lib/python2.7/site-packages/snowballstemmer-1.1.0-py2.7.egg','/home/niels/.local/lib/python2.7/site-packages/docutils-0.11-py2.7.egg','/usr/local/lib/python2.7/dist-packages/docopt-0.6.1-py2.7.egg','/home/niels/workspace/amuse/sandbox/ndrost/remote_simple','/home/niels/workspace/amuse/test','/home/niels/workspace/amuse/src','/home/niels/workspace/opencl-pcraster/python','/usr/lib/python2.7','/usr/lib/python2.7/plat-linux2','/usr/lib/python2.7/lib-tk','/usr/lib/python2.7/lib-old','/usr/lib/python2.7/lib-dynload','/home/niels/.local/lib/python2.7/site-packages','/usr/local/lib/python2.7/dist-packages','/usr/lib/python2.7/dist-packages','/usr/lib/python2.7/dist-packages/PIL','/usr/lib/python2.7/dist-packages/gst-0.10','/usr/lib/python2.7/dist-packages/gtk-2.0','/usr/lib/pymodules/python2.7')
            existing_syspath = set(sys.path)
            for x in syspath:
                if not x in existing_syspath:
                    sys.path.append(x)

            from amuse.rfi import core

            from simple import simpleImplementation
            from simple import simpleInterface

            instance = simpleImplementation()

            from amuse.rfi.python_code import PythonImplementation

            x = PythonImplementation(instance, simpleInterface)
            x.start()
        finally:
            MPI.Finalize()
