Index: /issm/trunk/src/c/EnumDefinitions/EnumAsString.cpp
===================================================================
--- /issm/trunk/src/c/EnumDefinitions/EnumAsString.cpp	(revision 4165)
+++ /issm/trunk/src/c/EnumDefinitions/EnumAsString.cpp	(revision 4166)
@@ -126,5 +126,4 @@
 		case RgbEnum : return "Rgb";
 		case SpcEnum : return "Spc";
-		case DofVecEnum : return "DofVec";
 		case GeographyEnum : return "Geography";
 		case IceSheetEnum : return "IceSheet";
Index: /issm/trunk/src/c/EnumDefinitions/EnumDefinitions.h
===================================================================
--- /issm/trunk/src/c/EnumDefinitions/EnumDefinitions.h	(revision 4165)
+++ /issm/trunk/src/c/EnumDefinitions/EnumDefinitions.h	(revision 4166)
@@ -148,6 +148,4 @@
 	/*Spc: */
 	SpcEnum,
-	/*DofVec: */
-	DofVecEnum,
 	/*}}}*/
 	/*Geography {{{1*/
Index: /issm/trunk/src/c/EnumDefinitions/StringAsEnum.cpp
===================================================================
--- /issm/trunk/src/c/EnumDefinitions/StringAsEnum.cpp	(revision 4165)
+++ /issm/trunk/src/c/EnumDefinitions/StringAsEnum.cpp	(revision 4166)
@@ -124,5 +124,4 @@
 	else if (strcmp(name,"Rgb")==0) return RgbEnum;
 	else if (strcmp(name,"Spc")==0) return SpcEnum;
-	else if (strcmp(name,"DofVec")==0) return DofVecEnum;
 	else if (strcmp(name,"Geography")==0) return GeographyEnum;
 	else if (strcmp(name,"IceSheet")==0) return IceSheetEnum;
Index: /issm/trunk/src/c/Makefile.am
===================================================================
--- /issm/trunk/src/c/Makefile.am	(revision 4165)
+++ /issm/trunk/src/c/Makefile.am	(revision 4166)
@@ -81,6 +81,4 @@
 					./objects/FemModel.cpp\
 					./objects/Material.h\
-					./objects/DofVec.h\
-					./objects/DofVec.cpp\
 					./objects/Load.h\
 					./objects/OptArgs.h\
@@ -385,4 +383,5 @@
 					./modules/OutputResultsx/OutputResultsx.cpp\
 					./modules/OutputResultsx/ElementResultsToPatch.cpp\
+					./modules/OutputResultsx/MatlabWriteResults.cpp\
 					./modules/Dux/Dux.h\
 					./modules/Dux/Dux.cpp\
@@ -606,6 +605,4 @@
 					./objects/FemModel.cpp\
 					./objects/Material.h\
-					./objects/DofVec.h\
-					./objects/DofVec.cpp\
 					./objects/Load.h\
 					./objects/SolverEnum.h\
@@ -907,4 +904,5 @@
 					./modules/OutputResultsx/OutputResultsx.cpp\
 					./modules/OutputResultsx/ElementResultsToPatch.cpp\
+					./modules/OutputResultsx/FileWriteResults.cpp\
 					./modules/Dux/Dux.h\
 					./modules/Dux/Dux.cpp\
Index: /issm/trunk/src/c/io/WriteData.cpp
===================================================================
--- /issm/trunk/src/c/io/WriteData.cpp	(revision 4165)
+++ /issm/trunk/src/c/io/WriteData.cpp	(revision 4166)
@@ -97,45 +97,4 @@
 	*pdataref=dataref;
 
-}
-/*}}}*/
-/*FUNCTION WriteData(mxArray** pdataref,DofVec* dofvec){{{1*/
-void WriteData(mxArray** pdataref,DofVec* dofvec){
-	
-	mxArray* mxvector=NULL;
-	mxArray* structdataref=NULL;
-	mxArray* dataref=NULL;
-
-	int nfields=4;
-	const	char*	fnames[nfields];
-	mwSize		onebyone[2] = {1,1};
-	mwSize		ndim=2;
-
-	fnames[0] = "name";
-	fnames[1] = "numdofs";
-	fnames[2] = "numentries";
-	fnames[3] = "vector";
-	
-	if(dofvec){
-		
-		/*call toolkit routine: */
-		if(dofvec->vector)PetscVectorToMatlabVector(&mxvector,dofvec->vector);
-		else mxvector=mxCreateDoubleMatrix(0,0,mxREAL);
-
-		/*use the mxvector to create a dofvec object: */
-		structdataref=mxCreateStructArray( ndim,onebyone,nfields,fnames);
-	
-		mxSetField( structdataref, 0, "name",mxCreateString(dofvec->name));
-		mxSetField( structdataref, 0, "numdofs",mxCreateDoubleScalar(dofvec->numdofs));
-		mxSetField( structdataref, 0, "numentries",mxCreateDoubleScalar(dofvec->numentries));
-		mxSetField( structdataref, 0, "vector",mxvector);
-
-
-		/*transform structure into dofvec class: */
-		mexCallMATLAB( 1, &dataref, 1, &structdataref, "dofvec");
-	}
-	else{
-		dataref = mxCreateDoubleMatrix(0,0,mxREAL);
-	}
-	*pdataref=dataref;
 }
 /*}}}*/
Index: /issm/trunk/src/c/io/io.h
===================================================================
--- /issm/trunk/src/c/io/io.h	(revision 4165)
+++ /issm/trunk/src/c/io/io.h	(revision 4166)
@@ -25,5 +25,4 @@
 void WriteData(mxArray** pdataref,double scalar);
 void WriteData(mxArray** pdataref,char* string);
-void WriteData(mxArray** pdataref,DofVec* vector);
 void WriteData(mxArray** pdataref,BamgMesh* bm);
 void WriteData(mxArray** pdataref,BamgGeom* bg);
