Esempio n. 1
0
 def setUp(self):
     super(_AbstractTestInterfaceFortran, self).setUp()
     print "building"
     self.check_can_compile_modules()
     self.exefile=compile_tools.build_fortran_worker(self.get_codestring(),
         self.get_path_to_results(), self.get_interface_class(), needs_mpi= True, 
         extra_fflags = ["-I","{0}/lib/stopcond".format( get_amuse_root_dir())],
         extra_ldflags = ["-L{0}/lib/stopcond".format(get_amuse_root_dir()), "-l"+self.get_libname()] )
Esempio n. 2
0
 def setup_class(cls):
     cls.check_can_compile_modules()
     cls.exefile = compile_tools.build_fortran_worker(
         cls.get_codestring(),
         cls.get_path_to_results(),
         cls.get_interface_class(),
         needs_mpi=True,
         extra_fflags=[
             "-I", "{0}/lib/stopcond".format(get_amuse_root_dir())
         ],
         extra_ldflags=[
             "-L{0}/lib/stopcond".format(get_amuse_root_dir()),
             "-l" + cls.get_libname()
         ])
Esempio n. 3
0
def fortran_compile(objectname, string, extra_args=[]):
    if os.path.exists(objectname):
        os.remove(objectname)

    root, ext = os.path.splitext(objectname)
    sourcename = root + '.f90'

    with open(sourcename, "w") as f:
        f.write(string)

    arguments = get_mpif90_arguments()
    arguments.extend(
        ["-g", "-I{0}/lib/forsockets".format(get_amuse_root_dir())] +
        extra_args + ["-c", "-o", objectname, sourcename])
    arguments.append("-Wall")

    process, stderr, stdout = open_subprocess(arguments)
    process.wait()

    if process.returncode == 0:
        wait_for_file(objectname)

    if process.returncode != 0 or not os.path.exists(objectname):
        raise Exception(
            "Could not compile {0}\nstdout:\n{1}\nstderr:\n{2}\narguments:\n{3}"
            .format(objectname, stdout, stderr, ' '.join(arguments)))
Esempio n. 4
0
def fortran_pythondev_buildso(soname, objectnames):
    if os.path.exists(soname):
        os.remove(soname)
    amuse_root = get_amuse_root_dir()

    arguments = get_mpif90_arguments()
    arguments.extend(objectnames)
    arguments.extend(shlex.split(config.compilers.pythondev_ldflags))
    arguments.append("-shared")
    arguments.append("-o")
    arguments.append(soname)
    arguments.append("-L" + amuse_root + "/lib/amuse_mpi")
    arguments.append("-lamuse_mpi")

    if 'LIBS' in os.environ:
        libs = os.environ['LIBS'].split()
        arguments.extend(libs)

    arguments.extend(get_ld_flags().split())

    process, stderr, stdout = open_subprocess(arguments)

    if process.returncode == 0:
        wait_for_file(soname)

    if process.returncode != 0 or not (os.path.exists(soname)):
        raise Exception(
            "Could not build {0}\nstdout:\n{1}\nstderr:\n{2}\narguments:\n{3}".
            format(soname, stdout, stderr, ' '.join(arguments)))
