Index: /issm/trunk-jpl/src/c/Makefile.am
===================================================================
--- /issm/trunk-jpl/src/c/Makefile.am	(revision 16303)
+++ /issm/trunk-jpl/src/c/Makefile.am	(revision 16304)
@@ -542,8 +542,4 @@
 
 #}}}
-#Responses sources  {{{
-responses_sources =  ./classes/Massfluxatgate.h \
-					 ./modules/ModelProcessorx/CreateOutputDefinitions.cpp
-#}}}
 #Damage sources  {{{
 damage_sources =  ./analyses/damage_core.cpp\
@@ -882,8 +878,4 @@
 endif
 
-if RESPONSES
-issm_sources  +=  $(responses_sources)
-endif
-
 if PETSC
 issm_sources  +=  $(petsc_sources)
Index: /issm/trunk-jpl/src/c/classes/IoModel.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/IoModel.cpp	(revision 16303)
+++ /issm/trunk-jpl/src/c/classes/IoModel.cpp	(revision 16304)
@@ -891,71 +891,4 @@
 }
 /*}}}*/
-/*FUNCTION IoModel::FetchMultipleData(char***       pstrings,int* pnumstrings,int data_enum){{{*/
-void  IoModel::FetchMultipleData(char*** pstrings,int* pnumstrings,int data_enum){
-
-	int my_rank;
-
-	int i;
-	int num_instances;
-
-	/*output: */
-	int   numstrings=0;
-	char** strings=NULL;
-
-	/*intermediary: */
-	char* string=NULL;
-	int   string_size;
-	int*   code=NULL;
-	FILE** file_instances=NULL;
-	FILE* file_id=NULL;
-
-	/*recover my_rank:*/
-	my_rank=IssmComm::GetRank();
-
-	/*Get file pointers to beginning of the data (multiple instances of it): */
-	file_instances=this->SetFilePointerToData(&codes,NULL,&num_instances,data_enum);
-
-	if(num_instances){
-
-		strings=xNew<char*>(num_instances);
-
-		for(i=0;i<num_instances;i++){
-
-			file_id=file_instances[i];
-
-			/*check we are indeed finding a string, not something else: */
-			if(codes[i]!=4)_error_("expecting a string for enum " << EnumToStringx(data_enum));
-
-			/*We have to read a string from disk. First read the dimensions of the string, then the string: */
-			if(my_rank==0){  
-				if(fread(&string_size,sizeof(int),1,file_id)!=1) _error_("could not read length of string ");
-			}
-
-			ISSM_MPI_Bcast(&string_size,1,ISSM_MPI_INT,0,IssmComm::GetComm()); 
-
-			/*Now allocate string: */
-			if(string_size){
-				string=xNew<char>((string_size+1));
-				string[string_size]='\0';
-
-				/*Read string on node 0, then broadcast: */
-				if(my_rank==0){  
-					if(fread(string,string_size*sizeof(char),1,file_id)!=1)_error_(" could not read string ");
-				}
-				ISSM_MPI_Bcast(string,string_size,ISSM_MPI_CHAR,0,IssmComm::GetComm()); 
-			}
-			else{
-				string=xNew<char>(1);
-				string[0]='\0';
-			}
-			strings[i]=string;
-		}
-	}
-	
-	/*Assign output pointers: */
-	*pstrings=strings;
-	*pnumstrings=num_instances;
-}
-/*}}}*/
 /*FUNCTION IoModel::FetchData(IssmDouble*** pmatrices,int** pmdims,int** pndims, int* pM,int data_enum){{{*/
 void  IoModel::FetchData(IssmDouble*** pmatrices,int** pmdims,int** pndims, int* pnumrecords,int data_enum){
@@ -1042,97 +975,4 @@
 	*pndims=ndims;
 	*pnumrecords=numrecords;
-}
-/*}}}*/
-/*FUNCTION IoModel::FetchMultipleData(IssmDouble*** pmatrices,int** pmdims,int** pndims, int* pM,int data_enum){{{*/
-void  IoModel::FetchMultipleData(IssmDouble*** pmatrices,int** pmdims,int** pndims, int* pnumrecords,int data_enum){
-
-	int i;
-	int num_instances;
-	int my_rank;
-	
-	FILE** file_instances=NULL;
-	FILE* file_id=NULL;
-
-	/*output: */
-	IssmDouble** matrices=NULL;
-	int*     mdims=NULL;
-	int*     ndims=NULL;
-	int      numrecords=0;
-
-	/*intermediary: */
-	int     M, N;
-	IssmPDouble *pmatrix = NULL;
-	IssmDouble *matrix = NULL;
-	int     code;
-
-	/*recover my_rank:*/
-	my_rank=IssmComm::GetRank();
-	
-	/*Get file pointers to beginning of the data (multiple instances of it): */
-	file_instances=this->SetFilePointerToData(&codes,NULL,&num_instances,data_enum);
-
-	if(num_instances){
-
-		/*Allocate matrices :*/
-		matrices=xNew<IssmDouble*>(numrecords);
-		mdims=xNew<int>(numrecords);
-		ndims=xNew<int>(numrecords);
-
-		for(i=0;i<num_instances;i++){
-
-			file_id=file_instances[i];
-			code=codes[i];
-
-			if((code!=5) && (code!=6) && (code!=7))_error_("expecting a IssmDouble, integer or boolean matrix for enum " << EnumToStringx(data_enum));
-			
-			/*We have to read a matrix from disk. First read the dimensions of the matrix, then the whole matrix: */
-			/*numberofelements: */
-			if(my_rank==0){  
-				if(fread(&M,sizeof(int),1,file_id)!=1) _error_("could not read number of rows for matrix ");
-			}
-			ISSM_MPI_Bcast(&M,1,ISSM_MPI_INT,0,IssmComm::GetComm()); 
-
-			if(my_rank==0){  
-				if(fread(&N,sizeof(int),1,file_id)!=1) _error_("could not read number of columns for matrix ");
-			}
-			ISSM_MPI_Bcast(&N,1,ISSM_MPI_INT,0,IssmComm::GetComm()); 
-
-			/*Now allocate matrix: */
-			if(M*N){
-				pmatrix=xNew<IssmPDouble>(M*N);
-
-				/*Read matrix on node 0, then broadcast: */
-				if(my_rank==0){  
-					if(fread(pmatrix,M*N*sizeof(IssmPDouble),1,file_id)!=1) _error_("could not read matrix ");
-				}
-				ISSM_MPI_Bcast(pmatrix,M*N,ISSM_MPI_PDOUBLE,0,IssmComm::GetComm()); 
-
-				_assert_(this->independents);
-				if (this->independents[data_enum]){
-					/*this data has already been checked out! So cancel all that we've done here, and return 
-					 * the data[data_enum] directly: */
-					matrix=this->data[data_enum];
-				}
-				else{
-					matrix=xNew<IssmDouble>(M*N);
-					for (int i=0;i<M*N;++i) matrix[i]=pmatrix[i];
-				}
-				xDelete<IssmPDouble>(matrix);
-			}
-			else
-				matrix=NULL;
-			
-			/*Assign: */
-			mdims[i]=M;
-			matrices[i]=matrix;
-			ndims[i]=N;
-		}
-	}
-
-	/*Assign output pointers: */
-	*pmatrices=matrices;
-	*pmdims=mdims;
-	*pndims=ndims;
-	*pnumrecords=num_instances;
 }
 /*}}}*/
@@ -1417,4 +1257,5 @@
 	ISSM_MPI_Bcast(&record_code,1,ISSM_MPI_INT,0,IssmComm::GetComm()); 
 	ISSM_MPI_Bcast(&vector_type,1,ISSM_MPI_INT,0,IssmComm::GetComm()); 
+	if(record_code==5) ISSM_MPI_Bcast(&vector_type,1,ISSM_MPI_INT,0,IssmComm::GetComm()); 
 
 	/*Assign output pointers:*/
@@ -1425,100 +1266,2 @@
 }
 /*}}}*/