Index: /issm/trunk/src/c/modules/OutputResultsx/MatlabWriteResults.cpp
===================================================================
--- /issm/trunk/src/c/modules/OutputResultsx/MatlabWriteResults.cpp	(revision 4165)
+++ /issm/trunk/src/c/modules/OutputResultsx/MatlabWriteResults.cpp	(revision 4166)
@@ -12,33 +12,43 @@
 
 #include <mex.h>
-#include "./io.h"
-#include "../objects/objects.h"
-#include "../shared/shared.h"
-#include "../include/include.h"
+#include "../../io/io.h"
+#include "../../objects/objects.h"
+#include "../../shared/shared.h"
+#include "../../include/include.h"
 
 void  MatlabWriteResults(mxArray** pdataref, Parameters* parameters, DataSet* results){
 
-	extern int  my_rank;
-	char       *filename     = NULL;
-	FILE       *fid          = NULL;
+	int i;
 
-	//Recover file name: 
-	parameters->FindParam(&filename,OutputFileNameEnum);
+	/*output: */
+	mxArray* dataref=NULL;
+	mwSize nfields;
+	const	char**	fnames=NULL;
+	mwSize		onebyone[2] = {1,1};
+	mwSize		ndim=2;
 
-	//Open filename for writing only on cpu 0
-	if(my_rank==0)fid=pfopen(filename,"wb");
+	/*How many results? : */
+	nfields=(mwSize)results->Size();
 
-	for(i=0;i<results->Size();i++){
+	/*recover names: */
+	fnames=(const char**)xmalloc(nfields*sizeof(char*));
+	for(i=0;i<nfields;i++){
 		ExternalResult* result=(ExternalResult*)results->GetObjectByOffset(i);
-
-		/*write result to disk: */
-		result->WriteData(fid);
+		fnames[i]=results->GetResultName();
 	}
 
-	/*Close file: */
-	if(my_rank==0)pfclose(fid,filename);
+	/*Initialize structure: */
+	dataref=mxCreateStructArray( ndim,onebyone,nfields,fnames);
 
-	/*Free ressources:*/
-	xfree((void**)&filename);
+	/*Fill each field: */
+	for(i=0;i<nfields;i++){
+
+		ExternalResult* result=(ExternalResult*)results->GetObjectByOffset(i);
+		result->SetMatlabField(dataref);
+	}
+	
+	/*Assign output pointers:*/
+	*pdataref=dataref;
+
 }
 #endif
Index: /issm/trunk/src/c/modules/OutputResultsx/OutputResultsx.cpp
===================================================================
--- /issm/trunk/src/c/modules/OutputResultsx/OutputResultsx.cpp	(revision 4165)
+++ /issm/trunk/src/c/modules/OutputResultsx/OutputResultsx.cpp	(revision 4166)
@@ -40,7 +40,7 @@
 	/*Write data to matlab structure or filename: */
 	#ifdef _SERIAL_
-		MatlabWriteResults();
+		MatlabWriteResults(pdataref,parameters,results);
 	#else
-		FileWriteResults();
+		FileWriteResults(parameters,results);
 	#endif
 }
Index: /issm/trunk/src/c/modules/OutputResultsx/OutputResultsx.h
===================================================================
--- /issm/trunk/src/c/modules/OutputResultsx/OutputResultsx.h	(revision 4165)
+++ /issm/trunk/src/c/modules/OutputResultsx/OutputResultsx.h	(revision 4166)
@@ -16,13 +16,14 @@
 
 #ifdef _SERIAL_
+#include <mex.h>
 void OutputResultsx(mxArray** pdataref, DataSet* elements, DataSet* loads, DataSet* nodes, DataSet* vertices, DataSet* materials, Parameters* parameters,DataSet* results);
+void MatlabWriteResults(mxArray** pdataref, Parameters* parameters, DataSet* results);
 #else
 void OutputResultsx(DataSet* elements, DataSet* loads, DataSet* nodes, DataSet* vertices, DataSet* materials, Parameters* parameters,DataSet* results);
+void FileWriteResults(Parameters* parameters, DataSet* results);
 #endif
 
 /* local prototypes: */
 void ElementResultsToPatch(DataSet* elements, DataSet* loads, DataSet* nodes, DataSet* vertices, DataSet* materials, Parameters* parameters,DataSet* results);
-void FileWriteResults(Parameters* parameters, DataSet* results);
-void MatlabWriteResults(mxArray** pdataref, Parameters* parameters, DataSet* results);
 
 #endif  /* _OUTPUTRESULTS_H */
