当前位置: 首页>>代码示例>>Python>>正文


Python pypar.finalize函数代码示例

本文整理汇总了Python中pypar.finalize函数的典型用法代码示例。如果您正苦于以下问题:Python finalize函数的具体用法?Python finalize怎么用?Python finalize使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了finalize函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: finalize

 def finalize(self):
     """
     End being parallel
     """
     if self.is_parallel is True:
         import pypar
         pypar.finalize()
开发者ID:dynaryu,项目名称:eqrm,代码行数:7,代码来源:parallel.py

示例2: run

def run():
    """
    Run the process, handling any parallelisation.
    """
    
    import argparse
    parser = argparse.ArgumentParser()
    parser.add_argument("-c", "--config",
                        help="Configuration file",
                        type=str)
    parser.add_argument("-i", "--inputfile",
                        help="Input DEM file (ascii format)",
                        type=str)
    parser.add_argument("-o", "--output", 
                        help="Output path",
                        type=str)
    parser.add_argument("-v", "--verbose", 
                        help=("Verbose output (not available when invoking"
                                "parallel run)") )
                                
    args = parser.parse_args() 
                          
    logfile = 'topomult.log'
    loglevel = 'INFO'
    
    if args.verbose:
        verbose = args.verbose
    else:
        verbose = False

    if args.config:
        cfg = ConfigParser.ConfigParser()
        cfg.read(args.config)

        input_file = cfg.get('Input', 'Filename')
        output_path = cfg.get('Output', 'Path')
        logfile = cfg.get('Logging', 'LogFile')
        loglevel = cfg.get('Logging', 'LogLevel')
        verbose = cfg.get('Logging', 'Verbose')
        
    if args.inputfile:
        input_file = args.inputfile

    if args.output:
        output_path = args.output
    
    attemptParallel()
    if pp.size() > 1 and pp.rank() > 0:
        logfile += '-' + str(pp.rank())
        verbose = False  # to stop output to console

    flStartLog(logfile, loglevel, verbose)
    
    pp.barrier()
    work(input_file, output_path,
             ['n','s','e','w','ne','nw','se','sw'])
    pp.barrier()
    
    pp.finalize()
开发者ID:wcarthur,项目名称:topomultipliers,代码行数:59,代码来源:topomult.py

示例3: runMapReduce

    def runMapReduce(self):
        if self.MPI_myid == 0:
            self.result = self.master()
        else:
            self.slave()

        pypar.finalize()
        logging.debug('[PROCESS %d]: MPI environment finalized.'%(self.MPI_myid, ))
        return
开发者ID:Mahdisadjadi,项目名称:pypar,代码行数:9,代码来源:MPIMapReducer.py

示例4: abnormalexit

def abnormalexit(reason):
    """this tells each worker node to exit, then kills the server process.
       this should only be called by the server node"""
    print 'abnormal exit'
    print reason
    sendtoall(('Die', 0))
    pypar.barrier()
    pypar.finalize()
    sys.exit(2)
开发者ID:qiuxing,项目名称:corrperm,代码行数:9,代码来源:mpi_nstat.py

示例5: run_client

def run_client():
    '''
    Runs
    '''
    # Identification
    myid = pypar.rank() # id of this process
    nproc = pypar.size() # number of processors

    print "I am client", myid
    pypar.finalize()
开发者ID:JoErNanO,项目名称:brian,代码行数:10,代码来源:cluster_client.py

示例6: run

 def run(self):
     if self.myid == 0:
         self.work.masterBeforeWork()
         self.master()
         self.work.masterAfterWork()
     else:
         self.work.slaveBeforeWork()
         self.slave()
         self.work.slaveAfterWork()
     
     pypar.finalize()
     if self.myid != 0:
         sys.exit()
开发者ID:Mahdisadjadi,项目名称:pypar,代码行数:13,代码来源:pypar_balancer.py

示例7: two_example

def two_example():
    txt = ["yes", "no", "when", "what the", "a", "5ive!"]

    rank = pypar.rank()
    size = pypar.size()

    print
    print "I am processor %d of %d. " % (rank, size)
    for i, ele in enumerate(txt):
        if i % size == rank:
            print "i" + str(i) + " P" + str(rank) + " len " + str(len(ele)) + " for " + ele

    pypar.finalize()
