if comm.rank == master: t = Timer('TOTAL') t_init = Timer('initialization') print formatting(comm.rank, 'Calculate differential equation with {0} processes'.format(comm.size)) comm.bcast(rows, root=master) comm.bcast(cols, root=master) comm_rows, comm_cols = get_dimensions(rows, comm.size) if comm.rank == master: print formatting(comm.rank, 'with {0}D topology: {1}x{2}'.format( 2 if comm_cols > 1 else 1, comm_rows, comm_cols)) topo = comm.Create_cart(dims=[comm_rows, comm_cols], periods=[0, 0], reorder=True) cart_comm = MPI.Cartcomm(topo) coords = cart_comm.Get_coords(comm.rank) comm_i, comm_j = coords step_x = right / (cols - 1) if cols > 1 else float('inf') step_y = -top / (rows - 1) if rows > 1 else float('inf') first_cols = cols / comm_cols + cols % comm_cols next_cols = cols / comm_cols first_rows = rows / comm_rows + rows % comm_rows next_rows = rows / comm_rows def get_calc_reg(i, j): return { 'rows': first_rows if i == 0 else next_rows,