import sys from mpi4py import MPI # ================================================================ # Set the number of processors for Aero and Structures nProc_aero = 1 nProc_struct = 3 # ================================================================ nProc_total = nProc_aero + nProc_struct if MPI.COMM_WORLD.size < (nProc_aero + nProc_struct): print 'Error: This script must be run with at least %d processors.'%(nProc_aero+nProc_struct) sys.exit(0) # end if if MPI.COMM_WORLD.rank < nProc_aero: member_key = 0 is_aero = True is_struct = False elif MPI.COMM_WORLD.rank >= nProc_aero and MPI.COMM_WORLD.rank < nProc_total: member_key = 1 is_aero = False is_struct = True else: member_key = 2 # Idle processors # end if comm = MPI.COMM_WORLD.Split(member_key)#, MPI.COMM_WORLD.rank) # Now Initialize PETSC4py on JUST the aero processors if is_aero == True: from petsc4py import PETSc # This will call PETSc initialize on JUST the aero processors else: pass #MPI.COMM_WORLD.barrier() # If you uncomment this, it will magically run # end if