Index: sm/trunk/src/c/objects/DofVec.cpp
===================================================================
--- /issm/trunk/src/c/objects/DofVec.cpp	(revision 4165)
+++ 	(revision )
@@ -1,445 +1,0 @@
-/*!\file DofVec.c
- * \brief: implementation of the DofVec object
- */
-
-#ifdef HAVE_CONFIG_H
-	#include "config.h"
-#else
-#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
-#endif
-
-#include "./objects.h"
-#include "../shared/shared.h"
-#include "../include/include.h"
-#include "../EnumDefinitions/EnumDefinitions.h"
-
-/*Object constructors and destructor*/
-/*FUNCTION DofVec::DofVec() {{{1*/
-DofVec::DofVec(){
-	return;
-}
-/*}}}*/
-/*FUNCTION DofVec::DofVec(char* name) {{{1*/
-DofVec::DofVec(char* name){
-
-	strcpy(this->name,name);
-	this->numdofs=0;
-	this->numentries=0;
-	this->vector=NULL;
-
-}
-/*}}}*/
-/*FUNCTION DofVec::DofVec(int total_size,char* name) {{{1*/
-DofVec::DofVec(int total_size,char* name){
-
-	strcpy(this->name,name);
-	this->numdofs=1;
-	this->numentries=total_size;
-	this->vector=NewVec(total_size);
-}
-/*}}}*/
-/*FUNCTION DofVec::DofVec(int total_size,double default_value,char* name) {{{1*/
-DofVec::DofVec(int total_size,double default_value,char* name){
-
-	strcpy(this->name,name);
-	this->numdofs=1;
-	this->numentries=total_size;
-	this->vector=NewVec(total_size);
-	VecSet(this->vector,default_value);
-}
-/*}}}*/
-/*FUNCTION DofVec::DofVec(int dofvec_numdofs,int dofvec_numentries,char* name) {{{1*/
-DofVec::DofVec(int dofvec_numdofs,int dofvec_numentries,char* name){
-
-	strcpy(this->name,name);
-	this->numdofs=dofvec_numdofs;
-	this->numentries=dofvec_numentries;
-	this->vector=NewVec(dofvec_numdofs*dofvec_numentries);
-}
-/*}}}*/
-/*FUNCTION DofVec::DofVec(int dofvec_numdofs,int dofvec_numentries,double default_value,char* name) {{{1*/
-DofVec::DofVec(int dofvec_numdofs,int dofvec_numentries,double default_value,char* name){
-
-	strcpy(this->name,name);
-	this->numdofs=dofvec_numdofs;
-	this->numentries=dofvec_numentries;
-	this->vector=NewVec(dofvec_numdofs*dofvec_numentries);
-	VecSet(this->vector,default_value);
-
-}
-/*}}}*/
-/*FUNCTION DofVec::DofVec(double* serial_vector,int total_size,char* name) {{{1*/
-DofVec::DofVec(double* serial_vector,int total_size,char* name){
-	
-	strcpy(this->name,name);
-	this->numdofs=1;
-	this->numentries=total_size;
-	this->vector=SerialToVec(serial_vector,total_size);
-}
-/*}}}*/
-/*FUNCTION DofVec::DofVec(double* serial_vector,int dofvec_numdofs,int dofvec_numentries,char* name) {{{1*/
-DofVec::DofVec(double* serial_vector,int dofvec_numdofs,int dofvec_numentries,char* name){
-	
-	strcpy(this->name,name);
-	this->numdofs=dofvec_numdofs;
-	this->numentries=dofvec_numentries;
-	this->vector=SerialToVec(serial_vector,dofvec_numdofs*dofvec_numentries);
-}
-/*}}}*/
-/*FUNCTION DofVec::DofVec(Vec vec,char* name) {{{1*/
-DofVec::DofVec(Vec vec,char* name){
-
-	strcpy(this->name,name);
-	this->numdofs=1;
-	VecGetSize(vec,&this->numentries);
-	VecDuplicatePatch(&this->vector,vec);
-	
-}
-/*}}}*/
-/*FUNCTION DofVec::DofVec(Vec vec,int dofvec_numdofs,int dofvec_numentries,char* name) {{{1*/
-DofVec::DofVec(Vec vec,int dofvec_numdofs,int dofvec_numentries,char* name){
-
-	strcpy(this->name,name);
-	this->numdofs=dofvec_numdofs;
-	this->numentries=dofvec_numentries;
-	VecDuplicatePatch(&this->vector,vec);
-}
-/*}}}*/
-/*FUNCTION DofVec::~DofVec {{{1*/
-DofVec::~DofVec(){
-	VecFree(&this->vector);
-}
-/*}}}*/
-
-/*Object management: */
-/*FUNCTION DofVec::copy {{{1*/
-Object* DofVec::copy() {
-
-	DofVec* dofvec=NULL;
-
-	dofvec=new DofVec(*this); 
-
-	/*do the dynamic allocation copy: */
-	VecDuplicatePatch(&dofvec->vector,this->vector);
-
-	return (Object*)dofvec;
-
-}
-/*}}}*/
-/*FUNCTION DofVec::DeepEcho {{{1*/
-void DofVec::DeepEcho(void){
-
-	printf("DofVec:\n");
-	printf("   name: %s\n",this->name);
-	printf("   numdofs: %i\n",this->numdofs);
-	printf("   numentries: %i\n",this->numentries);
-	printf("   totalsize: %i\n",this->numdofs*this->numentries);
-	if(this->vector)VecView(this->vector,PETSC_VIEWER_STDOUT_WORLD);
-}
-/*}}}*/
-/*FUNCTION DofVec::Demarshall {{{1*/
-void  DofVec::Demarshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   i;
-	double* serial_vector=NULL;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*this time, no need to get enum type, the pointer directly points to the beginning of the 
-	 *object data (thanks to DataSet::Demarshall):*/
-
-	memcpy(&name,marshalled_dataset,sizeof(name));marshalled_dataset+=sizeof(name);
-	memcpy(&numdofs,marshalled_dataset,sizeof(numdofs));marshalled_dataset+=sizeof(numdofs);
-	memcpy(&numentries,marshalled_dataset,sizeof(numentries));marshalled_dataset+=sizeof(numentries);
-
-	serial_vector=(double*)xmalloc(this->numentries*this->numdofs*sizeof(double));
-	memcpy(serial_vector,marshalled_dataset,this->numentries*this->numdofs*sizeof(double));marshalled_dataset+=this->numentries*this->numdofs*sizeof(double);
-
-	this->vector=SerialToVec(serial_vector,this->numentries*this->numdofs);
-
-	/*Free ressources:*/
-	xfree((void**)&serial_vector);
-
-	/*return: */
-	*pmarshalled_dataset=marshalled_dataset;
-	return;
-}
-/*}}}*/
-/*FUNCTION DofVec::Echo {{{1*/
-void DofVec::Echo(void){
-
-	printf("DofVec:\n");
-	printf("   name: %s\n",this->name);
-	printf("   numdofs: %i\n",this->numdofs);
-	printf("   numentries: %i\n",this->numentries);
-	printf("   totalsize: %i\n",this->numentries*this->numdofs);
-	printf("   vector: %p\n",this->vector);
-
-}
-/*}}}*/
-/*FUNCTION DofVec::Marshall {{{1*/
-void  DofVec::Marshall(char** pmarshalled_dataset){
-
-	char* marshalled_dataset=NULL;
-	int   enum_type=0;
-	double* serial_vector=NULL;
-
-	/*recover marshalled_dataset: */
-	marshalled_dataset=*pmarshalled_dataset;
-
-	/*get enum type of DofVec: */
-	enum_type=DofVecEnum;
-	
-	/*marshall enum: */
-	memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
-	
-	/*marshall DofVec data: */
-	memcpy(marshalled_dataset,&name,sizeof(name));marshalled_dataset+=sizeof(name);
-	memcpy(marshalled_dataset,&numdofs,sizeof(numdofs));marshalled_dataset+=sizeof(numdofs);
-	memcpy(marshalled_dataset,&numentries,sizeof(numentries));marshalled_dataset+=sizeof(numentries);
-
-	/*Serialize vector before marshalling it: */
-	VecToMPISerial(&serial_vector,this->vector);
-	
-	memcpy(marshalled_dataset,serial_vector,this->numentries*this->numdofs*sizeof(double));marshalled_dataset+=this->numentries*this->numdofs*sizeof(double);
-
-	/*Free ressources: */
-	xfree((void**)&serial_vector);
-	
-	*pmarshalled_dataset=marshalled_dataset;
-	return;
-}
-/*}}}*/
-/*FUNCTION DofVec::MarshallSize {{{1*/
-int   DofVec::MarshallSize(){
-	return sizeof(name)
-		+sizeof(numdofs)
-		+sizeof(numentries)
-		+this->numentries*this->numdofs*sizeof(double)
-		+sizeof(int); //sizeof(int) for enum type
-}
-/*}}}*/
-
-/*Object functions*/
-/*FUNCTION DofVec::Enum {{{1*/
-int DofVec::Enum(void){
-
-	return DofVecEnum;
-
-}
-/*}}}*/
-/*FUNCTION DofVec::Id {{{1*/
-int DofVec::Id(void){ 
-	ISSMERROR(" no id function for DofVec class");
-}
-
-/*FUNCTION DofVec::GetVec {{{1*/
-Vec     DofVec::GetVec(void){
-	return vector;
-}
-/*}}}*/
-/*FUNCTION DofVec::GetVecFromDof(double** pvector,int dof) {{{1*/
-void DofVec::GetVecFromDof(double** pvector,int dof){
-
-	double* dofset=NULL;
-	double* serial_vector=NULL;
-	Vec     vector=NULL;
-
-	
-	/*check we are not out of bounds: */
-	if (dof>=numdofs){
-		ISSMERROR("%s%i%s%i\n"," error message: dof ",dof," requested is out of bounds for vector with number of dofs",this->numdofs);
-	}
-
-	dofset=dofsetgen(1,&dof,this->numdofs,this->numdofs*this->numentries);
-	VecPartition(&vector, this->vector, dofset, this->numdofs*this->numentries);
-
-	VecToMPISerial(&serial_vector,vector);
-
-	/*Free ressources:*/
-	VecFree(&vector);
-	xfree((void**)&dofset);
-
-	/*Assign output pointers:*/
-	*pvector=serial_vector;
-}
-/*}}}*/
-/*FUNCTION DofVec::GetVecFromDof(Vec* pvector, int dof) {{{1*/
-void DofVec::GetVecFromDof(Vec* pvector, int dof){
-
-	double* dofset=NULL;
-	Vec     vector=NULL;
-
-	
-	/*check we are not out of bounds: */
-	if (dof>=numdofs){
-		ISSMERROR("%s%i%s%i\n"," error message: dof ",dof," requested is out of bounds for vector with number of dofs",this->numdofs);
-	}
-
-	dofset=dofsetgen(1,&dof,this->numdofs,this->numdofs*this->numentries);
-	VecPartition(&vector, this->vector, dofset, this->numdofs*this->numentries);
-
-	/*Free ressources:*/
-	xfree((void**)&dofset);
-
-	/*Assign output pointers:*/
-	*pvector=vector;
-}
-/*}}}*/
-/*FUNCTION DofVec::GetVecFromDofList(double** pvector, int requested_numdofs,int* requested_doflist) {{{1*/
-void DofVec::GetVecFromDofList(double** pvector, int requested_numdofs,int* requested_doflist){
-
-	int i;
-	double* dofset=NULL;
-	double* serial_vector=NULL;
-	Vec     vector=NULL;
-	
-	/*check we are not out of bounds: */
-	if (requested_numdofs>=this->numdofs) ISSMERROR("%s%i%s%i\n"," error message: requested dof list has size  ",requested_numdofs," which is out of bounds for vector with number of dofs",this->numdofs);
-
-	for(i=0;i<requested_numdofs;i++){
-		if (requested_doflist[i]>=this->numdofs)ISSMERROR("%s%i%s%i\n"," error message: requested dof   ",requested_doflist[i]," in list, is out of bounds for vector with number of dofs",this->numdofs);
-	}
-
-	
-	dofset=dofsetgen(requested_numdofs,requested_doflist,this->numdofs,this->numdofs*this->numentries);
-	VecPartition(&vector, this->vector, dofset, this->numdofs*this->numentries);
-
-	VecToMPISerial(&serial_vector,vector);
-
-	/*Free ressources:*/
-	VecFree(&vector);
-	xfree((void**)&dofset);
-
-
-	/*Assign output pointers:*/
-	*pvector=serial_vector;
-}
-/*}}}*/
-/*FUNCTION DofVec::GetVecFromDofList(Vec* pvector, int requested_numdofs,int* requested_doflist) {{{1*/
-void DofVec::GetVecFromDofList(Vec* pvector, int requested_numdofs,int* requested_doflist){
-
-	int i;
-	double* dofset=NULL;
-	Vec     vector=NULL;
-	
-	/*check we are not out of bounds: */
-	if (requested_numdofs>=this->numdofs) ISSMERROR("%s%i%s%i\n"," error message: requested dof list has size  ",requested_numdofs," which is out of bounds for vector with number of dofs",this->numdofs);
-
-	for(i=0;i<requested_numdofs;i++){
-		if (requested_doflist[i]>=this->numdofs)ISSMERROR("%s%i%s%i\n"," error message: requested dof   ",requested_doflist[i]," in list, is out of bounds for vector with number of dofs",this->numdofs);
-	}
-
-	
-	dofset=dofsetgen(requested_numdofs,requested_doflist,this->numdofs,this->numdofs*this->numentries);
-	VecPartition(&vector, this->vector, dofset, this->numdofs*this->numentries);
-
-
-	/*Free ressources:*/
-	xfree((void**)&dofset);
-
-	/*Assign output pointers:*/
-	*pvector=vector;
-}
-/*}}}*/
-/*FUNCTION DofVec::SetValuesFromVecAndDofList(double* serial_vector,int vector_size,int requested_numdofs,int* requested_doflist) {{{1*/
-void DofVec::SetValuesFromVecAndDofList(double* serial_vector,int vector_size,int requested_numdofs,int* requested_doflist){
-
-	double* dofset=NULL;
-	Vec     vector=NULL;
-
-	/*First thing, is the vector of the right size? :*/
-	if (vector_size!=requested_numdofs*this->numentries)ISSMERROR("%s%i%s%i"," error message: input vector size ",vector_size," is not equal to the expected numdofs*numentries",requested_numdofs*this->numentries);
-
-	/*Create dofset: */
-	dofset=dofsetgen(requested_numdofs,requested_doflist,this->numdofs,this->numdofs*this->numentries);
-
-	/*Make a parallel vector out of the serial input vector: */
-	vector=SerialToVec(serial_vector,vector_size);
-	
-	/*Merge vector into this->vector: */
-	VecMerge(this->vector,vector,dofset,vector_size);
-
-	/*Free ressources:*/
-	xfree((void**)&dofset);
-	VecFree(&vector);
-}
-/*}}}*/
-/*FUNCTION DofVec::SetValuesFromVecAndDofList(Vec vector,int requested_numdofs,int* requested_doflist) {{{1*/
-void DofVec::SetValuesFromVecAndDofList(Vec vector,int requested_numdofs,int* requested_doflist){
-
-	double* dofset=NULL;
-	int    vector_size;
-
-	VecGetSize(vector,&vector_size);
-
-	/*First thing, is the vector of the right size? :*/
-	if (vector_size!=requested_numdofs*this->numentries)ISSMERROR("%s%i%s%i"," error message: input vector size ",vector_size," is not equal to the expected numdofs*numentries",requested_numdofs*this->numentries);
-
-	/*Create dofset: */
-	dofset=dofsetgen(requested_numdofs,requested_doflist,this->numdofs,this->numdofs*this->numentries);
-
-	/*Merge vector into this->vector: */
-	VecMerge(this->vector,vector,dofset,vector_size);
-
-	/*Free ressources:*/
-	xfree((void**)&dofset);
-}
-/*}}}*/
-/*FUNCTION DofVec::SetValuesFromVecAndDofList(DofVec* vector,int requested_numdofs,int* requested_doflist) {{{1*/
-void DofVec::SetValuesFromVecAndDofList(DofVec* vector,int requested_numdofs,int* requested_doflist){
-
-	double* dofset=NULL;
-	int    vector_size;
-
-	vector_size=vector->Size();
-
-	/*First thing, is the vector of the right size? :*/
-	if (vector_size!=requested_numdofs*this->numentries)ISSMERROR("%s%i%s%i"," error message: input vector size ",vector_size," is not equal to the expected numdofs*numentries",requested_numdofs*this->numentries);
-
-	/*Create dofset: */
-	dofset=dofsetgen(requested_numdofs,requested_doflist,this->numdofs,this->numdofs*this->numentries);
-
-	/*Merge vector into this->vector: */
-	VecMerge(this->vector,vector->GetVec(),dofset,vector_size);
-
-	/*Free ressources:*/
-	xfree((void**)&dofset);
-}
-/*}}}*/
-/*FUNCTION DofVec::GetValuesFromIndex {{{1*/
-double* DofVec::GetValuesFromIndex(int index_size,int* index){
-
-	double* values=NULL;
-	double* serial_vector=NULL;
-	int i;
-
-	/*Serialize vector first, then allocate a buffer and fill it with the correct 
-	 * values: */
-	VecToMPISerial(&serial_vector,this->vector);
-
-	values=(double*)xmalloc(index_size*sizeof(double));
-	for(i=0;i<index_size;i++){
-		values[i]=serial_vector[index[i]];
-	}
-
-	/*Free ressources:*/
-	xfree((void**)&serial_vector);
-
-	return values;
-}
-/*}}}*/
-/*FUNCTION DofVec::MyRank {{{1*/
-int    DofVec::MyRank(void){ 
-
-	extern int my_rank;
-	return my_rank; 
-}
-
-/*FUNCTION DofVec::Size {{{1*/
-int DofVec::Size(){
-	return this->numdofs*this->numentries;
-}
-/*}}}*/
Index: sm/trunk/src/c/objects/DofVec.h
===================================================================
--- /issm/trunk/src/c/objects/DofVec.h	(revision 4165)
+++ 	(revision )
@@ -1,72 +1,0 @@
-/*! \file DovVec.h 
- *  \brief: header file for dofvec object
- */
-
-#ifndef _DOFVEC_H_
-#define _DOFVEC_H_
-
-/*Headers:*/
-/*{{{1*/
-#include "./Object.h"
-#include "../toolkits/toolkits.h"
-
-#define DOFVECNAMESIZE 20
-/*}}}*/
-
-
-class DofVec: public Object{
-	
-	public:
-
-		char name[DOFVECNAMESIZE];
-		int numdofs; //number  of dofs per entry.
-		int numentries; //number of entries
-		Vec vector; //vector itself.
-
-
-		DofVec();
-		DofVec(char* name);
-		DofVec(int total_size,char* name); //default numdofs=1, numentries=total_size, default_value=0;
-		DofVec(int total_size,double default_value,char* name); //default numdofs=1, numentries=total_size
-		DofVec(int numdofs,int numentries,char* name);  //default_value=0;
-		DofVec(int numdofs,int numentries,double default_value,char* name); 
-		DofVec(double* serial_vector,int size,char* name); //default numdofs=1;
-		DofVec(double* serial_vector,int numdofs,int numentries,char* name);
-		DofVec(Vec vec,char* name); //default numdofs=1;
-		DofVec(Vec vec,int numdofs,int numentries,char* name); 
-
-		~DofVec();
-
-		void  Echo();
-		void  DeepEcho();
-		void  Marshall(char** pmarshalled_dataset);
-		int   MarshallSize();
-		void  Demarshall(char** pmarshalled_dataset);
-		int   Enum();
-		int   Id(); 
-		int   MyRank();
-		int   Size();
-		void    InputUpdateFromVector(double* vector, int name, int type){ISSMERROR("Not implemented yet!");}
-		void    InputUpdateFromVector(bool* vector, int name, int type){ISSMERROR("Not implemented yet!");}
-		void    InputUpdateFromVector(int* vector, int name, int type){ISSMERROR("Not implemented yet!");}
-		void    InputUpdateFromConstant(double constant, int name){ISSMERROR("Not implemented yet!");}
-		void    InputUpdateFromConstant(int constant, int name){ISSMERROR("Not implemented yet!");}
-		void    InputUpdateFromConstant(bool constant, int name){ISSMERROR("Not implemented yet!");}
-		void    InputUpdateFromSolution(double* solution){ISSMERROR("Not implemented yet!");}
-		Object* copy();
-
-		Vec     GetVec(void);
-		void    GetVecFromDof(double** pvector,int dof);
-		void    GetVecFromDof(Vec* vector,int dof);
-		void    GetVecFromDofList(double** pvector, int numdofs,int* doflist);
-		void    GetVecFromDofList(Vec* pvector, int numdofs,int* doflist);
-		
-		void    SetValuesFromVecAndDofList(double* vector,int vector_size,int numdofs,int* doflist);
-		void    SetValuesFromVecAndDofList(Vec vector,int numdofs,int* doflist);
-		void    SetValuesFromVecAndDofList(DofVec* vector,int numdofs,int* doflist);
-		
-		double* GetValuesFromIndex(int index_size,int* index);
-				
-
-};
-#endif  /* _DOFVEC_H */
Index: /issm/trunk/src/c/objects/ExternalResults/BoolExternalResult.cpp
===================================================================
--- /issm/trunk/src/c/objects/ExternalResults/BoolExternalResult.cpp	(revision 4165)
+++ /issm/trunk/src/c/objects/ExternalResults/BoolExternalResult.cpp	(revision 4166)
@@ -177,2 +177,17 @@
 }
 /*}}}1*/