-/*FUNCTION IoModel::SetFilePointersToData{{{*/
-FILE** IoModel::SetFilePointersToData(int** pcodes,int** pvector_types, int* pnum_instances, int data_enum){
-
-	int  my_rank;
-	int  found         = 0;
-	int  record_enum;
-	int  record_length;
-	int  record_code;       //1 to 7 number
-	int  vector_type;       //1 to 7 number
-	int* vector_types   = NULL;
-	int* codes= NULL;
-	int  num_instances  = 0;
-	int  counter;
-	FILE** file_instances =NULL;
-
-	/*recover my_rank:*/
-	my_rank=IssmComm::GetRank();
-
-	/*Go find in the binary file, the data we want to fetch and count the number of 
-	 * instances it appears: */
-	if(my_rank==0){
-
-		/*First set FILE* position to the beginning of the file: */
-		fseek(fid,0,SEEK_SET);
-
-		/*Now march through file looking for the correct data identifier: */
-		for(;;){
-			/*Read enum for this size of first string name: */
-			if(fread(&record_enum,sizeof(int),1,fid)==0){
-				/*Ok, we have reached the end of the file. break: */
-				break;
-			}
-
-			/*Is this the record sought for? : */
-			if (data_enum==record_enum) num_instances++;
-
-			/*Read the record length, and use it to skip the record: */
-			if(fread(&record_length,sizeof(int),1,fid)!=1) _error_("Could not read record_length");
-			fseek(fid,record_length,SEEK_CUR);
-		}
-
-		/*Ok, initialize the number of file handles we are going to return: */
-		if(num_instances){
-			file_instances = xNew<FILE*>(num_instances);
-			codes = xNew<int>(num_instances);
-			vector_types = xNew<int>(num_instances);
-		}
-
-	
-		/*Reset FILE* position to the beginning of the file, and start again, this time saving the data information 
-		 * as we find it: */
-		counter=0;
-		fseek(fid,0,SEEK_SET);
-
-		for(;;){
-			/*Read enum for this size of first string name: */
-			if(fread(&record_enum,sizeof(int),1,fid)==0){
-				/*Ok, we have reached the end of the file. break: */
-				break;
-			}
-
-			/*Is this the record sought for? : */
-			if (data_enum==record_enum){
-				/*Ok, we have found the correct string. Pass the record length, and read data type code: */
-				fseek(fid,sizeof(int),SEEK_CUR);
-				if(fread(&record_code,sizeof(int),1,fid)!=1) _error_("Could not read record_code");
-
-				/*if record_code points to a vector, get its type (nodal or elementary): */
-				if(5<=record_code && record_code<=7){
-					if(fread(&vector_type,sizeof(int),1,fid)!=1) _error_("Could not read vector_type");
-				}
-				codes[counter]=record_code;
-				vector_types[counter]=vector_type;
-				file_instances[counter]=fid;
-				counter++;
-				break;
-			}
-			else{
-				/*This is not the correct string, read the record length, and use it to skip this record: */
-				if(fread(&record_length,sizeof(int),1,fid)!=1) _error_("Could not read record_length");
-				/*skip: */
-				fseek(fid,record_length,SEEK_CUR);
-			}
-		}
-	}
-
-	/*Broadcast data: */
-	ISSM_MPI_Bcast(&num_instances,1,ISSM_MPI_INT,0,IssmComm::GetComm()); 
-	ISSM_MPI_Bcast(codes,num_instances,ISSM_MPI_INT,0,IssmComm::GetComm()); 
-	ISSM_MPI_Bcast(vector_types,num_instances,ISSM_MPI_INT,0,IssmComm::GetComm()); 
-
-	/*Assign output pointers:*/
-	*pcodes=codes;
-	*pnum_instances=num_instances;
-	if(pvector_types)*pvector_types=vector_types;
-	return file_instances;
-}
-/*}}}*/
Index: /issm/trunk-jpl/src/c/classes/IoModel.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/IoModel.h	(revision 16303)
+++ /issm/trunk-jpl/src/c/classes/IoModel.h	(revision 16304)
@@ -76,6 +76,4 @@
 		void        FetchData(char***   pstringarray,int* pnumstrings,int data_enum);
 		void        FetchData(IssmDouble*** pmatrixarray,int** pmdims,int** pndims, int* pnumrecords,int data_enum);
-		void        FetchMultipleData(char***   pstringarray,int* pnumstrings,int data_enum);
-		void        FetchMultipleData(IssmDouble*** pmatrixarray,int** pmdims,int** pndims, int* pnumrecords,int data_enum);
 		void        FetchData(Option **poption,int data_enum);
 		void        FetchData(int num,...);
@@ -83,5 +81,4 @@
 		void        FetchDataToInput(Elements* elements,int vector_enum,IssmDouble default_value);
 		void        LastIndex(int *pindex);
-		FILE**      SetFilePointersToData(int** pcodes,int** pvector_types, int data_enum);
 		FILE*       SetFilePointerToData(int* pcode,int* pvector_type, int data_enum);
 		void        DeclareIndependents(void);
Index: sm/trunk-jpl/src/c/classes/Massfluxatgate.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/Massfluxatgate.h	(revision 16303)
+++ 	(revision )
@@ -1,124 +1,0 @@
-/*!\file Massfluxatgate.h
- * \brief: header file for Massfluxatgate object
- */
-
-#ifndef _MASSFLUXATGATE_H_
-#define _MASSFLUXATGATE_H_
-
-/*Headers:*/
-/*{{{*/
-#include "../shared/shared.h"
-#include "../datastructures/datastructures.h"
-/*}}}*/
-
-template <class doubletype>
-class Massfluxatgate: public Object{
-
-	public: 
-
-		char*       name;
-		int         numsegments;
-		doubletype *x1;
-		doubletype *y1;
-		doubletype *x2;
-		doubletype *y2;
-		int*        elements;
-
-		/*Massfluxatgate constructors, destructors :*/
-		/*FUNCTION Massfluxatgate() {{{*/
-		Massfluxatgate(){
-			this->name     = 0;
-			this->numsegments     = 0;
-			this->segments   = 0;
-		}
-		/*}}}*/
-		/*FUNCTION Massfluxatgate(char* name, int numsegments, doubletype* segments) {{{*/
-		Massfluxatgate(char* in_name, int in_numsegments, doubletype* in_segments) {
-
-			this->name   = xNew<char>(strlen(in_name)+1);
-			xMemCpy<char>(this->name,in_name,strlen(in_name)+1);
-
-			this->numsegments=in_numsegments;
-
-			if(this->numsegments){
-				this->x1=xNew<doubletype>(this->numsegments);
-				this->x2=xNew<doubletype>(this->numsegments);
-				this->y1=xNew<doubletype>(this->numsegments);
-				this->y2=xNew<doubletype>(this->numsegments);
-				this->elements=xNew<int>(this->numsegments);
-
-				for(i=0;i<this->numsegments;i++){
-					this->x1[i]=in_segments[5*i+0];
-					this->y1[i]=in_segments[5*i+1];
-					this->x2[i]=in_segments[5*i+2];
-					this->y2[i]=in_segments[5*i+3];
-					this->elements[i]=(int)in_segments[5*i+4];
-				}
-			}
-		}
-		/*}}}*/
-		/*FUNCTION Massfluxatgate(char* name, int numsegments, doubletype* x1, doubletype* y1, doubletype* x2, doubletype* y2,int* elements) {{{*/
-		Massfluxatgate(char* in_name, int in_numsegments, doubletype* in_x1, doubletype* in_y1, doubletype* in_x2, doubletype* in_y2,int* in_elements){
-
-			this->name   = xNew<char>(strlen(in_name)+1);
-			xMemCpy<char>(this->name,in_name,strlen(in_name)+1);
-
-			this->numsegments=in_numsegments;
-
-			if(this->numsegments){
-				this->x1=xNew<doubletype>(this->numsegments); xMemCpy<doubletype>(this->x1,in_x1,this->numsegments);
-				this->y1=xNew<doubletype>(this->numsegments); xMemCpy<doubletype>(this->y1,in_y1,this->numsegments);
-				this->x2=xNew<doubletype>(this->numsegments); xMemCpy<doubletype>(this->x2,in_x2,this->numsegments);
-				this->y2=xNew<doubletype>(this->numsegments); xMemCpy<doubletype>(this->y2,in_y2,this->numsegments);
-				this->elements=xNew<int>(this->numsegments); xMemCpy<int>(this->elements,in_elements,this->numsegments);
-				
-			}
-		}
-		/*}}}*/
-		/*FUNCTION ~Massfluxatgate() {{{*/
-		~Massfluxatgate(){
-			xDelete<doubletype>(this->x1);
-			xDelete<doubletype>(this->y1);
-			xDelete<doubletype>(this->x2);
-			xDelete<doubletype>(this->y2);
-			xDelete<int>(this->elements);
-			xDelete<char>(this->name);
-		}
-		/*}}}*/
-
-		/*Object virtual function resolutoin: */
-		/*FUNCTION Echo(){{{*/
-		void Echo(void){
-			_printf_(" Massfluxatgate: " << name << "\n");
-			_printf_("    numsegments: " << numsegments << "\n");
-			if(numsegments){
-				_printf_("   element: x1, y1, x2, y2:\n");
-				for(int i=0;i<numsegments;i++){
-					_printf_(elements[i] << " " << x1[i] << " " << y1[i] << " " << x2[i] << " " << y2[i] << "\n");
-				}
-			}
-		}
-		/*}}}*/
-		/*FUNCTION DeepEcho(){{{*/
-		void DeepEcho(void){
-			this->Echo();
-		}
-		/*}}}*/
-		/*FUNCTION Id(){{{*/
-		int Id(void){
-			return -1;
-		}
-		/*}}}*/
-		/*FUNCTION ObjectEnum{{{*/
-		int ObjectEnum(void){
-			return MassfluxatgateEnum;
-		}
-		/*}}}*/
-		/*FUNCTION copy {{{*/
-		Object* copy() {
-			return new Massfluxatgate(this->name,this->numsegments,this->); 
-		}
-		/*}}}*/
-};
-
-#endif  /* _MASSFLUXATGATE_H_ */
Index: /issm/trunk-jpl/src/c/classes/classes.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/classes.h	(revision 16303)
+++ /issm/trunk-jpl/src/c/classes/classes.h	(revision 16304)
@@ -17,5 +17,4 @@
 #include "./IndependentObject.h"
 #include "./Segment.h"
