Index: /issm/trunk-jpl/src/c/Container/DataSet.h
===================================================================
--- /issm/trunk-jpl/src/c/Container/DataSet.h	(revision 14677)
+++ /issm/trunk-jpl/src/c/Container/DataSet.h	(revision 14678)
@@ -4,5 +4,4 @@
 #include <vector>
 #include "../classes/objects/Object.h"
-#include "../toolkits/toolkits.h"
 #include "../EnumDefinitions/EnumDefinitions.h"
 
Index: /issm/trunk-jpl/src/c/Makefile.am
===================================================================
--- /issm/trunk-jpl/src/c/Makefile.am	(revision 14677)
+++ /issm/trunk-jpl/src/c/Makefile.am	(revision 14678)
@@ -53,4 +53,5 @@
 					./classes/IoModel.h\
 					./classes/IoModel.cpp\
+					./classes/objects/Bucket.h\
 					./classes/objects/Node.h\
 					./classes/objects/Node.cpp\
Index: /issm/trunk-jpl/src/c/classes/objects/Bucket.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/objects/Bucket.h	(revision 14678)
+++ /issm/trunk-jpl/src/c/classes/objects/Bucket.h	(revision 14678)
@@ -0,0 +1,85 @@
+/*!\file Bucket.h
+ * \brief: header file for Bucket object
+ */
+
+#ifndef _BUCKET_H
+#define _BUCKET_H
+
+/*Headers:*/
+/*{{{*/
+#include "./Object.h"
+#include "../../shared/Alloc/alloc.h"
+/*}}}*/
+
+template <class doubletype> class Bucket: public Object{
+
+	private: 
+		int m,n; /*size of local matrix we are storing*/
+		/*row and column indices of the matrix we are storing*/
+		int* idxm;
+		int* idxn; 
+		doubletype* values; /*local matrix*/
+		InsMode mode; /*mode of insertion for this bucket*/
+
+	public: 
+	
+		/*constructors, destructors: */
+		Bucket(int min,int* idxmin,int nin,int* idxnin,doubletype* valuesin,InsMode modein){ /*{{{*/
+			this->m=min;
+			this->n=nin;
+			this->mode=modein;
+			if(this->m){
+				this->idxm=xNew<int>(this->m); 
+				xMemCpy(this->idxm,idxmin,this->m);
+			}
+			if(this->n){
+				this->idxn=xNew<int>(this->n); 
+				xMemCpy(this->idxn,idxnin,this->n);
+			}
+			if(this->m*this->n){
+				this->values=xNew<doubletype>(this->n*this->m);
+				xMemCpy(this->values,valuesin,this->n*this->m);
+			}
+		} /*}}}*/
+		~Bucket(){ /*{{{*/
+			xDelete<int>(idxm);
+			xDelete<int>(idxn);
+			xDelete<doubletype>(values);
+		} /*}}}*/
+
+		/*object virtual functions definitions:*/
+		void    Echo(){ /*{{{*/
+			printf("Bucket echo (cpu #: %i): \n",IssmComm::GetRank());
+			printf("# rows: %i, #cols: %i\n",this->m,this->n);
+		} /*}}}*/
+		void    DeepEcho(){ /*{{{*/
+			int i,j;
+
+			printf("Bucket echo (cpu #: %i): \n",IssmComm::GetRank());
+			printf("# rows: %i, #cols: %i\n",this->m,this->n);
+			for (i=0;i<this->m;i++){
+				printf("row %i, column indices: ",this->idxm[i]);
+				for (j=0;j<this->n;j++){
+					printf(" %i",this->idxn[j]);
+				}
+				printf("\n");
+				printf("values: ");
+				for (j=0;j<this->n;j++){
+					printf(" %i",this->values[m*i+j]);
+				}
+				printf("\n");
+			}
+		}
+		/*}}}*/
+		int     Id(){ /*{{{*/
+			return -1;
+		} /*}}}*/
+		int     ObjectEnum(){ /*{{{*/
+			return -1;
+		} /*}}}*/
+		Object *copy()        {/*{{{*/
+			_error_("Not implemented yet (similar to Elements)"); };
+		/*}}}*/
+};
+
+#endif  /* _BUCKET_H */
Index: /issm/trunk-jpl/src/c/classes/objects/Options/GenericOption.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/objects/Options/GenericOption.h	(revision 14677)
+++ /issm/trunk-jpl/src/c/classes/objects/Options/GenericOption.h	(revision 14678)
@@ -17,4 +17,6 @@
 #include "../../../include/include.h"
 #include "../../../shared/Exceptions/exceptions.h"