+/*FUNCTION BoolExternalResult::GetResultName(void); {{{1*/
+char* BoolExternalResult::GetResultName(void){
+	return  EnumAsString(this->enum_type);
+}
+/*}}}*/
+/*FUNCTION BoolExternalResult::SetMatlabField(mxArray* dataref);{{{1*/
+#ifdef _SERIAL_
+char* BoolExternalResult::SetMatlabField(mxArray* dataref){
+
+	char* name=NULL;
+	name=this->GetResultName();
+	mxSetField( dataref, 0, name,mxCreateDoubleScalar((double)value));
+}
+#endif
+/*}}}*/
Index: /issm/trunk/src/c/objects/ExternalResults/BoolExternalResult.h
===================================================================
--- /issm/trunk/src/c/objects/ExternalResults/BoolExternalResult.h	(revision 4165)
+++ /issm/trunk/src/c/objects/ExternalResults/BoolExternalResult.h	(revision 4166)
@@ -66,4 +66,8 @@
 		int   EnumType(){return enum_type;}
 		void  WriteData(FILE* fid);
+		char* GetResultName(void);
+	    #ifdef _SERIAL_
+		void  SetMatlabField(mxArray* dataref);
+		#endif
 		/*}}}*/
 };
Index: /issm/trunk/src/c/objects/ExternalResults/DoubleExternalResult.cpp
===================================================================
--- /issm/trunk/src/c/objects/ExternalResults/DoubleExternalResult.cpp	(revision 4165)
+++ /issm/trunk/src/c/objects/ExternalResults/DoubleExternalResult.cpp	(revision 4166)
@@ -173,2 +173,17 @@
 }
 /*}}}1*/