-#include "./Massfluxatgate.h"
 
 /*Constraints: */
Index: sm/trunk-jpl/src/c/modules/ModelProcessorx/CreateOutputDefinitions.cpp
===================================================================
--- /issm/trunk-jpl/src/c/modules/ModelProcessorx/CreateOutputDefinitions.cpp	(revision 16303)
+++ 	(revision )
@@ -1,41 +1,0 @@
-/*!\file: CreateParametersOutputDefinitions.cpp
- * \brief driver for creating output definitions dataset, and including it into the parameters dataset
- */ 
-
-#include "../../../toolkits/toolkits.h"
-#include "../../../classes/classes.h"
-#include "../../../shared/shared.h"
-#include "../ModelProcessorx.h"
-
-void CreateParametersOutputDefinitions(Parameters** pparameters,IoModel* iomodel,int solution_type,int analysis_type){
-
-	Parameters *parameters = NULL;
-	DataSet* output_definitions=NULL;
-
-	/*Get parameters: */
-	parameters=*pparameters;
-
-	output_definitions=new DataSet();
-	
-	iomodel->FetchData(&output_definition_enums,&num_output_definitions,NULL,OutputdefinitionEnumsEnum); 
-	if(num_output_definitions){
-		for (i=0;i<num_output_definitions;i++){
-
-			if (output_definition_enums[i]==MassfluxatgateEnum){
-
-				/*Fetch segments and names: */
-				iomodel->FetchMultipleData(&gatenames,&numgates,MassfluxatgateNameEnum);
-				iomodel->FetchMultipleData(&gatesegments,&gatesegments_M,&gatesegments_N,&numgates,MassfluxatgateSegmentsEnum);
-				for(j=0;j<numgates;j++){
-					output_definitions->AddObject(new Massfluxgate(gatenames[i],gatesegments[i],gatesegments_M[i],gatesegments_N[i]));
-				}
-			}
-			else _error_("output definition enum " << output_definition_enums[i] << "not supported yet!");
-		}
-	}
-	parameters->AddObject(new DataSetParam(OutputdefinitionEnum,output_definitions);
-
-	
-	/*Assign output pointer: */
-	*pparameters=parameters;
-}
Index: /issm/trunk-jpl/src/c/modules/ModelProcessorx/CreateParameters.cpp
===================================================================
--- /issm/trunk-jpl/src/c/modules/ModelProcessorx/CreateParameters.cpp	(revision 16303)
+++ /issm/trunk-jpl/src/c/modules/ModelProcessorx/CreateParameters.cpp	(revision 16304)
@@ -24,4 +24,18 @@
 	IssmDouble  time;
 	bool        ispdd,isdelta18o;
+
+	/*parameters for mass flux: {{{*/
+	int          mass_flux_num_profiles     = 0;
+	bool         qmu_mass_flux_present      = false;
+	bool         autodiff_mass_flux_present = false;
+	bool         mass_flux_present          = false;
+	IssmDouble **array                      = NULL;
+	int         *mdims_array                = NULL;
+	int         *ndims_array                = NULL;
+	IssmDouble  *temp_matrix                = NULL;
+	int          temp_m,temp_n;
+	IssmDouble  *matrix                     = NULL;
+	int          count;
+	/*}}}*/
 
 	if(*pparameters)return; //do not create parameters twice!
@@ -137,6 +151,65 @@
 	iomodel->DeleteData(requestedoutputs,MasstransportRequestedOutputsEnum);
 
-	/*Output definitions dataset: */
-	CreateOutputDefinitions(&parameters,iomodel);
+	/*Deal with mass flux segments: {{{*/
+	iomodel->FetchData(&qmu_mass_flux_present,QmuMassFluxSegmentsPresentEnum);
+	iomodel->FetchData(&autodiff_mass_flux_present,AutodiffMassFluxSegmentsPresentEnum);
+
+	if(qmu_mass_flux_present || autodiff_mass_flux_present)mass_flux_present=true;
+	else mass_flux_present=false;
+	parameters->AddObject(new BoolParam(MassFluxSegmentsPresentEnum,mass_flux_present));
+
+	if(mass_flux_present){
+
+		/*Fetch the mass flux segments necessary to compute the mass fluxes.  Build a DoubleMatArrayParam object out of them: */ 
+		iomodel->FetchData(&array,&mdims_array,&ndims_array,&mass_flux_num_profiles,MassFluxSegmentsEnum);
+		if(mass_flux_num_profiles==0)_error_("mass_flux_num_profiles is 0, when MassFlux computations were requested!");
+
+		/*Go through segments, and extract those that belong to this cpu: */
+		for(i=0;i<mass_flux_num_profiles;i++){
+			temp_matrix=array[i];
+			temp_m=mdims_array[i];
+			temp_n=ndims_array[i];
+			_assert_(temp_n==5);
+
+			m=0;
+			for(j=0;j<temp_m;j++){
+				if (  iomodel->my_elements[reCast<int>(*(temp_matrix+5*j+4))-1] )m++;
+			}
+			if(m){
+				matrix=xNewZeroInit<IssmDouble>(5*m);
+				count=0;
+				for(j=0;j<temp_m;j++){
+					if (iomodel->my_elements[reCast<int>(*(temp_matrix+5*j+4))-1]){
+						for(k=0;k<5;k++)*(matrix+5*count+k)=*(temp_matrix+5*j+k);
+						count++;
+					}
+				}
+			}
+			else{
+				matrix=NULL;
+			}
+
+			/*Assign: */
+			array[i]=matrix;
+			mdims_array[i]=m;
+			ndims_array[i]=5;
+
+			/*Free temporary matrix: */
+			xDelete<IssmDouble>(temp_matrix);
+		}
+
+		/*Ok, we have an array of segments, different on every cpu. Create a DoubleMatArrayParam object with it: */
+		parameters->AddObject(new DoubleMatArrayParam(MassFluxSegmentsEnum,array,mass_flux_num_profiles,mdims_array,ndims_array));
+
+		/*Free data: */
+		for(i=0;i<mass_flux_num_profiles;i++){
+			IssmDouble* matrix=array[i];
+			xDelete<IssmDouble>(matrix);
+		}
+		xDelete<int>(mdims_array); 
+		xDelete<int>(ndims_array);
+		xDelete<IssmDouble*>(array);
+	}
+	/*}}}*/
 
 	/*Solution specific parameters*/
Index: /issm/trunk-jpl/src/c/modules/ModelProcessorx/ModelProcessorx.h
===================================================================
--- /issm/trunk-jpl/src/c/modules/ModelProcessorx/ModelProcessorx.h	(revision 16303)
+++ /issm/trunk-jpl/src/c/modules/ModelProcessorx/ModelProcessorx.h	(revision 16304)
@@ -160,7 +160,3 @@
 void DistributeNumDofs(DofIndexing* index,int analysis_type,int node_type);
 
-#ifdef _HAVE_RESPONSES_
-void CreateParametersOutputDefinitions(Parameters** pparameters,IoModel* iomodel,int solution_type,int analysis_type);
 #endif
-
-#endif
Index: /issm/trunk-jpl/src/c/shared/Enum/EnumDefinitions.h
===================================================================
--- /issm/trunk-jpl/src/c/shared/Enum/EnumDefinitions.h	(revision 16303)
+++ /issm/trunk-jpl/src/c/shared/Enum/EnumDefinitions.h	(revision 16304)
@@ -27,4 +27,5 @@
 	AutodiffFovForwardIndicesEnum,
 	AutodiffFosReverseIndexEnum,
+	AutodiffMassFluxSegmentsPresentEnum,
 	AutodiffKeepEnum,
 	AutodiffObufsizeEnum,
@@ -213,4 +214,7 @@
 	MasstransportRequestedOutputsEnum,
 	QmuIsdakotaEnum,
+	MassFluxSegmentsEnum,
+	MassFluxSegmentsPresentEnum,
+	QmuMassFluxSegmentsPresentEnum,
 	QmuNumberofpartitionsEnum,
 	QmuNumberofresponsesEnum,
@@ -539,11 +543,4 @@
 	WaterColumnOldEnum,
 	/*}}}*/
-	/*Output Definitions{{{*/
-	OutputdefinitionEnum,
-	OutputdefinitionEnumsEnum,
-	MassfluxatgateEnum,
-	MassfluxatgateNameEnum,
-	MassfluxatgateSegmentsEnum,
-	/*}}}*/
 	/*Responses{{{*/
 	MinVelEnum,
Index: /issm/trunk-jpl/src/c/shared/Enum/EnumToStringx.cpp
===================================================================
--- /issm/trunk-jpl/src/c/shared/Enum/EnumToStringx.cpp	(revision 16303)
+++ /issm/trunk-jpl/src/c/shared/Enum/EnumToStringx.cpp	(revision 16304)
@@ -35,4 +35,5 @@
 		case AutodiffFovForwardIndicesEnum : return "AutodiffFovForwardIndices";
 		case AutodiffFosReverseIndexEnum : return "AutodiffFosReverseIndex";
+		case AutodiffMassFluxSegmentsPresentEnum : return "AutodiffMassFluxSegmentsPresent";
 		case AutodiffKeepEnum : return "AutodiffKeep";
 		case AutodiffObufsizeEnum : return "AutodiffObufsize";
@@ -221,4 +222,7 @@
 		case MasstransportRequestedOutputsEnum : return "MasstransportRequestedOutputs";
 		case QmuIsdakotaEnum : return "QmuIsdakota";
+		case MassFluxSegmentsEnum : return "MassFluxSegments";
+		case MassFluxSegmentsPresentEnum : return "MassFluxSegmentsPresent";
+		case QmuMassFluxSegmentsPresentEnum : return "QmuMassFluxSegmentsPresent";
 		case QmuNumberofpartitionsEnum : return "QmuNumberofpartitions";
 		case QmuNumberofresponsesEnum : return "QmuNumberofresponses";
@@ -528,9 +532,4 @@
 		case TriaP1ElementResultEnum : return "TriaP1ElementResult";
 		case WaterColumnOldEnum : return "WaterColumnOld";
-		case OutputdefinitionEnum : return "Outputdefinition";
-		case OutputdefinitionEnumsEnum : return "OutputdefinitionEnums";
-		case MassfluxatgateEnum : return "Massfluxatgate";
-		case MassfluxatgateNameEnum : return "MassfluxatgateName";
-		case MassfluxatgateSegmentsEnum : return "MassfluxatgateSegments";
 		case MinVelEnum : return "MinVel";
 		case MaxVelEnum : return "MaxVel";
Index: /issm/trunk-jpl/src/c/shared/Enum/StringToEnumx.cpp
===================================================================
--- /issm/trunk-jpl/src/c/shared/Enum/StringToEnumx.cpp	(revision 16303)
+++ /issm/trunk-jpl/src/c/shared/Enum/StringToEnumx.cpp	(revision 16304)
@@ -35,4 +35,5 @@
 	      else if (strcmp(name,"AutodiffFovForwardIndices")==0) return AutodiffFovForwardIndicesEnum;
 	      else if (strcmp(name,"AutodiffFosReverseIndex")==0) return AutodiffFosReverseIndexEnum;
+	      else if (strcmp(name,"AutodiffMassFluxSegmentsPresent")==0) return AutodiffMassFluxSegmentsPresentEnum;
 	      else if (strcmp(name,"AutodiffKeep")==0) return AutodiffKeepEnum;
 	      else if (strcmp(name,"AutodiffObufsize")==0) return AutodiffObufsizeEnum;
@@ -136,9 +137,9 @@
 	      else if (strcmp(name,"InversionCostFunctionsCoefficients")==0) return InversionCostFunctionsCoefficientsEnum;
 	      else if (strcmp(name,"InversionCostFunctions")==0) return InversionCostFunctionsEnum;
-	      else if (strcmp(name,"InversionGradientScaling")==0) return InversionGradientScalingEnum;
          else stage=2;
    }
    if(stage==2){
-	      if (strcmp(name,"InversionIscontrol")==0) return InversionIscontrolEnum;
+	      if (strcmp(name,"InversionGradientScaling")==0) return InversionGradientScalingEnum;
+	      else if (strcmp(name,"InversionIscontrol")==0) return InversionIscontrolEnum;
 	      else if (strcmp(name,"InversionTao")==0) return InversionTaoEnum;
 	      else if (strcmp(name,"InversionIncompleteAdjoint")==0) return InversionIncompleteAdjointEnum;
@@ -224,4 +225,7 @@
 	      else if (strcmp(name,"MasstransportRequestedOutputs")==0) return MasstransportRequestedOutputsEnum;
 	      else if (strcmp(name,"QmuIsdakota")==0) return QmuIsdakotaEnum;
+	      else if (strcmp(name,"MassFluxSegments")==0) return MassFluxSegmentsEnum;
+	      else if (strcmp(name,"MassFluxSegmentsPresent")==0) return MassFluxSegmentsPresentEnum;
+	      else if (strcmp(name,"QmuMassFluxSegmentsPresent")==0) return QmuMassFluxSegmentsPresentEnum;
 	      else if (strcmp(name,"QmuNumberofpartitions")==0) return QmuNumberofpartitionsEnum;
 	      else if (strcmp(name,"QmuNumberofresponses")==0) return QmuNumberofresponsesEnum;
@@ -256,12 +260,12 @@
 	      else if (strcmp(name,"SurfaceforcingsMassBalance")==0) return SurfaceforcingsMassBalanceEnum;
 	      else if (strcmp(name,"SurfaceforcingsIspdd")==0) return SurfaceforcingsIspddEnum;
-	      else if (strcmp(name,"SurfaceforcingsDesfac")==0) return SurfaceforcingsDesfacEnum;
+         else stage=3;
+   }
+   if(stage==3){
+	      if (strcmp(name,"SurfaceforcingsDesfac")==0) return SurfaceforcingsDesfacEnum;
 	      else if (strcmp(name,"SurfaceforcingsS0p")==0) return SurfaceforcingsS0pEnum;
 	      else if (strcmp(name,"SurfaceforcingsIssmbgradients")==0) return SurfaceforcingsIssmbgradientsEnum;
 	      else if (strcmp(name,"SurfaceforcingsMonthlytemperatures")==0) return SurfaceforcingsMonthlytemperaturesEnum;
-         else stage=3;
-   }
-   if(stage==3){
-	      if (strcmp(name,"SurfaceforcingsHref")==0) return SurfaceforcingsHrefEnum;
+	      else if (strcmp(name,"SurfaceforcingsHref")==0) return SurfaceforcingsHrefEnum;
 	      else if (strcmp(name,"SurfaceforcingsSmbref")==0) return SurfaceforcingsSmbrefEnum;
 	      else if (strcmp(name,"SurfaceforcingsBPos")==0) return SurfaceforcingsBPosEnum;
@@ -379,12 +383,12 @@
 	      else if (strcmp(name,"Input")==0) return InputEnum;
 	      else if (strcmp(name,"IntInput")==0) return IntInputEnum;
-	      else if (strcmp(name,"IntParam")==0) return IntParamEnum;
+         else stage=4;
+   }
+   if(stage==4){
+	      if (strcmp(name,"IntParam")==0) return IntParamEnum;
 	      else if (strcmp(name,"IntVecParam")==0) return IntVecParamEnum;
 	      else if (strcmp(name,"TransientParam")==0) return TransientParamEnum;
 	      else if (strcmp(name,"Matice")==0) return MaticeEnum;
-         else stage=4;
-   }
-   if(stage==4){
-	      if (strcmp(name,"Matpar")==0) return MatparEnum;
+	      else if (strcmp(name,"Matpar")==0) return MatparEnum;
 	      else if (strcmp(name,"Node")==0) return NodeEnum;
 	      else if (strcmp(name,"Numericalflux")==0) return NumericalfluxEnum;
@@ -502,12 +506,12 @@
 	      else if (strcmp(name,"StressTensorxz")==0) return StressTensorxzEnum;
 	      else if (strcmp(name,"StressTensoryy")==0) return StressTensoryyEnum;
-	      else if (strcmp(name,"StressTensoryz")==0) return StressTensoryzEnum;
+         else stage=5;
+   }
+   if(stage==5){
+	      if (strcmp(name,"StressTensoryz")==0) return StressTensoryzEnum;
 	      else if (strcmp(name,"StressTensorzz")==0) return StressTensorzzEnum;
 	      else if (strcmp(name,"GiaCrossSectionShape")==0) return GiaCrossSectionShapeEnum;
 	      else if (strcmp(name,"GiadWdt")==0) return GiadWdtEnum;
-         else stage=5;
-   }
-   if(stage==5){
-	      if (strcmp(name,"GiaW")==0) return GiaWEnum;
+	      else if (strcmp(name,"GiaW")==0) return GiaWEnum;
 	      else if (strcmp(name,"P0")==0) return P0Enum;
 	      else if (strcmp(name,"P1")==0) return P1Enum;
@@ -540,9 +544,4 @@
 	      else if (strcmp(name,"TriaP1ElementResult")==0) return TriaP1ElementResultEnum;
 	      else if (strcmp(name,"WaterColumnOld")==0) return WaterColumnOldEnum;
-	      else if (strcmp(name,"Outputdefinition")==0) return OutputdefinitionEnum;
-	      else if (strcmp(name,"OutputdefinitionEnums")==0) return OutputdefinitionEnumsEnum;
-	      else if (strcmp(name,"Massfluxatgate")==0) return MassfluxatgateEnum;
-	      else if (strcmp(name,"MassfluxatgateName")==0) return MassfluxatgateNameEnum;
-	      else if (strcmp(name,"MassfluxatgateSegments")==0) return MassfluxatgateSegmentsEnum;
 	      else if (strcmp(name,"MinVel")==0) return MinVelEnum;
 	      else if (strcmp(name,"MaxVel")==0) return MaxVelEnum;
Index: /issm/trunk-jpl/src/m/classes/autodiff.m
===================================================================
--- /issm/trunk-jpl/src/m/classes/autodiff.m	(revision 16303)
+++ /issm/trunk-jpl/src/m/classes/autodiff.m	(revision 16304)
@@ -83,4 +83,5 @@
 			%early return
 			if ~obj.isautodiff,
+				WriteData(fid,'data',false,'enum',AutodiffMassFluxSegmentsPresentEnum(),'format','Boolean');
 				WriteData(fid,'data',false,'enum',AutodiffKeepEnum(),'format','Boolean');
 				return;
@@ -197,4 +198,20 @@
 			end
 			%}}}
