def backengine(self): """ Starts WPG simulations in parallel in a subprocess """ fname = IOUtilities.getTmpFileName() self.dumpToFile(fname) forcedMPIcommand = self.parameters.forced_mpi_command if forcedMPIcommand == "": (np, ncores) = self.computeNTasks() mpicommand = ParallelUtilities.prepareMPICommandArguments( np, ncores) else: mpicommand = forcedMPIcommand if 'SIMEX_VERBOSE' in os.environ: if 'MPI' in os.environ['SIMEX_VERBOSE']: print(("WavePropagator backengine mpicommand: " + mpicommand)) if 'PYTHON' in os.environ['SIMEX_VERBOSE']: import platform print("Running python %s." % (platform.python_version())) mpicommand += " python " + __file__ + " " + fname args = shlex.split(mpicommand) proc = subprocess.Popen(args, universal_newlines=True) proc.wait() os.remove(fname) return proc.returncode
def backengine(self): """ This method drives the backengine CrystFEL.pattern_sim.""" # pattern_sim backengine does not support MPI. return self._run() # collect MPI arguments if self.parameters.forced_mpi_command == "": np = self.computeNTasks() mpicommand = ParallelUtilities.prepareMPICommandArguments(np) else: mpicommand = self.parameters.forced_mpi_command # Dump to a temporary file. fname = IOUtilities.getTmpFileName() self.dumpToFile(fname) mpicommand += " ".join([" ", sys.executable, __file__, fname]) args = shlex.split(mpicommand) if 'SIMEX_VERBOSE' in os.environ and os.environ[ 'SIMEX_VERBOSE'] == 'MPI': print("MPI command: " + mpicommand) try: proc = subprocess.Popen(args, universal_newlines=True) proc.wait() except: raise finally: os.remove(fname) return proc.returncode
def backengine(self): """ Starts EMC simulations in parallel in a subprocess """ # Set paths. self._setupPaths() fname = IOUtilities.getTmpFileName() self.dumpToFile(fname) # collect MPI arguments if self.parameters.forced_mpi_command == "": np = self.computeNTasks() #mpicommand=ParallelUtilities.prepareMPICommandArguments(np) mpicommand = "" else: mpicommand = self.parameters.forced_mpi_command # collect program arguments command_sequence = [ 'python', __file__, fname, ] # put MPI and program arguments together args = shlex.split(mpicommand) + command_sequence print(' '.join(args)) if 'SIMEX_VERBOSE' in os.environ: if 'MPI' in os.environ['SIMEX_VERBOSE']: print(("EMCOrientation backengine mpicommand: " + mpicommand)) print(' '.join(args)) if 'PYTHON' in os.environ['SIMEX_VERBOSE']: import platform print("Running python version %s." % (platform.python_version())) # Run the backengine command. proc = subprocess.Popen(args) proc.wait() os.remove(fname) # Return the return code from the backengine. return proc.returncode
def _backengineWithPdb(self): """ """ """ Run the diffraction simulation if the sample is a pdb. Codes is based on pysingfel/tests/test_particle.test_calFromPDB """ # Dump self to file. fname = IOUtilities.getTmpFileName() self.dumpToFile(fname) # Setup the mpi call. forcedMPIcommand = self.parameters.forced_mpi_command if forcedMPIcommand == "" or forcedMPIcommand is None: (np, ncores) = self.computeNTasks() mpicommand = ParallelUtilities.prepareMPICommandArguments( np, ncores) else: mpicommand = forcedMPIcommand mpicommand += " ".join(("", sys.executable, __file__, fname)) if 'SIMEX_VERBOSE' in os.environ: if 'MPI' in os.environ['SIMEX_VERBOSE']: print(("SingFELPhotonDiffractor backengine mpicommand: " + mpicommand)) # Launch the system command. args = shlex.split(mpicommand) with subprocess.Popen(args, universal_newlines=True) as proc: out, err = proc.communicate() # Remove the dumped class. os.remove(fname) return proc.returncode