+/*FUNCTION DoubleExternalResult::GetResultName(void); {{{1*/
+char* DoubleExternalResult::GetResultName(void){
+	return  EnumAsString(this->enum_type);
+}
+/*}}}*/
+/*FUNCTION DoubleExternalResult::SetMatlabField(mxArray* dataref);{{{1*/
+#ifdef _SERIAL_
+char* DoubleExternalResult::SetMatlabField(mxArray* dataref){
+
+	char* name=NULL;
+	name=this->GetResultName();
+	mxSetField( dataref, 0, name,mxCreateDoubleScalar(value));
+}
+#endif
+/*}}}*/
Index: /issm/trunk/src/c/objects/ExternalResults/DoubleExternalResult.h
===================================================================
--- /issm/trunk/src/c/objects/ExternalResults/DoubleExternalResult.h	(revision 4165)
+++ /issm/trunk/src/c/objects/ExternalResults/DoubleExternalResult.h	(revision 4166)
@@ -66,4 +66,8 @@
 		int   EnumType(){return enum_type;}
 		void  WriteData(FILE* fid);
+		char* GetResultName(void);
+		#ifdef _SERIAL_
+		void  SetMatlabField(mxArray* dataref);
+		#endif
 		/*}}}*/
 };
Index: /issm/trunk/src/c/objects/ExternalResults/DoubleMatExternalResult.cpp
===================================================================
--- /issm/trunk/src/c/objects/ExternalResults/DoubleMatExternalResult.cpp	(revision 4165)
+++ /issm/trunk/src/c/objects/ExternalResults/DoubleMatExternalResult.cpp	(revision 4166)
@@ -199,2 +199,39 @@
 }
 /*}}}1*/