+			%deal with mass fluxes:  {{{
+			mass_flux_segments=cell(0,1);
+			for i=1:num_dependent_objects,
+				dep=obj.dependents{i};
+				if strcmpi(dep.name,'MassFlux'),
+					mass_flux_segments{end+1,1}=dep.segments;
+				end
+			end
+			if ~isempty(mass_flux_segments), 
+				WriteData(fid,'data',mass_flux_segments,'enum',MassFluxSegmentsEnum(),'format','MatArray');
+				flag=true;
+			else
+				flag=false;
+			end
+			WriteData(fid,'data',flag,'enum',AutodiffMassFluxSegmentsPresentEnum(),'format','Boolean');
+			%}}}
 			%deal with trace keep on: {{{
 			keep=false;
Index: /issm/trunk-jpl/src/m/classes/autodiff.py
===================================================================
--- /issm/trunk-jpl/src/m/classes/autodiff.py	(revision 16303)
+++ /issm/trunk-jpl/src/m/classes/autodiff.py	(revision 16304)
@@ -86,4 +86,5 @@
 		#early return
 		if not self.isautodiff:
+			WriteData(fid,'data',False,'enum',AutodiffMassFluxSegmentsPresentEnum(),'format','Boolean')
 			WriteData(fid,'data',False,'enum',AutodiffKeepEnum(),'format','Boolean')
 			return
@@ -181,4 +182,14 @@
 			WriteData(fid,'data',indices,'enum',AutodiffFovForwardIndicesEnum(),'format','IntMat','mattype',3)
 		#}}}
+		#deal with mass fluxes:  {{{
+		mass_flux_segments=[dep.segments for dep in self.dependents if strcmpi(dep.name,'MassFlux')]
+
+		if mass_flux_segments:
+			WriteData(fid,'data',mass_flux_segments,'enum',MassFluxSegmentsEnum(),'format','MatArray')
+			flag=True
+		else:
+			flag=False
+		WriteData(fid,'data',flag,'enum',AutodiffMassFluxSegmentsPresentEnum(),'format','Boolean')
+		#}}}
 		#deal with trace keep on: {{{
 		keep=False
Index: /issm/trunk-jpl/src/m/classes/damage.m
===================================================================
--- /issm/trunk-jpl/src/m/classes/damage.m	(revision 16303)
+++ /issm/trunk-jpl/src/m/classes/damage.m	(revision 16304)
@@ -110,5 +110,5 @@
 			disp(sprintf('   Damage:\n'));
 
-			fielddisplay(obj,'D','damage tensor (vector)');
+			fielddisplay(obj,'D','damage tensor (scalar)');
 			fielddisplay(obj,'law','damage law (string) from {''undamaged'',''pralong''}');
 			fielddisplay(obj,'spcdamage','damage constraints (NaN means no constraint)');
Index: sm/trunk-jpl/src/m/classes/massfluxatgate.m
===================================================================
--- /issm/trunk-jpl/src/m/classes/massfluxatgate.m	(revision 16303)
+++ 	(revision )
@@ -1,63 +1,0 @@
-%MASSFLUXATGATE class definition
-%
-%   Usage:
-%      massfluxatgate=massfluxatgate();
-
-classdef massfluxatgate
-	properties (SetAccess=public)  
-		%massfluxatgate 
-		name                = '';
-		profilename            = ''; 
-	end
-	properties (SetAccess=private)  
-		segments            = NaN;
-	end
-	methods
-		function obj = massfluxatgate(varargin) % {{{
-			switch nargin
-				case 0
-					obj=setdefaultparameters(obj);
-				case 1
-					obj.name=varargin{1};
-				case 2
-					obj.name=varargin{1};
-					obj.profilename=varargin{2};
-				otherwise
-					error('constructor not supported');
-			end
-		end % }}}
-		function obj = setdefaultparameters(obj) % {{{
-		end % }}}
-		function md = checkconsistency(obj,md,solution,analyses) % {{{
-			
-			if ~ischar(obj.name),
-				error('massfluxatgate error message: ''name'' field should be a string!');
-			end
-			if ~ischar(obj.profilename),
-				error('massfluxatgate error message: ''profilename'' field should be a string!');
-			end
-
-			%check the profilename points to a file!: 
-			if exist(obj.profilename,'file')~=2,
-				error('massfluxatgate error message: file name for profile corresponding to gate does not point to a legitimate file on disk!');
-			end
-		end % }}}
-		function disp(obj) % {{{
-			disp(sprintf('   Massfluxatgate:\n'));
-
-			fielddisplay(obj,'name','identifier for this massfluxatgate response');
-			fielddisplay(obj,'profilename','name of file (shapefile or argus file) defining a profile (or gate)');
-			
-		end % }}}
-		function marshall(obj,md,fid) % {{{
-
-		%before marshalling, we need to create the segments out of the profilename: 
-		obj.segments=MeshProfileIntersection(md.mesh.elements,md.mesh.x,md.mesh.y,obj.profilename);
-
-		%ok, marshall name and segments: 
-		WriteData(fid,'object',obj,'fieldname','name','format','String');
-		WriteData(fid,'object',obj,'fieldname','segments','format','DoubleMat','mattype',1);
-
-		end % }}}
-	end
-end
Index: /issm/trunk-jpl/src/m/classes/model.m
===================================================================
--- /issm/trunk-jpl/src/m/classes/model.m	(revision 16303)
+++ /issm/trunk-jpl/src/m/classes/model.m	(revision 16304)
@@ -45,5 +45,4 @@
 
 		results          = 0;
-		outputdefinition = 0;
 		radaroverlay     = 0;
 		miscellaneous    = 0;
@@ -1072,5 +1071,4 @@
 			md.radaroverlay     = radaroverlay();
 			md.results          = struct();
-			md.outputdefinition = outputdefinition();
 			md.miscellaneous    = miscellaneous();
 			md.private          = private();
@@ -1109,5 +1107,4 @@
 			disp(sprintf('%19s: %-22s -- %s','inversion'       ,['[1x1 ' class(obj.inversion) ']'],'parameters for inverse methods'));
 			disp(sprintf('%19s: %-22s -- %s','qmu'             ,['[1x1 ' class(obj.qmu) ']'],'dakota properties'));
-			disp(sprintf('%19s: %-22s -- %s','outputdefinition',['[1x1 ' class(obj.outputdefinition) ']'],'output definition'));
 			disp(sprintf('%19s: %-22s -- %s','results'         ,['[1x1 ' class(obj.results) ']'],'model results'));
 			disp(sprintf('%19s: %-22s -- %s','radaroverlay'    ,['[1x1 ' class(obj.radaroverlay) ']'],'radar image for plot overlay'));
Index: sm/trunk-jpl/src/m/classes/outputdefinition.m
===================================================================
--- /issm/trunk-jpl/src/m/classes/outputdefinition.m	(revision 16303)
+++ 	(revision )
@@ -1,54 +1,0 @@
-%CONSTANTS class definition
-%
-%   Usage:
-%      outputdefinition=outputdefinition();
-
-classdef outputdefinition
-	properties (SetAccess=public) 
-		definitions                 = {};
-	end
-	properties (SetAccess=private) 
-		enums                 = {};
-	end
-	methods
-		function obj = outputdefinition(varargin) % {{{
-			switch nargin
-				case 0
-					obj=setdefaultparameters(obj);
-				otherwise
-					error('constructor not supported');
-			end
-		end % }}}
-		function obj = setdefaultparameters(obj) % {{{
-
-			obj.definitions={};
-			obj.enums=NaN;
-
-		end % }}}
-		function md = checkconsistency(obj,md,solution,analyses) % {{{
-
-			md = checkfield(md,'outputdefinition.definitions','cell',1);
-
-			for i=1:length(obj.definitions),
-				md=checkconsistency(obj.definitions{i},md,solution,analyses);
-			end
-
-		end % }}}
-		function disp(obj) % {{{
-			disp(sprintf('   outputdefinition:'));
-			fielddisplay(obj,'definitions','list of potential outputs that can be requested, but which need additional data to be defined');
-
-		end % }}}
-		function marshall(obj,md,fid) % {{{
-
-		enums=zeros(length(obj.definitions),1);
-		for i=1:length(obj.definitions),
-			obj.definitions{i}.marshall(md,fid);
-			obj.enums(i)=StringToEnum(class(obj.definitions{i}));
-		end
-		obj.enums=unique(obj.enums);
-		
-		WriteData(fid,'object',obj,'fieldname','enums','format','DoubleMat','mattype',1);
-		end % }}}
-	end
-end
Index: /issm/trunk-jpl/src/m/classes/qmu.m
===================================================================
--- /issm/trunk-jpl/src/m/classes/qmu.m	(revision 16303)
+++ /issm/trunk-jpl/src/m/classes/qmu.m	(revision 16304)
@@ -17,4 +17,7 @@
 		variabledescriptors         = {};
 		responsedescriptors         = {};
+		mass_flux_profile_directory = NaN;
+		mass_flux_profiles          = NaN;
+		mass_flux_segments          = {};
 		adjacency                   = NaN;
 		vertex_weight               = NaN;
@@ -130,4 +133,7 @@
 			fielddisplay(obj,'responsedescriptors','');
 			fielddisplay(obj,'method','array of dakota_method class');
+			fielddisplay(obj,'mass_flux_profile_directory','directory for mass flux profiles');
+			fielddisplay(obj,'mass_flux_profiles','list of mass_flux profiles');
+			fielddisplay(obj,'mass_flux_segments','');
 			fielddisplay(obj,'adjacency','');
 			fielddisplay(obj,'vertex_weight','weight applied to each mesh vertex');
@@ -145,4 +151,11 @@
 			WriteData(fid,'object',obj,'fieldname','variabledescriptors','format','StringArray');
 			WriteData(fid,'object',obj,'fieldname','responsedescriptors','format','StringArray');
+			if ~isempty(obj.mass_flux_segments), 
+				WriteData(fid,'data',obj.mass_flux_segments,'enum',MassFluxSegmentsEnum,'format','MatArray');
+				flag=true; 
+			else 
+				flag=false; 
+			end
+			WriteData(fid,'data',flag,'enum',QmuMassFluxSegmentsPresentEnum,'format','Boolean');
 		end % }}}
 	end
