Exemplo n.º 1
0
def main():
    options,args = parser.parse_args(sys.argv[1:])

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

    run=args[0]

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

    group=options.group
    if group is not None:
        group = 'group: ['+group+']'
    else:
        group=''

    mode=''
    if options.bynode:
        mode='mode: bynode'

    extra=''
    if options.extra is not None:
        extra='\n'.join( options.extra.split(';') )

    wqd = shapesim.get_wq_dir(run, combine=True)
    if not os.path.exists(wqd):
        os.makedirs(wqd)

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

    runtype = c['runtype']
    if runtype == 'byellip':
        n2 = cs['nume']
    else:
        n2 = shapesim.get_nums2n(c)

    for i1 in xrange(n1):
        for i2 in xrange(n2):
            job_name='%s-combine-%03i-%03i' % (rstr,i1,i2)

            wqurl = shapesim.get_wq_url(run,i1,i2,combine=True)

            wlog("writing wq script:",wqurl)
            with open(wqurl,'w') as fobj:
                wqscript=_wqtemplate % {'job_name':job_name,
                                        'run':run, 
                                        'i1':i1,
                                        'i2':i2,
                                        'group':group,
                                        'mode':mode,
                                        'extra':extra,
                                        'pri':options.priority}
                fobj.write(wqscript)
Exemplo n.º 2
0
def main():
    options,args = parser.parse_args(sys.argv[1:])

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

    run=args[0]

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


    if options.bytrial:
        if 'stack-' in run:
            ntrial=c['nsplit']
        else:
            orient=cs.get('orient','rand')
            if orient == 'ring':
                ntrial = cs['nsplit']
            else:
                ntrial = cs['ntrial']


    wqd = shapesim.get_wq_dir(run, bytrial=options.bytrial)
    if not os.path.exists(wqd):
        os.makedirs(wqd)

    extra=''
    if options.bynode:
        extra='mode: bynode\nN: 1'
    elif options.ncores is not None:
        ncores=int(options.ncores)
        extra='mode: bycore1\nN: %d' % ncores

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

    n1 = shapesim.get_numT(cs)

    runtype = c['runtype']
    if runtype == 'byellip':
        n2 = cs['nume']
    else:
        n2 = shapesim.get_nums2n(c)



    for i1 in xrange(n1):
        for i2 in xrange(n2):
            groups=''
            if options.i2new is not None and i2 <= int(options.i2new):
                groups='group: [new,new2]'
            elif options.i2new1 is not None and i2 <= int(options.i2new1):
                groups='group: [new]'
            elif options.i2new2 is not None and i2 <= int(options.i2new2):
                groups='group: [new2]'
            elif options.groups is not None:
                groups = 'group: [%s]' % options.groups

            if options.bytrial:
                for itrial in xrange(ntrial):
                    job_name='%s-%03i-%03i-%02i' % (rstr,i1,i2,itrial)
                    wqurl = shapesim.get_wq_url(run,i1,i2,itrial=itrial)
                    wlog("writing wq script:",wqurl)
                    with open(wqurl,'w') as fobj:
                        d={'job_name':job_name,
                           'run':run, 
                           'i1':i1,
                           'i2':i2,
                           'itrial':itrial,
                           'groups':groups,
                           'extra':extra,
                           'pri':options.priority}
                        wqscript=_wqtemplate_bytrial % d
                        fobj.write(wqscript)


            else:
                job_name='%s-%03i-%03i' % (rstr,i1,i2)
                wqurl = shapesim.get_wq_url(run,i1,i2)

                wlog("writing wq script:",wqurl)
                with open(wqurl,'w') as fobj:
                    wqscript=_wqtemplate % {'job_name':job_name,
                                            'run':run, 
                                            'i1':i1,
                                            'i2':i2,
                                            'groups':groups,
                                            'extra':extra,
                                            'pri':options.priority}
                    fobj.write(wqscript)
Exemplo n.º 3
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)