+#include "../../../shared/Alloc/alloc.h"
+#include "../../../shared/MemOps/xMemCpy.h"
 #include "../../../io/io.h"
 #include "../../../EnumDefinitions/EnumDefinitions.h"
Index: /issm/trunk-jpl/src/c/classes/objects/objects.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/objects/objects.h	(revision 14677)
+++ /issm/trunk-jpl/src/c/classes/objects/objects.h	(revision 14678)
@@ -17,4 +17,5 @@
 #include "./IndependentObject.h"
 #include "./Segment.h"
+#include "./Bucket.h"
 
 /*Constraints: */
Index: /issm/trunk-jpl/src/c/toolkits/issm/IssmMpiDenseMat.h
===================================================================
--- /issm/trunk-jpl/src/c/toolkits/issm/IssmMpiDenseMat.h	(revision 14677)
+++ /issm/trunk-jpl/src/c/toolkits/issm/IssmMpiDenseMat.h	(revision 14678)
@@ -22,4 +22,7 @@
 #include "../../shared/Alloc/alloc.h"
 #include "../../include/macros.h"
+#include "../../Container/DataSet.h"
+#include "../../classes/IssmComm.h"
+#include "../../classes/objects/Bucket.h"
 #include <math.h>
 
@@ -38,41 +41,84 @@
 	public:
 
-		int M,N; 
+		int M,N;  //global size
+		int m;    //local number of rows
 		doubletype* matrix;  /*here, doubletype is either IssmDouble or IssmPDouble*/
+		DataSet*    buckets;  /*here, we store buckets of values that we will Assemble into a global matrix.*/
 
 		/*IssmMpiDenseMat constructors, destructors*/
 		/*FUNCTION IssmMpiDenseMat(){{{*/
 		IssmMpiDenseMat(){
-			_error_("not supported yet!");
+			this->M=0;
+			this->N=0;
+			this->m=0;
+			this->matrix=NULL;
+			this->buckets=new DataSet();
 		}
 		/*}}}*/
 		/*FUNCTION IssmMpiDenseMat(int M,int N){{{*/