Index: /issm/trunk-jpl/src/m/classes/qmu.py
===================================================================
--- /issm/trunk-jpl/src/m/classes/qmu.py	(revision 16303)
+++ /issm/trunk-jpl/src/m/classes/qmu.py	(revision 16304)
@@ -27,4 +27,7 @@
 		self.variabledescriptors         = []
 		self.responsedescriptors         = []
+		self.mass_flux_profile_directory = float('NaN')
+		self.mass_flux_profiles          = float('NaN')
+		self.mass_flux_segments          = []
 		self.adjacency                   = float('NaN')
 		self.vertex_weight               = float('NaN')
@@ -123,4 +126,7 @@
 		s+="%s\n" % fielddisplay(self,'responsedescriptors','')
 		s+="%s\n" % fielddisplay(self,'method','array of dakota_method class')
+		s+="%s\n" % fielddisplay(self,'mass_flux_profile_directory','directory for mass flux profiles')
+		s+="%s\n" % fielddisplay(self,'mass_flux_profiles','list of mass_flux profiles')
+		s+="%s\n" % fielddisplay(self,'mass_flux_segments','')
 		s+="%s\n" % fielddisplay(self,'adjacency','')
 		s+="%s\n" % fielddisplay(self,'vertex_weight','weight applied to each mesh vertex')