开发者ID:vipkolon,项目名称:eqrm,代码行数:13,代码来源:just_a_parallel_spike.py

示例8: main

def main():
    
#    #=========================================================================
#    #==============    Electronic TISE   =====================================
#    #=========================================================================
#    #Get parameters.
#    m_max, nu_max, mu_max, R_grid, beta, theta = el_tise_problem_parameters()
#   
#    #Do calculations.
#    electronic_BO.save_electronic_eigenstates(m_max, nu_max, mu_max, R_grid, beta, theta)
#
#    #=========================================================================   
#    #==============    Electronic TDSE   =====================================
#    #=========================================================================
#    #Get parameters.
#    filename, m, q, E_lim = el_tdse_problem_parameters()
#    
#    #Do calculations.
#    tdse = tdse_electron.TDSE_length_z(filename = filename)
#    tdse.BO_dipole_couplings(m, q, E_lim)
#
#    #=========================================================================   
#    #==============    Vibrational TISE   ====================================
    #=========================================================================
    #Get problem parameters.
    filename_el, nr_kept, xmin, xmax, xsize, order = vib_problem_parameters()
    
    #Do calculations.
    vibrational_BO.save_all_eigenstates(filename_el, nr_kept, 
	xmin, xmax, xsize, order)
    
    #=========================================================================   
    #==============    Vibrational TDSE   ====================================
    #=========================================================================
    #Get problem parameters.
    filename_el, nr_kept, xmin, xmax, xsize, order = vib_problem_parameters()
    
    #Do calculations.
    vibrational_BO.save_all_couplings(filename_el, nr_kept, 
    	xmin, xmax, xsize, order)
    
    #Calculate couplings for the eigenfunction basis.
    #vibrational_BO.save_eigenfunction_couplings(filename_el, nr_kept, 
    #	xmin, xmax, xsize, order)
    
    #=========================================================================
   
    pypar.finalize()
开发者ID:sas044,项目名称:H2plus_Born_Oppenheimer,代码行数:48,代码来源:main.py

示例9: main

def main():

    # Parse command line

    options, args = cookbook.doc_optparse.parse( __doc__ )

    #try:
    pos_fname, neg_fname, out_dir = args
    align_count, mapping = rp.mapping.alignment_mapping_from_file( file( options.mapping ) )
    #except:
    #    cookbook.doc_optparse.exit()

    try:
        run( open( pos_fname ), open( neg_fname ), out_dir, options.format, align_count, mapping )
    finally:
        pypar.finalize()
开发者ID:bxlab,项目名称:esperr,代码行数:16,代码来源:rp_adapt_mpi.py

示例10: __init__

    def __init__(self, aWorkList):  
       
        self.WORKTAG = 1
        self.DIETAG =  2
        
        self.MPI_myid =    pypar.rank()
        self.MPI_numproc = pypar.size()
        self.MPI_node =    pypar.get_processor_name()

        self.works = aWorkList
        self.numWorks = len(self.works)

        self.reduceFunction = None
        self.mapFunction = None
        self.result = None
   
        if self.MPI_numproc < 2:
            pypar.finalize()
            if self.MPI_myid == 0:
                raise Exception, 'ERROR: Number of processors must be greater than 2.'
开发者ID:Mahdisadjadi,项目名称:pypar,代码行数:20,代码来源:MPIMapReducer.py

示例11: start

def start(initializer=None, initargs=(), maxtasks=None):
    global Pool
    try:
        # make pypar available
        global pp
        import pypar as pp

        if pp.size() > 1:
            Pool = PyparPool
            if pp.rank() > 0:
                worker(initializer, initargs, maxtasks)
        else:
            # fallback to multiprocessing
            print "Using multiprocessing"
            pp.finalize()
            import multiprocessing as mp

            Pool = mp.Pool

    except ImportError:  # no pypar
        return
开发者ID:deepakkarki,项目名称:pypar,代码行数:21,代码来源:pyparprocessing.py

示例12: do_run