+/*FUNCTION DoubleMatExternalResult::GetResultName(void); {{{1*/
+char* DoubleMatExternalResult::GetResultName(void){
+	return  EnumAsString(this->enum_type);
+}
+/*}}}*/
+/*FUNCTION DoubleMatExternalResult::SetMatlabField(mxArray* dataref);{{{1*/
+#ifdef _SERIAL_
+char* DoubleMatExternalResult::SetMatlabField(mxArray* dataref){
+
+	mxArray* pfield=NULL;
+	mxArray* pfield2=NULL;
+	double* doublemat=NULL;
+	int M,N;
+	char* name=NULL;
+	double* doublemat=NULL;
+
+	/*Make a copy of the value, to be used by matlab: */
+	doublemat=(double*)xmalloc(M*N*sizeof(double));
+	memcpy(doublemat,values,M*N*sizeof(double));
+
+	/*recover name: */
+	name=this->GetResultName();
+				
+	/*create matlab matrix: */
+	pfield=mxCreateDoubleMatrix(0,0,mxREAL);
+	mxSetM(pfield,N);
+	mxSetN(pfield,M);
+	mxSetPr(pfield,doublemat);
+	
+	/*transpose the matrix, from c to matlab format */
+	mexCallMATLAB(1,&pfield2, 1, &pfield, "'");
+
+	/*set tranpose matrix inside the dataref structure: */
+	mxSetField( dataref, 0, name,pfield2);
+}
+#endif
+/*}}}*/
Index: /issm/trunk/src/c/objects/ExternalResults/DoubleMatExternalResult.h
===================================================================
--- /issm/trunk/src/c/objects/ExternalResults/DoubleMatExternalResult.h	(revision 4165)
+++ /issm/trunk/src/c/objects/ExternalResults/DoubleMatExternalResult.h	(revision 4166)
@@ -66,4 +66,8 @@
 		int   EnumType(){return enum_type;}
 		void  WriteData(FILE* fid);