@@ -138,3 +144,9 @@
 		WriteData(fid,'object',self,'fieldname','variabledescriptors','format','StringArray')
 		WriteData(fid,'object',self,'fieldname','responsedescriptors','format','StringArray')
+		if not self.mass_flux_segments:
+			WriteData(fid,'data',self.mass_flux_segments,'enum',MassFluxSegmentsEnum(),'format','MatArray');
+			flag=True; 
+		else:
+			flag=False; 
+		WriteData(fid,'data',flag,'enum',QmuMassFluxSegmentsPresentEnum(),'format','Boolean');
 	# }}}
Index: /issm/trunk-jpl/src/m/contrib/paraview/exportVTK.m
===================================================================
--- /issm/trunk-jpl/src/m/contrib/paraview/exportVTK.m	(revision 16303)
+++ /issm/trunk-jpl/src/m/contrib/paraview/exportVTK.m	(revision 16304)
@@ -1,3 +1,3 @@
-function exportVTK(filename,model)
+function exportVTK(filename,model,Solution)
 % vtk export
 % function exportVTK(filename,model,Solution)
@@ -19,9 +19,11 @@
 mkdir(filename);
 
-%get the element related variables
 points=[model.mesh.x model.mesh.y model.mesh.z];
 [num_of_points,dim]=size(points);
 [num_of_elt]=size(model.mesh.elements,1);
 [point_per_elt]=size(model.mesh.elements,2);
+sol_enum=EnumToString(Solution);
+
+sol_struct=model.results.(sol_enum);
 
 %Select the type of element function of the number of nodes per elements
@@ -34,31 +36,19 @@
 end
 
-%sol_enum=EnumToString(Solution);
+%looking for multiple time steps
+num_of_timesteps=size(sol_struct,2);
 
-%this is the result structure
-res_struct=model.results;
+%getting the number of fields in the solution
+fieldnames=fields(sol_struct(1));
+num_of_fields=length(fieldnames);
 
-%Getting all the solutions of the model
-solnames=fields(res_struct);
-num_of_sols=length(solnames);
+if num_of_timesteps==1; %just one timestep only write one file
 
-%building solution structure 
-for i=1:num_of_sols
-	sol_struct{i}=res_struct.(solnames{i});
-end
-
-%looking for multiple time steps
-num_of_timesteps=size(sol_struct{1},2);
-
-for i=1:num_of_timesteps;
-	%by default, we take the timestep from the first solution sturcture
-	timestep=sol_struct{1}(i).step;
-	
-	FID = fopen(strcat(path,filesep,name,filesep,name,'.vtk',int2str(timestep),'.vtk'),'w+');
+	FID = fopen(strcat(path,filesep,name,filesep,name,'.vtk'),'w+');
 	fprintf(FID,'# vtk DataFile Version 2.0 \n');
 	fprintf(FID,'Data for run %s \n',model.miscellaneous.name);
 	fprintf(FID,'ASCII \n');
 	fprintf(FID,'DATASET UNSTRUCTURED_GRID \n');
-	
+
 	fprintf(FID,'POINTS %d float\n',num_of_points);
 	if(dim==3);
