コード例 #1
0
    def _run_spawn(self):

        LogMgr.info("_run_spawn() [Pickling Sim]")
        (bundle, resfilename) = MetaDataBundleBuilder.build_std_pickler(self)
        (_bundlefname, sim_cmd) = bundle.write_to_file_and_get_exec_string()

        # if Exists(resfilename):
        #    os.unlink(resfilename)

        if not os.path.exists(resfilename):

            # Setup the LD_LIBRARY PATH:
            # It may be nessesary to add the following to .mfrc
            # ld_library_path_suffix = /home/michael/hw/morphforge/src/morphforgecontrib/neuron_gsl/cpp
            ld_path_additions = RCMgr.get("Neuron", "ld_library_path_suffix").split(":")
            old_ld_path = os.environ.get("LD_LIBRARY_PATH", "")
            os.environ["LD_LIBRARY_PATH"] = ":".join([old_ld_path] + ld_path_additions)

            LogMgr.info("_run_spawn() [Spawning subprocess]")
            ret_code = subprocess.call(sim_cmd, shell=True)
            if ret_code != 1:
                raise ValueError("Unable to simulate %s" % self.name)
            LogMgr.info("_run_spawn() [Finished spawning subprocess]")

        # Load back the results:
        LogMgr.info("_run_spawn() [Loading results]")
        print "_run_spawn() [Loading results from %s ]" % resfilename
        self.result = SimulationResult.load_from_file(resfilename)
        LogMgr.info("_run_spawn() [Finished loading results]")

        # We have to do this so that the simulation object
        # within the result is correct!!
        self.result.simulation = self

        # Save the simulation summary:
        do_summary = False
        if do_summary:
            fname = "~/Desktop/pdfs/%s.pdf" % (self._sim_desc_str().replace(" ", ""))
            summary = SimulationMRedoc.build(self)
            summary.to_pdf(fname)

        # And unlink the old files (so we don't go mad on disk space)
        os.unlink(resfilename)
        os.unlink(_bundlefname)

        return self.result
コード例 #2
0
    def _run_spawn(self):

        LogMgr.info('_run_spawn() [Pickling Sim]')
        (bundle, resfilename) = MetaDataBundleBuilder.build_std_pickler(self)
        (_bundlefname, sim_cmd) = bundle.write_to_file_and_get_exec_string()

        # if Exists(resfilename):
        #    os.unlink(resfilename)

        if not os.path.exists(resfilename):

            # Setup the LD_LIBRARY PATH:
            # It may be nessesary to add the following to .mfrc
            # ld_library_path_suffix = /home/michael/hw/morphforge/src/morphforgecontrib/neuron_gsl/cpp
            ld_path_additions = RCMgr.get('Neuron',
                                          'ld_library_path_suffix').split(':')
            old_ld_path = os.environ.get('LD_LIBRARY_PATH', '')
            os.environ['LD_LIBRARY_PATH'] = ':'.join([old_ld_path] +
                                                     ld_path_additions)

            LogMgr.info('_run_spawn() [Spawning subprocess]')
            ret_code = subprocess.call(sim_cmd, shell=True)
            if ret_code != 1:
                raise ValueError('Unable to simulate %s' % self.name)
            LogMgr.info('_run_spawn() [Finished spawning subprocess]')

        # Load back the results:
        LogMgr.info('_run_spawn() [Loading results]')
        self.result = SimulationResult.load_from_file(resfilename)
        LogMgr.info('_run_spawn() [Finished loading results]')

        # We have to do this so that the simulation object
        # within the result is correct!!
        self.result.simulation = self

        # Save the simulation summary:

        do_summary = False
        if do_summary:
            fname = '~/Desktop/pdfs/%s.pdf' % (self._sim_desc_str().replace(
                ' ', ''))
            summary = SimulationMRedoc.build(self)
            summary.to_pdf(fname)

        return self.result
