#NEWLINE# def setup_communicators( self , comm ) : #NEWLINE# #INDENT# self . mpi . comm = comm #NEWLINE# size = comm . size #NEWLINE# rank = comm . rank #NEWLINE# ( mincpu , maxcpu ) = self . workflow . get_req_cpus ( ) #NEWLINE# self . _num_parallel_subs = ( size / mincpu ) #NEWLINE# leftover = ( size % mincpu ) #NEWLINE# color = [ ] #NEWLINE# resp_color = [ ] #NEWLINE# undefs = ( [ MPI . UNDEFINED ] * sub_comm ) #NEWLINE# for i in range ( self . _num_parallel_subs ) : #NEWLINE# #INDENT# color . extend ( ( [ i ] * mincpu ) ) #NEWLINE# resp_color . extend ( ( [ 0 ] + undefs [ 1 : ] ) ) #NEWLINE# #UNINDENT# if leftover : #NEWLINE# #INDENT# color . extend ( ( [ MPI . UNDEFINED ] * leftover ) ) #NEWLINE# resp_color . extend ( ( [ MPI . UNDEFINED ] * leftover ) ) #NEWLINE# #UNINDENT# sub_comm = comm . Split ( color [ rank ] ) #NEWLINE# self . _color = color #NEWLINE# if ( self . _num_parallel_subs == 1 ) : #NEWLINE# #INDENT# self . workflow . setup_communicators ( comm ) #NEWLINE# self . _resp_comm = MPI . COMM_NULL #NEWLINE# return #NEWLINE# #UNINDENT# if ( mincpu > comm . size ) : #NEWLINE# #INDENT# raise RuntimeError ( ( 'subsystem %s requested %d processors but got %s' % ( self . name , mincpu , comm . size ) ) ) #NEWLINE# #UNINDENT# self . workflow . setup_communicators ( sub_comm ) #NEWLINE# self . _resp_comm = comm . Split ( resp_color [ rank ] )