view gaussian_job_rules.py @ 2:ed472dc06c20 draft default tip

Uploaded 1.0.0
author malex
date Tue, 18 Sep 2012 23:03:01 -0400
parents
children
line wrap: on
line source

def gaussian(job):
    inp_data = dict( [ ( da.name, da.dataset ) for da in job.input_datasets ] )
    inp_data.update( [ ( da.name, da.dataset ) for da in job.input_library_datasets ] )
    src_comfile = inp_data[ "infile" ].file_name
    comfile = open(src_comfile, 'r')
    ppn='1'
    pmem = '900mb'
    overhead = 200
    walltime = '11:59:59'
    for line in comfile:
        line = line.strip().lower()
        if ( "%nproc=" in line):
            try:
                ppn = line.split('=')[1]
            except Exception, e:
                log.debug(e)
                sys.stdout.write(e)
        if ("%mem=" in line):
            try:
                mem_str = line.split('=')[1]
                if ( "kb" in mem_str ):
                    mem_num = mem_str.split('kb')[0]
                    mem_num = int(int(mem_num) / 1024.0) + overhead
                if ( "mb" in mem_str ):
                    mem_num = mem_str.split('mb')[0]
                    mem_num = int(mem_num) + overhead
                elif ( "gb" in mem_str ):
                    mem_num = mem_str.split('gb')[0]
                    mem_num = (int(mem_num) * 1024) + overhead
                elif ( "kw" in mem_str ):
                    mem_num = mem_str.split('kw')[0]
                    mem_num = int(int(mem_num) * 8 / 1024.0) + overhead
                elif ( "mw" in mem_str ):
                    mem_num = mem_str.split('mw')[0]
                    mem_num = (int(mem_num) * 8) + overhead
                elif ( "gw" in mem_str ):
                    mem_num = mem_str.split('gw')[0]
                    mem_num = (int(mem_num) * 8 * 1024) + overhead
                else:
                    #Assume words
                    mem_num = int(int(mem_str) * 8 / 1024.0 / 1024.0) + overhead
                pmem_num = int(mem_num / int(ppn))
                pmem = str(pmem_num) + 'mb'
            except Exception, e:
                log.debug(e)
                sys.stdout.write(e)
        if ("!walltime=" in line):
            try:
                walltime = line.split('=')[1]
            except Exception, e:
                log.debug(e)
                sys.stdout.write(e)
    request = "-l nodes=1:ppn=%s,pmem=%s,walltime=%s" % (ppn, pmem, walltime)
    return 'drmaa://%s/' % request