+		char* GetResultName(void);
+		#ifdef _SERIAL_
+		void  SetMatlabField(mxArray* dataref);
+		#endif
 		/*}}}*/
 };
Index: /issm/trunk/src/c/objects/ExternalResults/DoubleVecExternalResult.cpp
===================================================================
--- /issm/trunk/src/c/objects/ExternalResults/DoubleVecExternalResult.cpp	(revision 4165)
+++ /issm/trunk/src/c/objects/ExternalResults/DoubleVecExternalResult.cpp	(revision 4166)
@@ -195,2 +195,34 @@
 }
 /*}}}1*/
+/*FUNCTION DoubleVecExternalResult::GetResultName(void); {{{1*/
+char* DoubleVecExternalResult::GetResultName(void){
+	return  EnumAsString(this->enum_type);
+}
+/*}}}*/
+/*FUNCTION DoubleVecExternalResult::SetMatlabField(mxArray* dataref);{{{1*/
+#ifdef _SERIAL_
+char* DoubleVecExternalResult::SetMatlabField(mxArray* dataref){
+
+	mxArray* pfield=NULL;
+	double* doublemat=NULL;
+	int M;
+	char* name=NULL;
+	double* doublevec=NULL;
+
+	/*Make a copy of the value, to be used by matlab: */
+	doublevec=(double*)xmalloc(M*sizeof(double));
+	memcpy(doublevec,values,M*sizeof(double));
+
+	/*recover name: */
+	name=this->GetResultName();
+				
+	/*create matlab matrix: */
+	pfield=mxCreateDoubleMatrix(0,0,mxREAL);
+	mxSetM(pfield,M);
+	mxSetN(pfield,1);
+	mxSetPr(pfield,doublevec);
+	mxSetField( dataref, 0, name,pfield);
+
+}
+#endif
+/*}}}*/
Index: /issm/trunk/src/c/objects/ExternalResults/DoubleVecExternalResult.h
===================================================================
--- /issm/trunk/src/c/objects/ExternalResults/DoubleVecExternalResult.h	(revision 4165)
+++ /issm/trunk/src/c/objects/ExternalResults/DoubleVecExternalResult.h	(revision 4166)
@@ -65,4 +65,8 @@
 		int   EnumType(){return enum_type;}
 		void  WriteData(FILE* fid);
+		char* GetResultName(void);
+		#ifdef _SERIAL_
+		void  SetMatlabField(mxArray* dataref);
+		#endif
 		/*}}}*/
 };
Index: /issm/trunk/src/c/objects/ExternalResults/ExternalResult.h
===================================================================
--- /issm/trunk/src/c/objects/ExternalResults/ExternalResult.h	(revision 4165)
+++ /issm/trunk/src/c/objects/ExternalResults/ExternalResult.h	(revision 4166)
@@ -33,4 +33,8 @@
 		virtual int   EnumType()=0;
 		virtual void  WriteData(FILE* fid)=0;
+		virtual char* GetResultName(void)=0;
+		#ifdef _SERIAL_
+		virtual void  SetMatlabField(mxArray* dataref)=0;
+		#endif
 		/*}}}*/
 };
Index: /issm/trunk/src/c/objects/ExternalResults/IntExternalResult.cpp
===================================================================
--- /issm/trunk/src/c/objects/ExternalResults/IntExternalResult.cpp	(revision 4165)
+++ /issm/trunk/src/c/objects/ExternalResults/IntExternalResult.cpp	(revision 4166)
@@ -177,2 +177,17 @@
 }
 /*}}}1*/
