def splitInput(filename): """ Split the parallel input file into multiple async file names Parameters filename: The path to the original parallel input file (string) """ nproc = 0 file = open(filename, 'rU') text = "" while 1: line = file.readline() if line == "": break text += line line = string.strip(line) if line.startswith("pdime"): # Get # Procs words = string.split(line) nproc = int(words[1]) * int(words[2]) * int(words[3]) if nproc == 0: sys.stderr.write("%s is not a valid APBS parallel input file!\n" % filename) sys.stderr.write("The inputgen script was unable to asynchronize this file!\n") sys.exit(2) base_pqr_name = utilities.getPQRBaseFileName(filename) for i in range(nproc): outname = base_pqr_name + "-PE%i.in" % i outtext = string.replace(text, "mg-para\n","mg-para\n async %i\n" % i) outfile = open(outname, "w") outfile.write(outtext) outfile.close()
def printInputFiles(self): """ Make the input file(s) associated with this object """ base_pqr_name = utilities.getPQRBaseFileName(self.pqrpath) if self.asyncflag == 1: outname = base_pqr_name + "-para.in" # Temporarily disable async flag for elec in self.elecs: elec.asyncflag = 0 file = open(outname, "w") file.write(str(self)) file.close() # Now make the async files elec = self.elecs[0] nproc = elec.pdime[0] * elec.pdime[1] * elec.pdime[2] for i in range(int(nproc)): outname = base_pqr_name + "-PE%i.in" % i for elec in self.elecs: elec.asyncflag = 1 elec.async = i file = open(outname, "w") file.write(str(self)) file.close() else: outname = base_pqr_name + ".in" file = open(outname, "w") file.write(str(self)) file.close()
def dumpPickle(self): """ Make a Python pickle associated with the APBS input parameters """ base_pqr_name = utilities.getPQRBaseFileName(self.pqrpath) outname = base_pqr_name + "-input.p" pfile = open(outname, "w") pickle.dump(self, pfile) pfile.close()