def do_run(pdb, i, cur, db, mutationList):
    
    if mutationList != "ALA":
        mfile = Core.Data.MutationListFile(filename=mutationList,create=True)
        mfile.removeDuplicates(autoUpdate=False)
        mutList = mfile.mutantList()
        if isRoot(myid):
            print mfile.numberOfMutants()
    else:
        mutList = Core.Data.CreateScanList(pdbFile=i, mutation='ALA', skipResidueTypes=['ALA', 'GLY'])
    
    results = DeltaStability(inputFile = i, mutationList = mutList, configurationFile='/home/satnam/proteinDesignTool.conf', workingDirectory = os.getcwd(), outputDirectory = os.getcwd())
    
    # Results are submitted to results_pdb+chain and only by one processor
    if isRoot(myid):
        cur.execute("create table if not exists results_%s_%s(mutation VARCHAR(20), score FLOAT);" % (pdb,os.path.split(mutationList)[1]))
        for mutant in range(results.stabilityResults.numberOfRows()):
            cur.execute("insert into results_%s_%s (mutation, score) VALUES (%s%s%s, %s%s%s);" % (pdb,os.path.split(mutationList)[1], '"', results.stabilityResults[mutant][0], '"', '"', results.stabilityResults[mutant][-1],'"'))
        print "Calculated %s stability and results added to database" % (pdb)
            
    pypar.finalize()
开发者ID:yongwangCPH,项目名称:peat,代码行数:21,代码来源:ProteinComplexTool_execute.py

示例13: main

def main():
    
    # Ensure all Processors are ready
    pypar.barrier()
    print "Processor %d is ready" % (myid)
    
    # Connect to MySQL db
    db = MySQLdb.connect(host="localhost", 
                         user = "root", 
                         passwd = "samsung", 
                         db = "sat")
    cur = db.cursor()


    # Option parser from wrapper script
    parser = optparse.OptionParser()
    # PDB
    parser.add_option("-p", "--pdb", 
                      help="Choose all or a pdb id", 
                      dest="pdb", default ="all")
    # PDB directory
    parser.add_option("-d", "--dir", 
                      help="i", 
                      dest="i", default ="all")

    parser.add_option("-m", "--mutationList", 
                      help="Location of mutation list file", 
                      dest="m", default="ALA")
    
    (opts, args) = parser.parse_args()
    
    # Run calculations
    do_run(opts.pdb, opts.i, cur, db, opts.m)

    # Finalize and exit
    pypar.finalize()
开发者ID:yongwangCPH,项目名称:peat,代码行数:36,代码来源:ProteinComplexTool_execute.py

示例14:

  mr2 = mr.copy()
  mr2.reduce(output)
  fp.close()
  mr2.destroy()

# stats to screen
# include stats on number of nonzeroes per row

if me == 0:
  print order,"rows in matrix"
  print ntotal,"nonzeroes in matrix"

mr.reduce(nonzero)
mr.collate()
mr.reduce(degree)
mr.collate()
mr.reduce(histo)
mr.gather(1)
mr.sort_keys(ncompare)
total = 0
mr.map_kv(mr,stats)
if me == 0: print order-total,"rows with 0 nonzeroes"

if me == 0:
  print "%g secs to generate matrix on %d procs in %d iterations" % \
        (tstop-tstart,nprocs,niterate)

mr.destroy()
  
pypar.finalize()
开发者ID:AndreasFetzer,项目名称:VTK,代码行数:30,代码来源:rmat.py

示例15: GenericMPI

    from pypar_balancer import PyparWork, PyparBalancer

    NUM_NODES=pp.size()
    
    if NUM_NODES > 1:
        HAVE_MPI=1  # we have pypar, and we're running with more than one node
        
    if DEBUG:
        if MY_RANK==0:
            if HAVE_PYPAR and HAVE_MPI:
                print "Running full MPI"
            elif HAVE_PYPAR:
                print "MPI available, but not enough nodes for master/slave"

    if HAVE_PYPAR and not HAVE_MPI:
        pp.finalize() # not enough nodes to actually run master/slave... shut down MPI now.
        
except:
    if DEBUG:
        import traceback
        traceback.print_exc()
        if HAVE_PYPAR and HAVE_MPI:
            print "Running full MPI"
        elif HAVE_PYPAR:
            print "MPI available, but not enough nodes for master/slave"
        else:
            print "No MPI."
        
if HAVE_MPI:
    class GenericMPI (PyparWork):
    
开发者ID:TaikiKato,项目名称:pypar,代码行数:30,代码来源:handympi.py


注:本文中的pypar.finalize函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。