@@ -69,37 +59,71 @@
 	P=[points zeros(num_of_points,3-dim)];
 	fprintf(FID,s,P');
- 
+
 	fprintf(FID,'CELLS %d %d\n',num_of_elt,num_of_elt*(point_per_elt+1));
 	s='%d';
 	for k=1:point_per_elt
-		s=horzcat(s,{' %d'});
+    s=horzcat(s,{' %d'});
   end
 	s=cell2mat(horzcat(s,{'\n'}));
 	fprintf(FID,s,[(point_per_elt)*ones(num_of_elt,1) model.mesh.elements-1]');
- 
+
 	fprintf(FID,'CELL_TYPES %d\n',num_of_elt);
 	s='%d\n';
 	fprintf(FID,s,celltype*ones(num_of_elt,1));
-	
-	%loop over the different solution structures
-	for j=1:num_of_sols
 
-		%getting the number of fields in the solution
-		fieldnames=fields(sol_struct{j}(i));
-		num_of_fields=length(fieldnames);
-		
+	%check which field is a real result and print	
+	fprintf(FID,'POINT_DATA %s \n',num2str(num_of_points));
+	for j=1:num_of_fields
+
+		if (length(sol_struct(1).(fieldnames{j}))==num_of_points);
+			fprintf(FID,'SCALARS %s float 1 \n',fieldnames{j});
+			fprintf(FID,'LOOKUP_TABLE default\n');
+			s='%e\n';
+			fprintf(FID,s,sol_struct.(fieldnames{j}));
+	  end
+  end
+		fclose(FID);
+else
+	for i=1:num_of_timesteps;
+		timestep=sol_struct(i).step;
+		FID = fopen(strcat(path,filesep,name,filesep,name,'.vtk',int2str(timestep),'.vtk'),'w+');
+		fprintf(FID,'# vtk DataFile Version 2.0 \n');
+		fprintf(FID,'Data for run %s \n',model.miscellaneous.name);
+		fprintf(FID,'ASCII \n');
+		fprintf(FID,'DATASET UNSTRUCTURED_GRID \n');
+
+		fprintf(FID,'POINTS %d float\n',num_of_points);
+		if(dim==3);
+			s='%f %f %f \n';
+		elseif(dim==2);
+			s='%f %f \n';
+   end
+		P=[points zeros(num_of_points,3-dim)];
+		fprintf(FID,s,P');
+
+		fprintf(FID,'CELLS %d %d\n',num_of_elt,num_of_elt*(point_per_elt+1));
+		s='%d';
+		for k=1:point_per_elt
+			s=horzcat(s,{' %d'});
+  	end
+		s=cell2mat(horzcat(s,{'\n'}));
+		fprintf(FID,s,[(point_per_elt)*ones(num_of_elt,1) model.mesh.elements-1]');
+
+		fprintf(FID,'CELL_TYPES %d\n',num_of_elt);
+		s='%d\n';
+		fprintf(FID,s,celltype*ones(num_of_elt,1));
+
 		%check which field is a real result and print
 		fprintf(FID,'POINT_DATA %s \n',num2str(num_of_points));
-		for k=1:num_of_fields
-			
-			if ((length(sol_struct{j}(i).(fieldnames{k})))==num_of_points);
-				fprintf(FID,'SCALARS %s float 1 \n',fieldnames{k});
+		for j=1:num_of_fields
+
+			if (length(sol_struct(1).(fieldnames{j}))==num_of_points);
+				fprintf(FID,'SCALARS %s float 1 \n',fieldnames{j});
 				fprintf(FID,'LOOKUP_TABLE default\n');
 				s='%e\n';
-				fprintf(FID,s,sol_struct{j}(i).(fieldnames{k}));
+				fprintf(FID,s,sol_struct(i).(fieldnames{j}));
 	    end		
-     end 
-	 end
-	 fclose(FID);
+    end 
+		fclose(FID);
   end
 end
Index: /issm/trunk-jpl/src/m/enum/AutodiffMassFluxSegmentsPresentEnum.m
===================================================================
--- /issm/trunk-jpl/src/m/enum/AutodiffMassFluxSegmentsPresentEnum.m	(revision 16304)
+++ /issm/trunk-jpl/src/m/enum/AutodiffMassFluxSegmentsPresentEnum.m	(revision 16304)
@@ -0,0 +1,11 @@
+function macro=AutodiffMassFluxSegmentsPresentEnum()
+%AUTODIFFMASSFLUXSEGMENTSPRESENTENUM - Enum of AutodiffMassFluxSegmentsPresent
+%
+%   WARNING: DO NOT MODIFY THIS FILE
+%            this file has been automatically generated by src/c/shared/Enum/Synchronize.sh
+%            Please read src/c/shared/Enum/README for more information
+%
+%   Usage:
+%      macro=AutodiffMassFluxSegmentsPresentEnum()
+
+macro=StringToEnum('AutodiffMassFluxSegmentsPresent');
Index: /issm/trunk-jpl/src/m/enum/EnumDefinitions.py
===================================================================
--- /issm/trunk-jpl/src/m/enum/EnumDefinitions.py	(revision 16303)
+++ /issm/trunk-jpl/src/m/enum/EnumDefinitions.py	(revision 16304)
@@ -27,4 +27,5 @@
 def AutodiffFovForwardIndicesEnum(): return StringToEnum("AutodiffFovForwardIndices")[0]
 def AutodiffFosReverseIndexEnum(): return StringToEnum("AutodiffFosReverseIndex")[0]
+def AutodiffMassFluxSegmentsPresentEnum(): return StringToEnum("AutodiffMassFluxSegmentsPresent")[0]
 def AutodiffKeepEnum(): return StringToEnum("AutodiffKeep")[0]
 def AutodiffObufsizeEnum(): return StringToEnum("AutodiffObufsize")[0]
@@ -213,4 +214,7 @@
 def MasstransportRequestedOutputsEnum(): return StringToEnum("MasstransportRequestedOutputs")[0]
 def QmuIsdakotaEnum(): return StringToEnum("QmuIsdakota")[0]
+def MassFluxSegmentsEnum(): return StringToEnum("MassFluxSegments")[0]
+def MassFluxSegmentsPresentEnum(): return StringToEnum("MassFluxSegmentsPresent")[0]
+def QmuMassFluxSegmentsPresentEnum(): return StringToEnum("QmuMassFluxSegmentsPresent")[0]
 def QmuNumberofpartitionsEnum(): return StringToEnum("QmuNumberofpartitions")[0]
 def QmuNumberofresponsesEnum(): return StringToEnum("QmuNumberofresponses")[0]
@@ -520,9 +524,4 @@
 def TriaP1ElementResultEnum(): return StringToEnum("TriaP1ElementResult")[0]
 def WaterColumnOldEnum(): return StringToEnum("WaterColumnOld")[0]
-def OutputdefinitionEnum(): return StringToEnum("Outputdefinition")[0]
-def OutputdefinitionEnumsEnum(): return StringToEnum("OutputdefinitionEnums")[0]
-def MassfluxatgateEnum(): return StringToEnum("Massfluxatgate")[0]
-def MassfluxatgateNameEnum(): return StringToEnum("MassfluxatgateName")[0]
-def MassfluxatgateSegmentsEnum(): return StringToEnum("MassfluxatgateSegments")[0]
 def MinVelEnum(): return StringToEnum("MinVel")[0]
 def MaxVelEnum(): return StringToEnum("MaxVel")[0]
Index: /issm/trunk-jpl/src/m/enum/MassFluxSegmentsEnum.m
===================================================================
--- /issm/trunk-jpl/src/m/enum/MassFluxSegmentsEnum.m	(revision 16304)
+++ /issm/trunk-jpl/src/m/enum/MassFluxSegmentsEnum.m	(revision 16304)
@@ -0,0 +1,11 @@
+function macro=MassFluxSegmentsEnum()
+%MASSFLUXSEGMENTSENUM - Enum of MassFluxSegments
+%
+%   WARNING: DO NOT MODIFY THIS FILE
+%            this file has been automatically generated by src/c/shared/Enum/Synchronize.sh
+%            Please read src/c/shared/Enum/README for more information
+%
+%   Usage:
+%      macro=MassFluxSegmentsEnum()
+
+macro=StringToEnum('MassFluxSegments');
Index: /issm/trunk-jpl/src/m/enum/MassFluxSegmentsPresentEnum.m
===================================================================
--- /issm/trunk-jpl/src/m/enum/MassFluxSegmentsPresentEnum.m	(revision 16304)
+++ /issm/trunk-jpl/src/m/enum/MassFluxSegmentsPresentEnum.m	(revision 16304)
@@ -0,0 +1,11 @@
+function macro=MassFluxSegmentsPresentEnum()
+%MASSFLUXSEGMENTSPRESENTENUM - Enum of MassFluxSegmentsPresent
+%
+%   WARNING: DO NOT MODIFY THIS FILE
+%            this file has been automatically generated by src/c/shared/Enum/Synchronize.sh
+%            Please read src/c/shared/Enum/README for more information
+%
+%   Usage:
+%      macro=MassFluxSegmentsPresentEnum()
+
+macro=StringToEnum('MassFluxSegmentsPresent');
Index: sm/trunk-jpl/src/m/enum/MassfluxatgateEnum.m
===================================================================
--- /issm/trunk-jpl/src/m/enum/MassfluxatgateEnum.m	(revision 16303)
+++ 	(revision )
@@ -1,11 +1,0 @@
-function macro=MassfluxatgateEnum()
-%MASSFLUXATGATEENUM - Enum of Massfluxatgate
-%
-%   WARNING: DO NOT MODIFY THIS FILE
-%            this file has been automatically generated by src/c/shared/Enum/Synchronize.sh
-%            Please read src/c/shared/Enum/README for more information
-%
-%   Usage:
-%      macro=MassfluxatgateEnum()
-
-macro=StringToEnum('Massfluxatgate');
Index: sm/trunk-jpl/src/m/enum/MassfluxatgateNameEnum.m
===================================================================
--- /issm/trunk-jpl/src/m/enum/MassfluxatgateNameEnum.m	(revision 16303)
+++ 	(revision )
@@ -1,11 +1,0 @@
-function macro=MassfluxatgateNameEnum()
-%MASSFLUXATGATENAMEENUM - Enum of MassfluxatgateName
-%
-%   WARNING: DO NOT MODIFY THIS FILE
-%            this file has been automatically generated by src/c/shared/Enum/Synchronize.sh
-%            Please read src/c/shared/Enum/README for more information
-%
-%   Usage:
-%      macro=MassfluxatgateNameEnum()
-
-macro=StringToEnum('MassfluxatgateName');
Index: sm/trunk-jpl/src/m/enum/MassfluxatgateSegmentsEnum.m
===================================================================
--- /issm/trunk-jpl/src/m/enum/MassfluxatgateSegmentsEnum.m	(revision 16303)
+++ 	(revision )
@@ -1,11 +1,0 @@
-function macro=MassfluxatgateSegmentsEnum()
-%MASSFLUXATGATESEGMENTSENUM - Enum of MassfluxatgateSegments
-%
-%   WARNING: DO NOT MODIFY THIS FILE
-%            this file has been automatically generated by src/c/shared/Enum/Synchronize.sh
-%            Please read src/c/shared/Enum/README for more information
-%
-%   Usage:
-%      macro=MassfluxatgateSegmentsEnum()
-
-macro=StringToEnum('MassfluxatgateSegments');
Index: sm/trunk-jpl/src/m/enum/OutputdefinitionEnum.m
===================================================================
--- /issm/trunk-jpl/src/m/enum/OutputdefinitionEnum.m	(revision 16303)
+++ 	(revision )
@@ -1,11 +1,0 @@
-function macro=OutputdefinitionEnum()
-%OUTPUTDEFINITIONENUM - Enum of Outputdefinition
-%
-%   WARNING: DO NOT MODIFY THIS FILE
-%            this file has been automatically generated by src/c/shared/Enum/Synchronize.sh
-%            Please read src/c/shared/Enum/README for more information
-%
-%   Usage:
-%      macro=OutputdefinitionEnum()
-
-macro=StringToEnum('Outputdefinition');
Index: sm/trunk-jpl/src/m/enum/OutputdefinitionEnumsEnum.m
===================================================================
--- /issm/trunk-jpl/src/m/enum/OutputdefinitionEnumsEnum.m	(revision 16303)
+++ 	(revision )
@@ -1,11 +1,0 @@
-function macro=OutputdefinitionEnumsEnum()
-%OUTPUTDEFINITIONENUMSENUM - Enum of Outputdefinitions
-%
-%   WARNING: DO NOT MODIFY THIS FILE
-%            this file has been automatically generated by src/c/shared/Enum/Synchronize.sh
-%            Please read src/c/shared/Enum/README for more information
-%
-%   Usage:
-%      macro=OutputdefinitionEnumsEnum()
-
-macro=StringToEnum('Outputdefinitions');
Index: /issm/trunk-jpl/src/m/enum/QmuMassFluxSegmentsPresentEnum.m
===================================================================
--- /issm/trunk-jpl/src/m/enum/QmuMassFluxSegmentsPresentEnum.m	(revision 16304)
+++ /issm/trunk-jpl/src/m/enum/QmuMassFluxSegmentsPresentEnum.m	(revision 16304)
@@ -0,0 +1,11 @@
+function macro=QmuMassFluxSegmentsPresentEnum()
+%QMUMASSFLUXSEGMENTSPRESENTENUM - Enum of QmuMassFluxSegmentsPresent
+%
+%   WARNING: DO NOT MODIFY THIS FILE
+%            this file has been automatically generated by src/c/shared/Enum/Synchronize.sh
+%            Please read src/c/shared/Enum/README for more information
+%
+%   Usage:
+%      macro=QmuMassFluxSegmentsPresentEnum()
+
+macro=StringToEnum('QmuMassFluxSegmentsPresent');
Index: /issm/trunk-jpl/test/NightlyRun/test234.m
===================================================================
--- /issm/trunk-jpl/test/NightlyRun/test234.m	(revision 16303)
+++ /issm/trunk-jpl/test/NightlyRun/test234.m	(revision 16304)
@@ -28,20 +28,14 @@
 md.qmu.responses.MaxVel=response_function('MaxVel',[],[0.0001 0.001 0.01 0.25 0.5 0.75 0.99 0.999 0.9999]);
 md.qmu.responses.IceVolume=response_function('IceVolume',[],[0.0001 0.001 0.01 0.25 0.5 0.75 0.99 0.999 0.9999]);
-md.qmu.responses.MassFlux1=response_function('MassFlux1',[],[0.0001 0.001 0.01 0.25 0.5 0.75 0.99 0.999 0.9999]);
-md.qmu.responses.MassFlux2=response_function('MassFlux2',[],[0.0001 0.001 0.01 0.25 0.5 0.75 0.99 0.999 0.9999]);
-md.qmu.responses.MassFlux3=response_function('MassFlux3',[],[0.0001 0.001 0.01 0.25 0.5 0.75 0.99 0.999 0.9999]);
-md.qmu.responses.MassFlux4=response_function('MassFlux4',[],[0.0001 0.001 0.01 0.25 0.5 0.75 0.99 0.999 0.9999]);
-md.qmu.responses.MassFlux5=response_function('MassFlux5',[],[0.0001 0.001 0.01 0.25 0.5 0.75 0.99 0.999 0.9999]);
-md.qmu.responses.massFlux6=response_function('MassFlux6',[],[0.0001 0.001 0.01 0.25 0.5 0.75 0.99 0.999 0.9999]);
+md.qmu.responses.MassFlux1=response_function('indexed_MassFlux_1',[],[0.0001 0.001 0.01 0.25 0.5 0.75 0.99 0.999 0.9999]);
+md.qmu.responses.MassFlux2=response_function('indexed_MassFlux_2',[],[0.0001 0.001 0.01 0.25 0.5 0.75 0.99 0.999 0.9999]);
+md.qmu.responses.MassFlux3=response_function('indexed_MassFlux_3',[],[0.0001 0.001 0.01 0.25 0.5 0.75 0.99 0.999 0.9999]);
+md.qmu.responses.MassFlux4=response_function('indexed_MassFlux_4',[],[0.0001 0.001 0.01 0.25 0.5 0.75 0.99 0.999 0.9999]);
+md.qmu.responses.MassFlux5=response_function('indexed_MassFlux_5',[],[0.0001 0.001 0.01 0.25 0.5 0.75 0.99 0.999 0.9999]);
+md.qmu.responses.massFlux6=response_function('indexed_MassFlux_6',[],[0.0001 0.001 0.01 0.25 0.5 0.75 0.99 0.999 0.9999]);
 
-md.outputdefinition.definitions={...
-		massfluxatgate('MassFlux1',[pwd '/../Exp/MassFlux1.exp']),...
-		massfluxatgate('MassFlux2',[pwd '/../Exp/MassFlux2.exp']),...
-		massfluxatgate('MassFlux3',[pwd '/../Exp/MassFlux3.exp']),...
-		massfluxatgate('MassFlux4',[pwd '/../Exp/MassFlux4.exp']),...
-		massfluxatgate('MassFlux5',[pwd '/../Exp/MassFlux5.exp']),...
-		massfluxatgate('MassFlux6',[pwd '/../Exp/MassFlux6.exp'])...
-	};
-
+%mass flux profiles
+md.qmu.mass_flux_profiles={'../Exp/MassFlux1.exp','../Exp/MassFlux2.exp','../Exp/MassFlux3.exp','../Exp/MassFlux4.exp','../Exp/MassFlux5.exp','../Exp/MassFlux6.exp'};
+md.qmu.mass_flux_profile_directory=pwd;
 
 %%  nond_sampling study
