예제 #1
0
def main():
    options,args = parser.parse_args(sys.argv[1:])

    if len(args) < 3:
        parser.print_help()
        sys.exit(45)

    run=args[0]
    nodes=int(args[1])
    ppn=int(args[2])

    np=nodes*ppn
    # seconds per ellip ring pair. this is for exp...

    seconds_per=get_seconds_per_pair()

    c = shapesim.read_config(run)

    sim_config  = c['sim_config']
    mcmc_config = c['mcmc_config']
    nsplit      = c['nsplit']
    s2n_vals    = c['s2n_vals']
    s2n_fac     = c['s2n_fac']
    min_npair   = c['min_npair']

    ns2n = len(s2n_vals)

    pbsd = shapesim.get_pbs_dir(run)
    logdir=os.path.join(pbsd,'logs')
    outd = shapesim.get_output_dir(run, sub='bytrial')

    if not os.path.exists(pbsd):
        os.makedirs(pbsd)
    if not os.path.exists(logdir):
        os.makedirs(logdir)
    if not os.path.exists(outd):
        os.makedirs(outd)

    rstr=run

    job_name = '-'.join( (rstr.split('-'))[1:] )

    script_url=shapesim.get_minions_script_url(run)
    script_base=os.path.basename(script_url)

    print script_url
    with open(script_url,'w') as fobj:
        c['version'] = options.version
        fobj.write(_script_template % c)
    print

    pbsf=shapesim.get_minions_url(run,0)
    cmdf=shapesim.get_commands_url(run,0)

    print cmdf
    ntot=0
    with open(cmdf,'w') as fobj:

        for is2n in xrange(ns2n):

            s2n = s2n_vals[is2n]
            npair = shapesim.get_s2n_nrepeat(s2n, fac=s2n_fac)
            if npair < min_npair:
                npair = min_npair

            ntot += npair*nsplit

            for isplit in xrange(nsplit):
                output = shapesim.get_output_url(run, 0, is2n, itrial=isplit)
                outbname=os.path.basename(output)

                logf=outbname.replace('.rec','.log')
                cmd=_cmd_template.format(script_file=script_base,
                                         s2n=s2n,
                                         npair=npair,
                                         output=output,
                                         logfile=logf)
                fobj.write(cmd)
                fobj.write('\n')


    time_seconds = ntot*seconds_per/(np-1)

    print pbsf
    hours_raw = time_seconds/3600.
    hours = int(round(hours_raw)) + 1
    print '    raw hours:',hours_raw,'hours used:',hours

    if options.version=='hopper':
        minions_cmd='minions-hopper'
    else:
        minions_cmd='minions'

    with open(pbsf,'w') as fobj:
        cmd_bname=os.path.basename(cmdf)
        pbslog=os.path.basename(pbsf)+'.pbslog'
        pbs_text=_pbs_template.format(minions_cmd=minions_cmd,
                                      job_name=job_name,
                                      pbslog=pbslog,
                                      nodes=nodes,
                                      ppn=ppn,
                                      np=np,
                                      hours=hours,
                                      commands_file=cmd_bname)
        fobj.write(pbs_text)
예제 #2
0
def main():
    options,args = parser.parse_args(sys.argv[1:])

    if len(args) < 2:
        parser.print_help()
        sys.exit(45)

    run=args[0]
    nodes=int(args[1])
    ppn=int(options.ppn)

    np=nodes*ppn
    # seconds per ellip ring pair. this is for exp...

    c = shapesim.read_config(run)
    cs = shapesim.read_config(c['sim'])

    seconds_per=get_seconds_per(run,c)

    nsplit = cs['nsplit']

    pbsd = shapesim.get_pbs_dir(run)
    logdir=os.path.join(pbsd,'logs')
    if not os.path.exists(pbsd):
        os.makedirs(pbsd)
    if not os.path.exists(logdir):
        os.makedirs(logdir)

    if run[0:8] == 'gmix-fit':
        rstr=run.replace('gmix-fit','gmix')
    else:
        rstr=run

    job_name = '-'.join( (rstr.split('-'))[1:] )

    if 'nums2' in cs:
        n1 = cs['nums2']
    else:
        n1 = len(cs['Tobj'])

    n2 = shapesim.get_nums2n(c)

    script_url=shapesim.get_minions_script_url(run)
    script_base=os.path.basename(script_url)

    print script_url
    with open(script_url,'w') as fobj:
        fobj.write(_script_template)
    print

    for i1 in xrange(n1):
        pbsf=shapesim.get_minions_url(run,i1)
        cmdf=shapesim.get_commands_url(run,i1)

        print cmdf
        ntot=0
        with open(cmdf,'w') as fobj:
            for i2 in xrange(n2):
                nellip=get_nellip(c,i2)

                for itrial in xrange(nsplit):
                    outf=shapesim.get_output_url(run, i1, i2, itrial=itrial)
                    outbname=os.path.basename(outf)
                    logf=outbname.replace('.rec','.log')
                    cmd=_cmd_template.format(script_file=script_base,
                                             run=run,
                                             i1=i1,
                                             i2=i2,
                                             itrial=itrial,
                                             logfile=logf)

                    fobj.write(cmd)
                    fobj.write('\n')

                    ntot += nellip

        time_seconds = ntot*seconds_per/(np-1)

        print pbsf
        hours_raw = time_seconds/3600.
        hours = int(round(hours_raw)) + 1
        print '    raw hours:',hours_raw,'hours used:',hours

        with open(pbsf,'w') as fobj:
            cmd_bname=os.path.basename(cmdf)
            pbslog=os.path.basename(pbsf)+'.pbslog'
            pbs_text=_pbs_template.format(job_name=job_name,
                                          pbslog=pbslog,
                                          nodes=nodes,
                                          ppn=ppn,
                                          np=np,
                                          hours=hours,
                                          commands_file=cmd_bname)
            fobj.write(pbs_text)