コード例 #3
0
    def _RunSpawn(self):
        
        LogMgr.info("_RunSpawn() [Pickling Sim]")
        b, resfilename = MetaDataBundleBuilder.buildStdPickler(self)
        bundlefilename, simCmd = b.writeToFileAndGetExecString()
        
        #if Exists(resfilename):
        #    os.unlink(resfilename)
        
        
        if not Exists(resfilename):

            # Setup the LD_LIBRARY PATH:
            # It may be nessesary to add the following to .mfrc
            # ld_library_path_suffix = /home/michael/hw/morphforge/src/morphforgecontrib/neuron_gsl/cpp
            ld_path_additions = RCMgr.get("Neuron","ld_library_path_suffix").split(":")
            old_ld_path = os.environ.get('LD_LIBRARY_PATH','') 
            os.environ['LD_LIBRARY_PATH'] = ":".join( [old_ld_path] + ld_path_additions ) 
            
            LogMgr.info("_RunSpawn() [Spawning subprocess]")
            retCode = ExecCommandGetRetCode(simCmd)
            if retCode != 1: raise ValueError("Unable to simulate %s" % self.name)
            LogMgr.info("_RunSpawn() [Finished spawning subprocess]")
            
        
        # Load back the results:
        LogMgr.info("_RunSpawn() [Loading results]")
        self.result = SimulationResult.loadFromFile(resfilename)
        LogMgr.info("_RunSpawn() [Finished loading results]")
        
        
        # We have to do this so that the simulation object
        # within the result is correct!!
        self.result.simulation = self
        
        
        return self.result
コード例 #4
0
class ModBuilderParams(object):

    nocmodlpath = RCReader.get('Neuron', 'nocmodlpath')
    libtoolpath = RCReader.get('Neuron', 'libtoolpath')

    compile_includes = ['.', '..'] + \
                      RCReader.get('Neuron', 'compileincludes').split(':')

    compile_defs = ['HAVE_CONFIG_H']

    std_link_libs = [
        'nrnoc',
        'oc',
        'memacs',
        'nrnmpi',
        'scopmath',
        'sparse13',
        'readline',
        'ncurses',
        'ivoc',
        'neuron_gnu',
        'meschach',
        'sundials',
        'm',
        'dl',
    ]
    nrn_link_dirs = RCReader.get('Neuron', 'nrnlinkdirs').split(':')

    rpath = RCReader.get('Neuron', 'rpath')
    rnd_alone_link_statement = RCReader.get('Neuron', 'rndalonelinkstatement')

    modlunitpath = RCReader.get('Neuron', 'modlunitpath')

    @classmethod
    def get_compile_str(cls,
                        c_filename,
                        lo_filename,
                        additional_compile_flags=''):
        incl_str = ' '.join(
            ["""-I"%s" """ % _incl for _incl in cls.compile_includes])
        def_str = ' '.join(["""-D%s """ % _def for _def in cls.compile_defs])
        variables = {
            'lo': lo_filename,
            'c': c_filename,
            'incs': incl_str,
            'defs': def_str,
            'additional_flags': additional_compile_flags
        }
        return """--mode=compile gcc %(defs)s  %(incs)s %(additional_flags)s  -g -O2 -c -o %(lo)s %(c)s  """ % variables

    @classmethod
    def get_link_str(cls, lo_filename, la_filename, additional_link_flags=''):
        std_lib_str = ' '.join(['-l%s' % lib for lib in cls.std_link_libs])
        std_lib_dir_str = ' '.join(
            ['-L%s' % _dir for _dir in cls.nrn_link_dirs])
        link_dict = {
            'la': la_filename,
            'lo': lo_filename,
            'std_lib_str': std_lib_str,
            'std_lib_dir_str': std_lib_dir_str,
            'rpath': cls.rpath,
            'randSt': cls.rnd_alone_link_statement,
            'additional_flags': additional_link_flags
        }
        return """--mode=link gcc -module  -g -O2  -shared  -o %(la)s  -rpath %(rpath)s  %(lo)s  %(std_lib_dir_str)s  %(randSt)s  %(std_lib_str)s  %(additional_flags)s """ % link_dict