Strange results of integration in parallel

Hi,

I got a very strange integration result in parallel. Basically I want to loop over all nodes, and integrate the coordinate over the whole domain. Below is the minimal code:

========================================

Blockquote

from ufl import *
from dolfin import *
import numpy as np

point0=Point(0,0)
point1=Point(10,10)
mesh = RectangleMesh(MPI.comm_world,point0,point1,2,2)

V_scale = FunctionSpace(mesh, “Lagrange”, 1)
scale = Function(V_scale,name=‘scale’) #displacement
scale.vector()[:]=0

coordinates = mesh.coordinates()
num_coordinate_mesh,_=coordinates.shape

scale_array=np.zeros(num_coordinate_mesh)
d2v_vector = dof_to_vertex_map(V_scale)

print('num_coordinate_mesh = ',num_coordinate_mesh )

for i in range(num_coordinate_mesh):
X_0=coordinates[i]
tem=X_0[0]
#tem=i #this is ok
print(’***tem=’,tem)
scale_=assemble(tem
dx(domain=mesh))
print(‘processor = ‘,MPI.comm_world.Get_rank(), ‘step = ‘,i,’ X_0’,X_0, ’ tem=’,tem,’ scale_’,scale_)

scale_array[i]=scale_

scale.vector().set_local(scale_array[d2v_vector])
scale.vector().apply(“insert”)

Save solution in VTK format

file = XDMFFile(mesh.mpi_comm(),‘check_result_1.xdmf’);
file.write(scale);

========================================
“mpirun -np 1 python minimal_code.py” gives me:
> processor = 0 step = 0 X_0 [0. 0.] tem= 0.0 scale_ 0.0
> ****tem= 10.0
> processor = 0 step = 1 X_0 [10. 0.] tem= 10.0 scale_ 1000.0
> ****tem= 0.0
> processor = 0 step = 2 X_0 [ 0. 10.] tem= 0.0 scale_ 0.0
> ****tem= 10.0
> processor = 0 step = 3 X_0 [10. 10.] tem= 10.0 scale_ 1000.0

which make sense, however if I run " mpirun -np 2 python minimal_code.py" or with more cores it gives me:

****tem= 0.0
processor = 1 step = 0 X_0 [0. 0.] tem= 0.0 scale_ 0.0
****tem= 0.0
processor = 1 step = 1 X_0 [ 0. 10.] tem= 0.0 scale_ 500.0
****tem= 10.0
processor = 1 step = 2 X_0 [10. 10.] tem= 10.0 scale_ 1000.0
num_coordinate_mesh = 3
****tem= 0.0
processor = 0 step = 0 X_0 [0. 0.] tem= 0.0 scale_ 0.0
****tem= 10.0
processor = 0 step = 1 X_0 [10. 0.] tem= 10.0 scale_ 500.0
****tem= 10.0
processor = 0 step = 2 X_0 [10. 10.] tem= 10.0 scale_ 1000.0

The results for node X_0 [ 0. 10.] and X_0 [10. 0.] does not make any sense to me.

Anyone has idea?