Esempio n. 1
0
    def submitjob(self, prog, args, dirpath, Nproc=None, wtime=None):
        if Nproc is None:
            Nproc = self.Nproc
        if wtime is None:
            wtime = self.wtime

        if self.paral == self.paral_modes.get("OMP"):
            os.environ["OMP_NUM_THREADS"] = str(Nproc)

        progargs = []
        jobname = str(dirpath)

        progargs.append("-n")
        progargs.append(str(Nproc))
        progargs.append("-W")
        progargs.append(str(wtime))
        progargs.append("-J")
        progargs.append(jobname)
        if Nproc > 1 and self.paral == self.paral_modes.get("OMP"):
            progargs.append("-R")
            progargs.append("span[ptile=" + str(Nproc) + "]")
        if Nproc > 1 and self.paral == self.paral_modes.get("MPI"):
            progargs.append("mpirun")
        progargs.append(prog)
        [progargs.append(a) for a in args]
        with open(dirpath + "/err.log", 'w') as errfile:
            with open(dirpath + "/out.log", 'w') as outfile:
                proc = su.dispatch(self.subcommand,
                                   progargs,
                                   dirpath,
                                   errfile=errfile,
                                   outfile=outfile)
        self.procinfo.append([proc.pid, jobname])
        return proc
Esempio n. 2
0
    def getMerit(self, structure, path):
        '''Returns the merit function evaluated for the Structure structure,
        with base path "path". 
        '''

        path = path + "/" + structure.dirname
        try:

            if self.merit == self.merits["Elase"]:
                proc = su.dispatch('tail', ['-n', '1', self.resultfile], path)
                [output, _] = proc.communicate()
                output = output.split()
                return abs(float(output[2]) - float(self.target))
            elif self.merit == self.merits["max gain"]:
                gain = []
                [gain.append(float(l[2])) for l in structure.results]
                return max(gain)
            elif self.merit == self.merits["wall plug efficiency"]:
                wp = []
                if structure.results == "ERROR":
                    return "ERROR"
                [wp.append(float(l[5])) for l in structure.results]
                return max(wp)
            else:
                print("Merit function " + str(self.merit) +
                      "not implemented yet!")
                return "ERROR"

        # Catch index errors arising from sewlab failing
        except (IndexError):
            return "ERROR"
Esempio n. 3
0
    def jobstatus(self, proc):
        for info in self.procinfo:
            if info[0] == proc.pid:
                jobname = info[1]
        p = su.dispatch("bjobs", ["-J", jobname], errfile=subprocess.PIPE)
        out = p.communicate()

        if ("not found" in out[1]) and (proc.poll() != None):
            dbg.debug("process ended!")
            return False
        else:
            return True
Esempio n. 4
0
    def submitjob(self, prog, args, dirpath, Nproc=None, wtime=None):
        if Nproc is None:
            Nproc = self.Nproc

        progargs = []
        progargs.append("-np")
        progargs.append(str(Nproc))
        progargs.append(prog)
        [progargs.append(a) for a in args]

        proc = su.dispatch("mpirun", progargs, dirpath)

        return proc
Esempio n. 5
0
    def run_sewself(self, structure, spath, inputs=None):
        '''Run sewself for given structure and structure path (spath)
        inputs (Optional): List of sting of commands to be executed (a-w)
        '''
        commands = ""
        if inputs is None:
            inputs = self.commands

        for c in inputs:
            if c[0] == 'a':
                commands += "a\n" + c[1] + "\n" + c[2] + \
                 "\n" + c[3] + "\n"
            elif c[0] == 'b':
                commands += "b\n"
                commands += str(self.numpar.get('Tlattice')) + "\n"
                commands += str(self.numpar.get('Te')) + "\n"
            elif c[0] == 'c':
                commands += "c\n"
            elif c[0] == 'd':
                commands += "d\n"
            elif c[0] == 'e':
                commands += "e\n"  # compute self-consitent potential
                commands += str(self.numpar.get('Tlattice')) + "\n"
                commands += str(self.numpar.get('Te')) + "\n"
            elif c[0] == 'f':
                commands += "f\n"
            elif c[0] == 'g':
                commands += "g\n"
                commands += str(self.numpar.get('Te')) + "\n"
            else:
                print("WARNING: Option " + c[0] + \
                " not implemented in Isewself!")
        commands += "q\n^C\n"

        dbg.debug("Running sewself:", callclass=self)
        dbg.flush()
        proc = su.dispatch(self.sewself, [],
                           spath,
                           infile=subprocess.PIPE,
                           outfile=subprocess.PIPE,
                           errfile=subprocess.PIPE)
        dbg.debug("Communicating sewself: \n" + commands, callclass=self)
        dbg.flush()
        out, err = proc.communicate(commands)
        structure.output = out
Esempio n. 6
0
 def submitandwait(self, prog, args, dirpath):
     proc = su.dispatch(prog, args, dirpath)
     while proc.poll() == None:
         time.sleep(0.1)
     return proc
Esempio n. 7
0
 def submitjob(self, prog, args, dirpath, Nproc=None, wtime=None):
     proc = su.dispatch(prog, args, dirpath)
     return proc
Esempio n. 8
0
 def run_buildmatself(self, structure, spath):
     su.dispatch(self.buildmatself, [self.structfilename], spath)