Index: issm/trunk/src/c/Container/Nodes.cpp
===================================================================
--- issm/trunk/src/c/Container/Nodes.cpp	(revision 10522)
+++ issm/trunk/src/c/Container/Nodes.cpp	(revision 11527)
@@ -60,5 +60,4 @@
 
 	int  i;
-	
 	int  dofcount=0;
 	int  maxdofspernode=0;
@@ -69,7 +68,7 @@
 
 	/*some check: */
-	if ((setenum!=GsetEnum) && (setenum!=FsetEnum) && (setenum!=SsetEnum))_error_("%s%s%s"," dof distribution for set of enum type ",EnumToStringx(setenum)," not supported yet!");
-
-	/*Go through objects, and distribute dofs locally, from 0 to numberofdofs: */
+	_assert_(setenum==GsetEnum || setenum==FsetEnum || setenum==SsetEnum);
+
+	/*Go through objects, and distribute dofs locally, from 0 to numberofdofsperobject*/
 	for (i=0;i<this->Size();i++){
 		Node* node=(Node*)this->GetObjectByOffset(i);
@@ -81,27 +80,20 @@
 	}
 
-	/*Ok, now every object has distributed dofs, but locally, and with a dof count starting from 
-	 *0. This means the dofs between all the cpus are not synchronized! We need to synchronize all 
-	 *dof on all cpus, and use those to update the dofs of every object: */
-
+	/* Now every object has distributed dofs, but locally, and with a dof count starting from 
+	 * 0. This means the dofs between all the cpus are not unique. We now offset the dofs of eache
+	 * cpus by the total last dofs of the previus cpu, starting from 0.
+	 * First: bet number of dofs for each cpu*/
 	alldofcount=(int*)xmalloc(num_procs*sizeof(int));
 	MPI_Gather(&dofcount,1,MPI_INT,alldofcount,1,MPI_INT,0,MPI_COMM_WORLD);
 	MPI_Bcast(alldofcount,num_procs,MPI_INT,0,MPI_COMM_WORLD);
 
-	/*Ok, now every cpu should start its own dof count at the end of the dofcount 
-	 * from cpu-1. : */
+	/* Every cpu should start its own dof count at the end of the dofcount from cpu-1*/
 	dofcount=0;
-	if(my_rank==0){
-		dofcount=0;
-	}
-	else{
+	if(my_rank!=0){
 		for(i=0;i<my_rank;i++){
 			dofcount+=alldofcount[i];
 		}
 	}
-
-	/*Ok, now every cpu knows where his dofs should start. Update the dof count: */
 	for (i=0;i<this->Size();i++){
-
 		/*Check that this node corresponds to our analysis currently being carried out: */
 		Node* node=(Node*)this->GetObjectByOffset(i);
@@ -109,20 +101,17 @@
 			node->OffsetDofs(dofcount,setenum);
 		}
-
-	}
-
-	/*Finally, remember that cpus may have skipped some objects, because they were clones. For every 
+	}
+
+	/* Finally, remember that cpus may have skipped some objects, because they were clones. For every 
 	 * object that is not a clone, tell them to show their dofs, so that later on, they can get picked 
 	 * up by their clones: */
 	maxdofspernode=this->MaxNumDofs(analysis_type,setenum);
 	numnodes=this->NumberOfNodes(analysis_type);
-
-	if (numnodes*maxdofspernode){
-		truedofs=(int*)xcalloc(numnodes*maxdofspernode,sizeof(int)); //initialize to 0, so that we can pick up the max
+	if(numnodes*maxdofspernode){
+		truedofs=   (int*)xcalloc(numnodes*maxdofspernode,sizeof(int)); //initialize to 0, so that we can pick up the max
 		alltruedofs=(int*)xcalloc(numnodes*maxdofspernode,sizeof(int));
 	}
 
 	for (i=0;i<this->Size();i++){
-		/*Check that this node corresponds to our analysis currently being carried out: */
 		Node* node=(Node*)this->GetObjectByOffset(i);
 		if (node->InAnalysis(analysis_type)){
@@ -130,13 +119,11 @@
 		}
 	}
-
 	MPI_Allreduce ( (void*)truedofs,(void*)alltruedofs,numnodes*maxdofspernode,MPI_INT,MPI_MAX,MPI_COMM_WORLD);
 
-	/*Ok, now every cpu knows the true dofs of everyone else that is not a clone. Let the clones recover those true dofs: */
+	/* Now every cpu knows the true dofs of everyone else that is not a clone*/
 	for (i=0;i<this->Size();i++){
-		/*Check that this node corresponds to our analysis currently being carried out: */
-		Node* node=(Node*)this->GetObjectByOffset(i);
-		if (node->InAnalysis(analysis_type)){
-			node->UpdateCloneDofs(alltruedofs,maxdofspernode,setenum); //give maxdofspernode, column size, so that nodes can index into alltruedofs
+		Node* node=(Node*)this->GetObjectByOffset(i);
+		if (node->InAnalysis(analysis_type)){
+			node->UpdateCloneDofs(alltruedofs,maxdofspernode,setenum);
 		}
 	}
@@ -146,6 +133,4 @@
 	xfree((void**)&truedofs);
 	xfree((void**)&alltruedofs);
-
-
 }
 /*}}}*/