Esempio n. 5
0
def c_pythondev_compile(objectname, string):
    root, ext = os.path.splitext(objectname)
    sourcename = root + '.c'
    amuse_root = get_amuse_root_dir()
    if os.path.exists(objectname):
        os.remove(objectname)

    with open(sourcename, "w") as f:
        f.write(string)

    mpicc = get_mpicc_name()
    arguments = [mpicc]
    arguments.extend(get_mpicc_flags().split())
    arguments.extend(["-I", numpy.get_include()])

    arguments.extend([
        "-I", amuse_root + "/lib/stopcond", "-I",
        amuse_root + "/lib/amuse_mpi", "-fPIC", "-c", "-o", objectname,
        sourcename
    ])
    arguments.extend(shlex.split(config.compilers.pythondev_cflags))

    process, stderr, stdout = open_subprocess(arguments)

    if process.returncode == 0:
        wait_for_file(objectname)

    if process.returncode != 0 or not os.path.exists(objectname):
        raise Exception(
            "Could not compile {0}\nstdout:\n{1}\nstderr:\n{2}\narguments:\n{3}"
            .format(objectname, stdout, stderr, ' '.join(arguments)))
    def fortran_pythondev_buildso(self, soname, objectnames):

        if os.path.exists(soname):
            os.remove(soname)
        amuse_root = get_amuse_root_dir()

        arguments = self.get_mpif90_arguments()
        arguments.extend(objectnames)
        arguments.extend(shlex.split(config.compilers.pythondev_ldflags))
        arguments.append("-shared")
        arguments.append("-o")
        arguments.append(soname)
        arguments.append("-L" + amuse_root + "/lib/amuse_mpi")
        arguments.append("-lamuse_mpi")

        if "LIBS" in os.environ:
            libs = os.environ["LIBS"].split()
            arguments.extend(libs)

        process = subprocess.Popen(arguments, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        stdout, stderr = process.communicate()

        if process.returncode == 0:
            self.wait_for_file(soname)

        if process.returncode != 0 or not (os.path.exists(soname)):
            print "Could not compile {0}, error = {1}".format(soname, stderr)
            raise Exception("Could not build {0}, error = {1}".format(soname, stderr))

        print stdout
        print stderr
    def fortran_pythondev_buildso(self, soname, objectnames):

        if os.path.exists(soname):
            os.remove(soname)
        amuse_root = get_amuse_root_dir()

        arguments = self.get_mpif90_arguments()
        arguments.extend(objectnames)
        arguments.extend(shlex.split(config.compilers.pythondev_ldflags))
        arguments.append("-shared")
        arguments.append("-o")
        arguments.append(soname)
        arguments.append("-L" + amuse_root + "/lib/amuse_mpi")
        arguments.append("-lamuse_mpi")

        if 'LIBS' in os.environ:
            libs = os.environ['LIBS'].split()
            arguments.extend(libs)

        process = subprocess.Popen(arguments,
                                   stdin=subprocess.PIPE,
                                   stdout=subprocess.PIPE,
                                   stderr=subprocess.PIPE)
        stdout, stderr = process.communicate()

        if process.returncode == 0:
            self.wait_for_file(soname)

        if process.returncode != 0 or not (os.path.exists(soname)):
            print "Could not compile {0}, error = {1}".format(soname, stderr)
            raise Exception("Could not build {0}, error = {1}".format(
                soname, stderr))

        print stdout
        print stderr
    def c_pythondev_compile(self, objectname, string):
        root, ext = os.path.splitext(objectname)
        sourcename = root + '.c'
        amuse_root = get_amuse_root_dir()
        if os.path.exists(objectname):
            os.remove(objectname)

        with open(sourcename, "w") as f:
            f.write(string)

        mpicc = self.get_mpicc_name()
        arguments = [mpicc]
        arguments.extend(self.get_mpicc_flags().split())

        arguments.extend([
            "-I", amuse_root + "/lib/stopcond", "-I",
            amuse_root + "/lib/amuse_mpi", "-fPIC", "-c", "-o", objectname,
            sourcename
        ])
        arguments.extend(shlex.split(config.compilers.pythondev_cflags))

        process = subprocess.Popen(arguments,
                                   stdin=subprocess.PIPE,
                                   stdout=subprocess.PIPE,
                                   stderr=subprocess.PIPE)
        stdout, stderr = process.communicate()

        if process.returncode == 0:
            self.wait_for_file(objectname)

        if process.returncode != 0 or not os.path.exists(objectname):
            print "Could not compile {0}, error = {1}".format(
                objectname, stderr)
            raise Exception("Could not compile {0}, error = {1}".format(
                objectname, stderr))
Esempio n. 9
0
def c_pythondev_compile(objectname, string):
    root, ext = os.path.splitext(objectname)
    sourcename = root + '.c'
    amuse_root = get_amuse_root_dir()
    if os.path.exists(objectname):
        os.remove(objectname)

    with open(sourcename, "w") as f:
        f.write(string)

    mpicc = get_mpicc_name()
    arguments = [mpicc]
    arguments.extend(get_mpicc_flags().split())
    arguments.extend(["-I",numpy.get_include()])

    arguments.extend(["-I", amuse_root + "/lib/stopcond","-I", amuse_root + "/lib/amuse_mpi",  "-fPIC", "-c",  "-o", objectname, sourcename])
    arguments.extend(shlex.split(config.compilers.pythondev_cflags))

    process, stderr, stdout = open_subprocess(arguments)

    if process.returncode == 0:
        wait_for_file(objectname)

    if process.returncode != 0 or not os.path.exists(objectname):
        raise Exception("Could not compile {0}\nstdout:\n{1}\nstderr:\n{2}\narguments:\n{3}".format(objectname, stdout, stderr, ' '.join(arguments)))
Esempio n. 10
0
def fortran_pythondev_buildso(soname, objectnames):
    if os.path.exists(soname):
        os.remove(soname)
    amuse_root = get_amuse_root_dir()

    arguments = get_mpif90_arguments()
    arguments.extend(objectnames)
    arguments.extend(shlex.split(config.compilers.pythondev_ldflags))
    arguments.append("-shared")
    arguments.append("-o")
    arguments.append(soname)
    arguments.append("-L"+amuse_root+"/lib/amuse_mpi")
    arguments.append("-lamuse_mpi")

    if 'LIBS' in os.environ:
        libs = os.environ['LIBS'].split()
        arguments.extend(libs)

    arguments.extend(get_ld_flags().split())

    process, stderr, stdout = open_subprocess(arguments)

    if process.returncode == 0:
        wait_for_file(soname)

    if process.returncode != 0 or not (os.path.exists(soname)):
        raise Exception("Could not build {0}\nstdout:\n{1}\nstderr:\n{2}\narguments:\n{3}".format(soname, stdout, stderr, ' '.join(arguments)))
Esempio n. 11
0
 def setup_class(cls):
     cls.check_can_compile_modules()
     cls.exefile=compile_tools.build_worker(codestring, 
         cls.get_path_to_results(), 
         cls.get_interface_class(), write_header=False, 
         extra_args=["-L"+get_amuse_root_dir()+"/lib/stopcond", "-l" + cls.get_libname()]
         )
Esempio n. 12
0
def fortran_build(exename, objectnames, extra_args=[]):
    if os.path.exists(exename):
        os.remove(exename)

    arguments = get_mpif90_arguments()
    arguments.extend(objectnames)

    arguments.append("-L{0}/lib/forsockets".format(get_amuse_root_dir()))
    arguments.append("-Wall")
    arguments.append("-lforsockets")
    arguments.extend(extra_args)

    arguments.append("-o")
    arguments.append(exename)

    arguments.extend(get_ld_flags().split())

    process, stderr, stdout = open_subprocess(arguments)

    if process.returncode == 0:
        wait_for_file(exename)

    if process.returncode != 0 or not os.path.exists(exename):
        raise Exception(
            "Could not build {0}\nstdout:\n{1}\nstderr:\n{2}\narguments:\n{3}".
            format(exename, stdout, stderr, ' '.join(arguments)))
Esempio n. 13
0
 def setUp(self):
     super(_AbstractTestInterface, self).setUp()
     print "building"
     self.check_can_compile_modules()
     self.exefile=compile_tools.build_worker(codestring, 
         self.get_path_to_results(), 
         self.get_interface_class(), write_header=False, 
         extra_args=["-L"+get_amuse_root_dir()+"/lib/stopcond", "-l" + self.get_libname()]
         )
 def setUp(self):
     super(_AbstractTestInterface, self).setUp()
     print "building"
     self.check_can_compile_modules()
     self.exefile=compile_tools.build_worker(codestring, 
         self.get_path_to_results(), 
         self.get_interface_class(), write_header=False, 
         extra_args=["-L"+get_amuse_root_dir()+"/lib/stopcond", "-l" + self.get_libname()]
         )
Esempio n. 15
0
def f90_compile(objectname, string, mpidir):
    root, ext = os.path.splitext(objectname)
    sourcename = root + '.f90'
    if os.path.exists(objectname):
        os.remove(objectname)
    with open(sourcename, "w") as f:
        f.write(string)

    rootdir = get_amuse_root_dir()
    arguments = get_mpif90_arguments()
    arguments.extend(["-I", "{0}/lib/stopcond".format(rootdir, mpidir), "-I", rootdir + "/lib/forsockets", "-c",  "-o", objectname, sourcename])
    process, stderr, stdout = open_subprocess(arguments)
    if not os.path.exists(objectname):  # or process.poll() == 1:
        raise Exception("Could not compile {0}\nstdout:\n{1}\nstderr:\n{2}\narguments:\n{3}".format(objectname, stdout, stderr, ' '.join(arguments)))
Esempio n. 16
0
def f90_build(exename, objectnames, libname):
    rootdir = get_amuse_root_dir()

    arguments = get_mpif90_arguments()
    arguments.extend(objectnames)
    arguments.append("-o")
    arguments.append(exename)
    arguments.extend(["-L{0}/lib/stopcond".format(rootdir), "-l"+libname])
    arguments.extend(["-L" + rootdir + "/lib/forsockets","-lforsockets"])
    arguments.extend(get_ld_flags().split())
    print 'build command:'
    print ' '.join(arguments)
    process, stderr, stdout = open_subprocess(arguments)
    if process.returncode != 0:
        raise Exception("Could not build {0}\nstdout:\n{1}\nstderr:\n{2}\narguments:\n{3}".format(exename, stdout, stderr, ' '.join(arguments)))
Esempio n. 17
0
def f90_build(exename, objectnames, libname):
    rootdir = get_amuse_root_dir()

    arguments = get_mpif90_arguments()
    arguments.extend(objectnames)
    arguments.append("-o")
    arguments.append(exename)
    arguments.extend(["-L{0}/lib/stopcond".format(rootdir), "-l" + libname])
    arguments.extend(["-L" + rootdir + "/lib/forsockets", "-lforsockets"])
    arguments.extend(get_ld_flags().split())
    print 'build command:'
    print ' '.join(arguments)
    process, stderr, stdout = open_subprocess(arguments)
    if process.returncode != 0:
        raise Exception(
            "Could not build {0}\nstdout:\n{1}\nstderr:\n{2}\narguments:\n{3}".
            format(exename, stdout, stderr, ' '.join(arguments)))
Esempio n. 18
0
def cxx_compile(objectname, string, extra_args=[]):
    if os.path.exists(objectname):
        os.remove(objectname)

    mpicxx = get_mpicxx_name()
    arguments = [mpicxx]
    arguments.extend(get_mpicxx_flags().split())
    rootdir = get_amuse_root_dir()
    arguments.extend(["-I", rootdir + "/lib/stopcond", "-x", "c++", "-c"]
                     + extra_args + ["-o", objectname, "-"])

    process, stderr, stdout = open_subprocess(arguments, stdin=string)

    if process.returncode == 0:
        wait_for_file(objectname)

    if process.returncode != 0 or not os.path.exists(objectname):
        raise Exception("Could not compile {0}\nstdout:\n{1}\nstderr:\n{2}\narguments:\n{3}".format(objectname, stdout, stderr, ' '.join(arguments)))
Esempio n. 19
0
def cxx_compile(objectname, string, extra_args=[]):
    if os.path.exists(objectname):
        os.remove(objectname)

    mpicxx = get_mpicxx_name()
    arguments = [mpicxx]
    arguments.extend(get_mpicxx_flags().split())
    rootdir = get_amuse_root_dir()
    arguments.extend(["-I", rootdir + "/lib/stopcond", "-x", "c++", "-c"]
                     + extra_args + ["-o", objectname, "-"])

    process, stderr, stdout = open_subprocess(arguments, stdin=string)

    if process.returncode == 0:
        wait_for_file(objectname)

    if process.returncode != 0 or not os.path.exists(objectname):
        raise Exception("Could not compile {0}\nstdout:\n{1}\nstderr:\n{2}\narguments:\n{3}".format(objectname, stdout, stderr, ' '.join(arguments)))
Esempio n. 20
0
def f90_compile(objectname, string, mpidir):
    root, ext = os.path.splitext(objectname)
    sourcename = root + '.f90'
    if os.path.exists(objectname):
        os.remove(objectname)
    with open(sourcename, "w") as f:
        f.write(string)

    rootdir = get_amuse_root_dir()
    arguments = get_mpif90_arguments()
    arguments.extend([
        "-I", "{0}/lib/stopcond".format(rootdir, mpidir), "-I",
        rootdir + "/lib/forsockets", "-c", "-o", objectname, sourcename
    ])
    process, stderr, stdout = open_subprocess(arguments)
    if not os.path.exists(objectname):  # or process.poll() == 1:
        raise Exception(
            "Could not compile {0}\nstdout:\n{1}\nstderr:\n{2}\narguments:\n{3}"
            .format(objectname, stdout, stderr, ' '.join(arguments)))
Esempio n. 21
0
    def c_pythondev_compile(self, objectname, string):
        root, ext = os.path.splitext(objectname)
        sourcename = root + ".c"
        amuse_root = get_amuse_root_dir()
        if os.path.exists(objectname):
            os.remove(objectname)

        with open(sourcename, "w") as f:
            f.write(string)

        mpicc = self.get_mpicc_name()
        arguments = [mpicc]
        arguments.extend(self.get_mpicc_flags().split())

        arguments.extend(
            [
                "-I",
                amuse_root + "/lib/stopcond",
                "-I",
                amuse_root + "/lib/amuse_mpi",
                "-fPIC",
                "-c",
                "-o",
                objectname,
                sourcename,
            ]
        )
        arguments.extend(shlex.split(config.compilers.pythondev_cflags))

        process = subprocess.Popen(arguments, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        stdout, stderr = process.communicate()

        if process.returncode == 0:
            self.wait_for_file(objectname)

        if process.returncode != 0 or not os.path.exists(objectname):
            print "Could not compile {0}, error = {1}".format(objectname, stderr)
            raise Exception("Could not compile {0}, error = {1}".format(objectname, stderr))
Esempio n. 22
0
def fortran_build(exename, objectnames):
    if os.path.exists(exename):
        os.remove(exename)

    arguments = get_mpif90_arguments()
    arguments.extend(objectnames)

    arguments.append("-L{0}/lib/forsockets".format(get_amuse_root_dir()))
    arguments.append("-Wall")
    arguments.append("-lforsockets")

    arguments.append("-o")
    arguments.append(exename)

    arguments.extend(get_ld_flags().split())

    process, stderr, stdout = open_subprocess(arguments)

    if process.returncode == 0:
        wait_for_file(exename)

    if process.returncode != 0 or not os.path.exists(exename):
        raise Exception("Could not build {0}\nstdout:\n{1}\nstderr:\n{2}\narguments:\n{3}".format(exename, stdout, stderr, ' '.join(arguments)))
Esempio n. 23
0
def fortran_compile(objectname, string, extra_args=[]):
    if os.path.exists(objectname):
        os.remove(objectname)

    root, ext = os.path.splitext(objectname)
    sourcename = root + '.f90'

    with open(sourcename, "w") as f:
        f.write(string)

    arguments = get_mpif90_arguments()
    arguments.extend(["-g",
                     "-I{0}/lib/forsockets".format(get_amuse_root_dir())]
                     + extra_args + ["-c",  "-o", objectname, sourcename])
    arguments.append("-Wall")

    process, stderr, stdout = open_subprocess(arguments)
    process.wait()

    if process.returncode == 0:
        wait_for_file(objectname)

    if process.returncode != 0 or not os.path.exists(objectname):
        raise Exception("Could not compile {0}\nstdout:\n{1}\nstderr:\n{2}\narguments:\n{3}".format(objectname, stdout, stderr, ' '.join(arguments)))