+/*FUNCTION IntExternalResult::GetResultName(void); {{{1*/
+char* IntExternalResult::GetResultName(void){
+	return  EnumAsString(this->enum_type);
+}
+/*}}}*/
+/*FUNCTION IntExternalResult::SetMatlabField(mxArray* dataref);{{{1*/
+#ifdef _SERIAL_
+char* IntExternalResult::SetMatlabField(mxArray* dataref){
+
+	char* name=NULL;
+	name=this->GetResultName();
+	mxSetField( dataref, 0, name,mxCreateIntScalar(value));
+}
+#endif
+/*}}}*/
Index: /issm/trunk/src/c/objects/ExternalResults/IntExternalResult.h
===================================================================
--- /issm/trunk/src/c/objects/ExternalResults/IntExternalResult.h	(revision 4165)
+++ /issm/trunk/src/c/objects/ExternalResults/IntExternalResult.h	(revision 4166)
@@ -66,4 +66,8 @@
 		int   EnumType(){return enum_type;}
 		void  WriteData(FILE* fid);
+		char* GetResultName(void);
+		#ifdef _SERIAL_
+		void  SetMatlabField(mxArray* dataref);
+		#endif
 		/*}}}*/
 };
Index: /issm/trunk/src/c/objects/ExternalResults/PetscVecExternalResult.cpp
===================================================================
--- /issm/trunk/src/c/objects/ExternalResults/PetscVecExternalResult.cpp	(revision 4165)
+++ /issm/trunk/src/c/objects/ExternalResults/PetscVecExternalResult.cpp	(revision 4166)
@@ -233,2 +233,29 @@
 }
 /*}}}1*/
+/*FUNCTION PetscVecExternalResult::GetResultName(void); {{{1*/
+char* PetscVecExternalResult::GetResultName(void){
+	return  EnumAsString(this->enum_type);
+}
+/*}}}*/
+/*FUNCTION PetscVecExternalResult::SetMatlabField(mxArray* dataref);{{{1*/
+#ifdef _SERIAL_
+void  PetscVecExternalResult::SetMatlabField(mxArray* dataref){
+
+	mxArray* pfield=NULL;
+	char* name=NULL;
+	double* doublevec=NULL;
+	int M;
+	
+	VecToMPISerial(&doublevec,value);
+	VecGetSize(value,&M);
+	name=this->GetResultName();
+	
+	pfield=mxCreateDoubleMatrix(0,0,mxREAL);
+	mxSetM(pfield,M);
+	mxSetN(pfield,1);
+	mxSetPr(pfield,doublevec);
+	
+	mxSetField( dataref, 0, name, pfield);
+}
+#endif
+/*}}}*/
Index: /issm/trunk/src/c/objects/ExternalResults/PetscVecExternalResult.h
===================================================================
--- /issm/trunk/src/c/objects/ExternalResults/PetscVecExternalResult.h	(revision 4165)
+++ /issm/trunk/src/c/objects/ExternalResults/PetscVecExternalResult.h	(revision 4166)
@@ -64,4 +64,8 @@
 		int   EnumType(){return enum_type;}
 		void  WriteData(FILE* fid);
+		char* GetResultName(void);
+		#ifdef _SERIAL_
+		void  SetMatlabField(mxArray* dataref);
+		#endif
 		/*}}}*/
 };
Index: /issm/trunk/src/c/objects/ExternalResults/StringExternalResult.cpp
===================================================================
--- /issm/trunk/src/c/objects/ExternalResults/StringExternalResult.cpp	(revision 4165)
+++ /issm/trunk/src/c/objects/ExternalResults/StringExternalResult.cpp	(revision 4166)
@@ -188,2 +188,18 @@
 }
 /*}}}1*/
+/*FUNCTION StringExternalResult::GetResultName(void); {{{1*/
+char* StringExternalResult::GetResultName(void){
+	return  EnumAsString(this->enum_type);
+}
+/*}}}*/
+/*FUNCTION StringExternalResult::SetMatlabField(mxArray* dataref);{{{1*/
+#ifdef _SERIAL_
+void  StringExternalResult::SetMatlabField(mxArray* dataref){
+	
+	char* name=NULL;
+
+	name=this->GetResultName();
+	mxSetField( dataref, 0, name, mxCreateString(value));
+}
+#endif
+/*}}}*/
Index: /issm/trunk/src/c/objects/ExternalResults/StringExternalResult.h
===================================================================
--- /issm/trunk/src/c/objects/ExternalResults/StringExternalResult.h	(revision 4165)
+++ /issm/trunk/src/c/objects/ExternalResults/StringExternalResult.h	(revision 4166)
@@ -65,4 +65,8 @@
 		int   EnumType(){return enum_type;}
 		void  WriteData(FILE* fid);
+		char* GetResultName(void);
+		#ifdef _SERIAL_
+		void  SetMatlabField(mxArray* dataref);
+		#endif
 		/*}}}*/
 };
Index: /issm/trunk/src/c/objects/FemModel.h
===================================================================
--- /issm/trunk/src/c/objects/FemModel.h	(revision 4165)
+++ /issm/trunk/src/c/objects/FemModel.h	(revision 4166)
@@ -12,5 +12,4 @@
 class DataSet;
 class Parameters;
-class DofVec;
 class NodeSets;
 /*}}}*/
@@ -37,6 +36,6 @@
 		DataSet*            results; //results that cannot be fit into the elements (such as one time constants, arrays, strings, etc ...)
 
-		DofVec*             partition; //one partitioning for all elements
-		DofVec*             tpartition;
+		Vec                 partition; //one partitioning for all elements
+		Vec                 tpartition;
 		
 		//multiple  sets of matrices/vectors for each analysis_type. m stands for multiple
Index: /issm/trunk/src/c/objects/objects.h
===================================================================
--- /issm/trunk/src/c/objects/objects.h	(revision 4165)
+++ /issm/trunk/src/c/objects/objects.h	(revision 4166)
@@ -92,5 +92,4 @@
 #include "./OptArgs.h"
 #include "./OptPars.h"
-#include "./DofVec.h"
 
 /*Bamg: */
