Index: /issm/trunk/src/c/ModelProcessorx/Partitioning.cpp
===================================================================
--- /issm/trunk/src/c/ModelProcessorx/Partitioning.cpp	(revision 3548)
+++ /issm/trunk/src/c/ModelProcessorx/Partitioning.cpp	(revision 3549)
@@ -213,4 +213,5 @@
 	/*Get edges and elements*/
 	IoModelFetchData(&iomodel->edges,&iomodel->numberofedges,NULL,iomodel_handle,"edges");
+	IoModelFetchData(&iomodel->elements,NULL,NULL,iomodel_handle,"elements");
 
 	/*!All elements have been partitioned above, only create elements for this CPU: */
@@ -233,18 +234,31 @@
 
 			/*2: Get the column where these ids are located in the index*/
-			pos==UNDEF;
+			pos=UNDEF;
 			for(j=0;j<3;j++){
-				if (iomodel->elements[3*(int)e2+j]==i1) pos=j+1;
-			}
-			ISSMASSERT(pos!=UNDEF);
+				if ((int)iomodel->elements[3*(int)e2+j]==i1) pos=j;
+			}
 
 			/*3: We have the id of the elements and the position of the vertices in the index
 			 * we can now create the corresponding nodes:*/
-			my_nodes[(int)e2*3+pos-1]=1;
-			my_nodes[(int)e2*3+((pos+1)%3)]=1;
+			if (pos==0){
+				my_nodes[(int)e2*3+0]=1;
+				my_nodes[(int)e2*3+2]=1;
+			}
+			else if(pos==1){
+				my_nodes[(int)e2*3+1]=1;
+				my_nodes[(int)e2*3+0]=1;
+			}
+			else if (pos==2){
+				my_nodes[(int)e2*3+2]=1;
+				my_nodes[(int)e2*3+1]=1;
+			}
+			else{
+				ISSMERROR("Problem in edges creation");
+			}
 		}
 	}
 
 	/*Free data: */
+	xfree((void**)&iomodel->elements);
 	xfree((void**)&iomodel->edges);
 
Index: /issm/trunk/src/c/ModelProcessorx/Prognostic2/CreateLoadsPrognostic2.cpp
===================================================================
--- /issm/trunk/src/c/ModelProcessorx/Prognostic2/CreateLoadsPrognostic2.cpp	(revision 3548)
+++ /issm/trunk/src/c/ModelProcessorx/Prognostic2/CreateLoadsPrognostic2.cpp	(revision 3549)
@@ -47,15 +47,14 @@
 		/*Create load*/
 		numericalflux_id=i+1; //Matlab indexing
+		numericalflux_elem_id=(int)e1+1;//id is in matlab index
+
+		/*1: Get vertices ids*/
+		i1=(int)iomodel->edges[4*i+0];
+		i2=(int)iomodel->edges[4*i+1];
 
 		if (!isnan(e2)){
 			strcpy(numericalflux_type,"internal");
 
-			numericalflux_elem_id=(int)e1+1;//id is in matlab index
-
 			/*Now, we must get the nodes of the 4 nodes located on the edge*/
-
-			/*1: Get vertices ids*/
-			i1=(int)iomodel->edges[4*i+0];
-			i2=(int)iomodel->edges[4*i+1];
 
 			/*2: Get the column where these ids are located in the index*/
@@ -76,10 +75,4 @@
 		else{
 			strcpy(numericalflux_type,"boundary");
-
-			numericalflux_elem_id=(int)e1+1;
-
-			/*1: Get vertices ids*/
-			i1=(int)iomodel->edges[4*i+0];
-			i2=(int)iomodel->edges[4*i+1];
 
 			/*2: Get the column where these ids are located in the index*/