-		IssmMpiDenseMat(int pM,int pN){
-			_error_("not supported yet!");
+		IssmMpiDenseMat(int Min,int Nin){
+			this->Init(Min,Nin);
 		}
 		/*}}}*/
 		/*FUNCTION IssmMpiDenseMat(int M,int N, doubletype sparsity){{{*/
 		IssmMpiDenseMat(int pM,int pN, doubletype sparsity){
-			_error_("not supported yet!");
+			/*no sparsity involved here, we are fully dense, so just use the previous constructor: */
+			this->Init(pM,pN);
 		}
 		/*}}}*/
 		/*FUNCTION IssmMpiDenseMat(int m,int n,int M,int N,int* d_nnz,int* o_nnz){{{*/
 		IssmMpiDenseMat(int m,int n,int pM,int pN,int* d_nnz,int* o_nnz){
-			_error_("not supported yet!");
+			/*not needed, we are fully dense!: */
+			this->Init(pM,pN);
 		}
 		/*}}}*/
 		/*FUNCTION IssmMpiDenseMat(doubletype* serial_mat,int M,int N,doubletype sparsity){{{*/
-		IssmMpiDenseMat(doubletype* serial_mat,int pM,int pN,doubletype sparsity){
-			_error_("not supported yet!");
+		IssmMpiDenseMat(doubletype* serial_mat,int Min,int Nin,doubletype sparsity){
+			
+			/*Here, we assume that the serial_mat is local to the local cpu, and that it has 
+			 * the correct size (m rows by N colums), n determined by DetermineLocalSize: */
+			this->buckets=new DataSet();
+			this->M=Min;
+			this->N=Nin;
+			this->m=DetermineLocalSize(this->M,IssmComm::GetComm());
+
+			this->matrix=NULL;
+			if(m*N){
+				this->matrix=xNewZeroInit<doubletype>(m*N);
+				xMemCpy<doubletype>(this->matrix,serial_mat,m*N);
+			}
 		}
 		/*}}}*/
 		/*FUNCTION IssmMpiDenseMat(int M,int N, int connectivity, int numberofdofspernode){{{*/
 		IssmMpiDenseMat(int pM,int pN, int connectivity,int numberofdofspernode){
-			_error_("not supported yet!");
+			/*not needed, we are fully dense!: */
+			this->Init(pM,pN);
 		}
 		/*}}}*/
 		/*FUNCTION ~IssmMpiDenseMat(){{{*/
 		~IssmMpiDenseMat(){
-			_error_("not supported yet!");
+			xDelete<doubletype>(this->matrix);
+			M=0;
+			N=0;
+			m=0;
+			delete this->buckets;
+		}
+		/*}}}*/
+		/*FUNCTION IssmMpiDenseMat::Init(int Min,int Nin){{{*/
+		void Init(int Min,int Nin){
+
+			this->buckets=new DataSet();
+			
+			this->M=Min;
+			this->N=Nin;
+			
+			/*Figure out local number of rows: */
+			this->m=DetermineLocalSize(this->M,IssmComm::GetComm());
+			
+			/*Initialize pointer: */
+			this->matrix=NULL;
+
+			/*Allocate: */
+			if (m*N)this->matrix=xNewZeroInit<doubletype>(this->m*N);
 		}
 		/*}}}*/
@@ -81,5 +127,23 @@
 		/*FUNCTION Echo{{{*/
 		void Echo(void){
-			_error_("not supported yet!");
+
+			int my_rank;
+			int i,j,k;
+
+			/*Do a synchronized dump across all the rows: */
+			my_rank=IssmComm::GetRank();
+			for(i=0;i<IssmComm::GetSize();i++){
+				if (my_rank==i){
+					printf("cpu %i #rows: %i\n",i,this->m);
+					for (j=0;j<this->m;j++){
+						printf("row %i ",j);
+						for (k=0;k<this->N;k++){
+							printf("%g ",this->matrix[j*this->N+k]);
+						}
+					}
+				}
+				MPI_Barrier(IssmComm::GetComm());
+			}
+
 		}
 		/*}}}*/
@@ -120,11 +184,18 @@
 		/*}}}*/
 		/*FUNCTION SetValues{{{*/
-		void SetValues(int m,int* idxm,int n,int* idxn,doubletype* values,InsMode mode){
-			_error_("not supported yet!");
+		void SetValues(int min,int* idxm,int nin,int* idxn,doubletype* values,InsMode mode){
+
+			/*we need to store all the values we collect here in order to Assemble later. 
+			 * Indeed, the values we are collecting here most of the time will not belong 
+			 * to us, but to another part of the matrix on another cpu: */
+			_assert_(buckets);
+
+			buckets->AddObject(new Bucket<doubletype>(min,idxm,nin,idxn,values,mode));
+
 		}
 		/*}}}*/
 		/*FUNCTION Convert{{{*/
 		void Convert(MatrixType type){
-			_error_("not supported yet!");
+			/*do nothing: */
 		}
 		/*}}}*/		
