⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mpdboot.py

📁 fortran并行计算包
💻 PY
📖 第 1 页 / 共 2 页
字号:
#!/usr/bin/env python##   (C) 2001 by Argonne National Laboratory.#       See COPYRIGHT in top-level directory.#"""usage:  mpdboot --totalnum=<n_to_start> [--file=<hostsfile>]  [--help] \                 [--rsh=<rshcmd>] [--user=<user>] [--mpd=<mpdcmd>]      \                 [--loccons] [--remcons] [--shell] [--verbose] [-1]     \                [--ncpus=<ncpus>] [--ifhn=<ifhn>] [--chkup] [--chkuponly] \                [--maxbranch=<maxbranch>] or, in short form,         mpdboot -n n_to_start [-f <hostsfile>] [-h] [-r <rshcmd>] [-u <user>] \                 [-m <mpdcmd>]  -s -v [-1] [-c]--totalnum specifies the total number of mpds to start; at least  one mpd will be started locally, and others on the machines specified  by the file argument; by default, only one mpd per host will be  started even if the hostname occurs multiple times in the hosts file-1 means remove the restriction of starting only one mpd per machine;   in this case, at most the first mpd on a host will have a console--file specifies the file of machines to start the rest of the mpds on;  it defaults to mpd.hosts--mpd specifies the full path name of mpd on the remote hosts if it is  not in your path--rsh specifies the name of the command used to start remote mpds; it  defaults to ssh; an alternative is rsh--shell says that the Bourne shell is your default for rsh' --verbose shows the ssh attempts as they occur; it does not provide  confirmation that the sshs were successful--loccons says you do not want a console available on local mpd(s)--remcons says you do not want consoles available on remote mpd(s)--ncpus indicates how many cpus you want to show for the local machine;  others are listed in the hosts file--ifhn indicates the interface hostname to use for the local mpd; others  may be specified in the hostsfile--chkup requests that mpdboot try to verify that the hosts in the host file  are up before attempting start mpds on any of them; it just checks the number  of hosts specified by -n--chkuponly requests that mpdboot try to verify that the hosts in the host file  are up; it then terminates; it just checks the number of hosts specified by -n--maxbranch indicates the maximum number of mpds to enter the ring under another;  the default is 4"""from time import ctime__author__ = "Ralph Butler and Rusty Lusk"__date__ = ctime()__version__ = "$Revision: 1.49 $"__credits__ = ""import refrom os       import environ, path, kill, access, X_OKfrom sys      import argv, exit, stdoutfrom popen2   import Popen4, Popen3, popen2from socket   import gethostname, gethostbyname_exfrom select   import select, errorfrom signal   import SIGKILLfrom commands import getoutput, getstatusoutputfrom mpdlib   import mpd_set_my_id, mpd_get_my_username, mpd_same_ips, \                     mpd_get_ranks_in_binary_tree, mpd_print, MPDSockglobal myHost, fullDirName, rshCmd, user, mpdCmd, debug, verbosedef mpdboot():    global myHost, fullDirName, rshCmd, user, mpdCmd, debug, verbose    myHost = gethostname()    mpd_set_my_id('mpdboot_%s' % (myHost) )    fullDirName  = path.abspath(path.split(argv[0])[0])    rshCmd = 'ssh'    user = mpd_get_my_username()    mpdCmd = path.join(fullDirName,'mpd.py')    hostsFilename = 'mpd.hosts'    totalnumToStart = 1    # may get chgd below    debug = 0    verbose = 0    localConArg  = ''    remoteConArg = ''    oneMPDPerHost = 1    myNcpus = 1    myIfhn = ''    chkupIndicator = 0  # 1 -> chk and start ; 2 -> just chk    maxUnderOneRoot = 4    try:        shell = path.split(environ['SHELL'])[-1]    except:        shell = 'csh'    argidx = 1    # skip arg 0    while argidx < len(argv):        if   argv[argidx] == '-h' or argv[argidx] == '--help':            usage()        elif argv[argidx] == '-r':    # or --rsh=            rshCmd = argv[argidx+1]            argidx += 2        elif argv[argidx].startswith('--rsh'):            splitArg = argv[argidx].split('=')            try:                rshCmd = splitArg[1]            except:                print 'mpdboot: invalid argument:', argv[argidx]                usage()            argidx += 1        elif argv[argidx] == '-u':    # or --user=            user = argv[argidx+1]            argidx += 2        elif argv[argidx].startswith('--user'):            splitArg = argv[argidx].split('=')            try:                user = splitArg[1]            except:                print 'mpdboot: invalid argument:', argv[argidx]                usage()            argidx += 1        elif argv[argidx] == '-m':    # or --mpd=            mpdCmd = argv[argidx+1]            argidx += 2        elif argv[argidx].startswith('--mpd'):            splitArg = argv[argidx].split('=')            try:                mpdCmd = splitArg[1]            except:                print 'mpdboot: invalid argument:', argv[argidx]                usage()            argidx += 1        elif argv[argidx] == '-f':    # or --file=            hostsFilename = argv[argidx+1]            argidx += 2        elif argv[argidx].startswith('--file'):            splitArg = argv[argidx].split('=')            try:                hostsFilename = splitArg[1]            except:                print 'mpdboot: invalid argument:', argv[argidx]                usage()            argidx += 1        elif argv[argidx].startswith('--ncpus'):            splitArg = argv[argidx].split('=')            try:                myNcpus = int(splitArg[1])            except:                print 'mpdboot: invalid argument:', argv[argidx]                usage()            argidx += 1        elif argv[argidx].startswith('--ifhn'):            splitArg = argv[argidx].split('=')            myIfhn = splitArg[1]            myHost = splitArg[1]            argidx += 1        elif argv[argidx] == '-n':    # or --totalnum=            totalnumToStart = int(argv[argidx+1])            argidx += 2        elif argv[argidx].startswith('--totalnum'):            splitArg = argv[argidx].split('=')            try:                totalnumToStart = int(splitArg[1])            except:                print 'mpdboot: invalid argument:', argv[argidx]                usage()            argidx += 1        elif argv[argidx].startswith('--maxbranch'):            splitArg = argv[argidx].split('=')            try:                maxUnderOneRoot = int(splitArg[1])            except:                print 'mpdboot: invalid argument:', argv[argidx]                usage()            argidx += 1        elif argv[argidx] == '-d' or argv[argidx] == '--debug':            debug = 1            argidx += 1        elif argv[argidx] == '-s' or argv[argidx] == '--shell':            shell = 'bourne'            argidx += 1        elif argv[argidx] == '-v' or argv[argidx] == '--verbose':            verbose = 1            argidx += 1        elif argv[argidx] == '-c' or argv[argidx] == '--chkup':            chkupIndicator = 1            argidx += 1        elif argv[argidx] == '--chkuponly':            chkupIndicator = 2            argidx += 1        elif argv[argidx] == '-1':            oneMPDPerHost = 0            argidx += 1        elif argv[argidx] == '--loccons':            localConArg  = '-n'            argidx += 1        elif argv[argidx] == '--remcons':            remoteConArg = '-n'            argidx += 1        else:            print 'mpdboot: unrecognized argument:', argv[argidx]            usage()    if debug:        print 'debug: starting'    lines = []    if totalnumToStart > 1:        try:            f = open(hostsFilename,'r')            for line in f:                lines.append(line)        except:            print 'unable to open (or read) hostsfile %s' % (hostsFilename)            exit(-1)    hostsAndInfo = [ {'host' : myHost, 'ncpus' : myNcpus, 'ifhn' : myIfhn} ]    for line in lines:        line = line.strip()        if not line  or  line[0] == '#':            continue        splitLine = re.split(r'\s+',line)        host = splitLine[0]        ncpus = 1  # default        if ':' in host:            (host,ncpus) = host.split(':',1)            ncpus = int(ncpus)        ifhn = ''  # default        for kv in splitLine[1:]:            (k,v) = kv.split('=',1)            if k == 'ifhn':                ifhn = v        hostsAndInfo.append( {'host' : host, 'ncpus' : ncpus, 'ifhn' : ifhn} )    cachedIPs = {}    if oneMPDPerHost  and  totalnumToStart > 1:        oldHostsAndInfo = hostsAndInfo[:]        hostsAndInfo = []        for hostAndInfo in oldHostsAndInfo:            oldhost = hostAndInfo['host']            try:

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -