Index: /issm/trunk-jpl/src/c/Makefile.am
===================================================================
--- /issm/trunk-jpl/src/c/Makefile.am	(revision 16387)
+++ /issm/trunk-jpl/src/c/Makefile.am	(revision 16388)
@@ -576,4 +576,10 @@
 				    ./modules/ConstraintsStatex/RiftConstraintsState.cpp
 #}}}
+#Responses sources  {{{
+responses_sources= ./classes/Massfluxatgate.h \
+				   ./modules/ModelProcessorx/CreateOutputDefinitions.cpp\
+				   ./modules/OutputDefinitionsResponsex/OutputDefinitionsResponsex.h\
+				   ./modules/OutputDefinitionsResponsex/OutputDefinitionsResponsex.cpp
+#}}}
 #Android sources  {{{
 android_sources = 
@@ -957,4 +963,8 @@
 endif
 
+if RESPONSES
+issm_sources +=  $(responses_sources)
+endif
+
 if ANDROID
 issm_sources +=  $(android_sources)
Index: /issm/trunk-jpl/src/c/classes/Definition.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/Definition.h	(revision 16388)
+++ /issm/trunk-jpl/src/c/classes/Definition.h	(revision 16388)
@@ -0,0 +1,19 @@
+/*!\file: Definition.h: abstract class used by some objects to behave like response objects 
+ * that can be called according to a string (the output definition)
+ */ 
+
+#ifndef _DEFINITION_H_
+#define  _DEFINITION_H_
+
+/*Headers:*/
+class FemModel;
+class Definition {
+
+	public:
+		virtual       ~Definition(){};
+		virtual char*  Name()=0;
+		virtual IssmDouble  Response(FemModel*)=0;
+
+};
+
+#endif //ifndef _DEFINITION_H_
Index: /issm/trunk-jpl/src/c/classes/Elements/Element.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/Elements/Element.h	(revision 16387)
+++ /issm/trunk-jpl/src/c/classes/Elements/Element.h	(revision 16388)
@@ -94,4 +94,5 @@
 		virtual void   MaxAbsVz(IssmDouble* pmaxabsvz)=0;
 		virtual IssmDouble MassFlux(IssmDouble* segment)=0;
+		virtual IssmDouble MassFlux(IssmDouble x1,IssmDouble y1, IssmDouble x2, IssmDouble y2,int segment_id)=0;
 		virtual void   ElementResponse(IssmDouble* presponse,int response_enum)=0;
 		virtual IssmDouble IceVolume(void)=0;
Index: /issm/trunk-jpl/src/c/classes/Elements/Penta.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/Elements/Penta.cpp	(revision 16387)
+++ /issm/trunk-jpl/src/c/classes/Elements/Penta.cpp	(revision 16388)
@@ -3739,4 +3739,28 @@
 	Tria* tria=(Tria*)SpawnTria(0); //lower face is 0, upper face is 1.
 	mass_flux=tria->MassFlux(segment);
+	delete tria->material; delete tria;
+
+	/*Delete Vx and Vy averaged*/
+	this->inputs->DeleteInput(VxAverageEnum);
+	this->inputs->DeleteInput(VyAverageEnum);
+
+	/*clean up and return*/
+	return mass_flux;
+}
+/*}}}*/
+/*FUNCTION Penta::MassFlux {{{*/
+IssmDouble Penta::MassFlux( IssmDouble x1, IssmDouble y1, IssmDouble x2, IssmDouble y2,int segment_id){
+
+	IssmDouble mass_flux=0;
+
+	if(!IsOnBed()) return mass_flux;
+
+	/*Depth Averaging Vx and Vy*/
+	this->InputDepthAverageAtBase(VxEnum,VxAverageEnum);
+	this->InputDepthAverageAtBase(VyEnum,VyAverageEnum);
+
+	/*Spawn Tria element from the base of the Penta: */
+	Tria* tria=(Tria*)SpawnTria(0); //lower face is 0, upper face is 1.
+	mass_flux=tria->MassFlux(x1,y1,x2,y2,segment_id);
 	delete tria->material; delete tria;
 
Index: /issm/trunk-jpl/src/c/classes/Elements/Penta.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/Elements/Penta.h	(revision 16387)
+++ /issm/trunk-jpl/src/c/classes/Elements/Penta.h	(revision 16388)
@@ -122,4 +122,5 @@
 		void   MinVz(IssmDouble* pminvz);
 		IssmDouble MassFlux(IssmDouble* segment);
+		IssmDouble MassFlux(IssmDouble x1,IssmDouble y1, IssmDouble x2, IssmDouble y2,int segment_id);
 		void   MaxAbsVx(IssmDouble* pmaxabsvx);
 		void   MaxAbsVy(IssmDouble* pmaxabsvy);
Index: /issm/trunk-jpl/src/c/classes/Elements/Seg.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/Elements/Seg.h	(revision 16387)
+++ /issm/trunk-jpl/src/c/classes/Elements/Seg.h	(revision 16388)
@@ -135,4 +135,5 @@
 		void       MinVz(IssmDouble* pminvz){_error_("not implemented yet");};
 		IssmDouble MassFlux(IssmDouble* segment){_error_("not implemented yet");};
+		IssmDouble MassFlux(IssmDouble x1,IssmDouble y1, IssmDouble x2, IssmDouble y2,int segment_id){_error_("not implemented yet");}
 		void       MaxAbsVx(IssmDouble* pmaxabsvx){_error_("not implemented yet");};
 		void       MaxAbsVy(IssmDouble* pmaxabsvy){_error_("not implemented yet");};
Index: /issm/trunk-jpl/src/c/classes/Elements/Tria.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/Elements/Tria.cpp	(revision 16387)
+++ /issm/trunk-jpl/src/c/classes/Elements/Tria.cpp	(revision 16388)
@@ -2889,4 +2889,68 @@
 	/*Return: */
 	return base*(surface-bed+min(rho_water/rho_ice*bathymetry,0.));
+}
+/*}}}*/
+/*FUNCTION Tria::MassFlux {{{*/
+IssmDouble Tria::MassFlux( IssmDouble x1, IssmDouble y1, IssmDouble x2, IssmDouble y2,int segment_id){
+
+	int        meshtype;
+	IssmDouble mass_flux=0.;
+	IssmDouble xyz_list[NUMVERTICES][3];
+	IssmDouble normal[2];
+	IssmDouble length,rho_ice;
+	IssmDouble h1,h2;
+	IssmDouble vx1,vx2,vy1,vy2;
+	GaussTria* gauss_1=NULL;
+	GaussTria* gauss_2=NULL;
+
+	/*Get material parameters :*/
+	rho_ice=matpar->GetRhoIce();
+
+	/*First off, check that this segment belongs to this element: */
+	if (segment_id!=this->id)_error_("error message: segment with id " << segment_id << " does not belong to element with id:" << this->id);
+
+	/*Get xyz list: */
+	GetVerticesCoordinates(&xyz_list[0][0],vertices,NUMVERTICES);
+
+	/*get area coordinates of 0 and 1 locations: */
+	gauss_1=new GaussTria();
+	gauss_1->GaussFromCoords(x1,y1,&xyz_list[0][0]);
+	gauss_2=new GaussTria();
+	gauss_2->GaussFromCoords(x2,y2,&xyz_list[0][0]);
+
+	normal[0]=cos(atan2(x1-x2,y2-y1));
+	normal[1]=sin(atan2(x1-x2,y2-y1));
+
+	length=sqrt(pow(x2-x1,2)+pow(y2-y1,2));
+
+	Input* thickness_input=inputs->GetInput(ThicknessEnum); _assert_(thickness_input);
+	this->parameters->FindParam(&meshtype,MeshTypeEnum);
+	Input* vx_input=NULL;
+	Input* vy_input=NULL;
+	if(meshtype==Mesh2DhorizontalEnum){
+		vx_input=inputs->GetInput(VxEnum); _assert_(vx_input);
+		vy_input=inputs->GetInput(VyEnum); _assert_(vy_input);
+	}
+	else{
+		vx_input=inputs->GetInput(VxAverageEnum); _assert_(vx_input);
+		vy_input=inputs->GetInput(VyAverageEnum); _assert_(vy_input);
+	}
+
+	thickness_input->GetInputValue(&h1, gauss_1);
+	thickness_input->GetInputValue(&h2, gauss_2);
+	vx_input->GetInputValue(&vx1,gauss_1);
+	vx_input->GetInputValue(&vx2,gauss_2);
+	vy_input->GetInputValue(&vy1,gauss_1);
+	vy_input->GetInputValue(&vy2,gauss_2);
+
+	mass_flux= rho_ice*length*(  
+				(ONETHIRD*(h1-h2)*(vx1-vx2)+0.5*h2*(vx1-vx2)+0.5*(h1-h2)*vx2+h2*vx2)*normal[0]+
+				(ONETHIRD*(h1-h2)*(vy1-vy2)+0.5*h2*(vy1-vy2)+0.5*(h1-h2)*vy2+h2*vy2)*normal[1]
+				);
+
+	/*clean up and return:*/
+	delete gauss_1;
+	delete gauss_2;
+	return mass_flux;
 }
 /*}}}*/
Index: /issm/trunk-jpl/src/c/classes/Elements/Tria.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/Elements/Tria.h	(revision 16387)
+++ /issm/trunk-jpl/src/c/classes/Elements/Tria.h	(revision 16388)
@@ -123,4 +123,5 @@
 		void       MinVz(IssmDouble* pminvz);
 		IssmDouble MassFlux(IssmDouble* segment);
+		IssmDouble MassFlux(IssmDouble x1,IssmDouble y1, IssmDouble x2, IssmDouble y2,int segment_id);
 		void       MaxAbsVx(IssmDouble* pmaxabsvx);
 		void       MaxAbsVy(IssmDouble* pmaxabsvy);
Index: /issm/trunk-jpl/src/c/classes/ExternalResults/GenericExternalResult.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/ExternalResults/GenericExternalResult.h	(revision 16387)
+++ /issm/trunk-jpl/src/c/classes/ExternalResults/GenericExternalResult.h	(revision 16388)
@@ -23,5 +23,6 @@
 	private: 
 		int        id;
-		int        enum_type;
+		int        enum_type; //in case we have an identifiable enum for this result
+		char*      enum_string;  //in case this result is only identifiable by a unique string, though arbitrary.
 		ResultType value;
 		int        M;
@@ -34,5 +35,6 @@
 		void GenericEcho(void){/*{{{*/
 			_printf_("   id: " << this->id << "\n");
-			_printf_("   enum:  " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")\n");
+			if(this->enum_type!=-1)_printf_("   enum:  " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")\n");
+			else _printf_("   string identified:  " << this->enum_string );
 			_printf_("   step: " << this->step << "\n");
 			_printf_("   time: " << this->time << "\n");
@@ -46,5 +48,8 @@
 
 			/*First write enum: */
-			EnumToStringx(&name,this->enum_type);
+			if(this->enum_type!=-1)EnumToStringx(&name,this->enum_type);
+			else{
+				name=xNew<char>(strlen(this->enum_string)+1); xMemCpy<char>(name,enum_string,strlen(this->enum_string)+1);
+			}
 			length=(strlen(name)+1)*sizeof(char);
 			fwrite(&length,sizeof(int),1,fid);
@@ -61,5 +66,6 @@
 		GenericExternalResult(){ /*{{{*/
 			id        = 0;
-			enum_type = NoneEnum;
+			enum_type = -1;
+			enum_string= NULL;
 			M         = 0;
 			N         = 0;
@@ -69,5 +75,6 @@
 		GenericExternalResult(int in_id, int in_enum_type,ResultType in_values, int in_M,int in_N,int in_step,IssmDouble in_time){/*{{{*/
 			id        = 0;
-			enum_type = NoneEnum;
+			enum_type = -1;
+			enum_string=NULL;
 			M         = 0;
 			N         = 0;
@@ -80,4 +87,5 @@
 			id        = in_id;
 			enum_type = in_enum_type;
+			enum_string = NULL;
 			value     = in_value;
 			step      = in_step;
@@ -85,5 +93,15 @@
 		}
 		/*}}}*/
+		GenericExternalResult(int in_id, char* in_enum_string,ResultType in_value,int in_step, IssmDouble in_time){ /*{{{*/
+			id        = in_id;
+			enum_type = -1;
+			enum_string = xNew<char>(strlen(in_enum_string)+1); xMemCpy<char>(enum_string,in_enum_string,strlen(in_enum_string)+1);
+			value     = in_value;
+			step      = in_step;
+			time      = in_time;
+		}
+		/*}}}*/
 		~GenericExternalResult(){ /*{{{*/
+			if(enum_string)xDelete<char>(enum_string);
 		} /*}}}*/
 
@@ -104,5 +122,6 @@
 		} /*}}}*/
 		Object* copy(void) { /*{{{*/
-			return new GenericExternalResult<ResultType>(this->id,this->enum_type,this->value,this->step,this->time);
+			if(enum_type!=-1) return new GenericExternalResult<ResultType>(this->id,this->enum_type,this->value,this->step,this->time);
+			else              return new GenericExternalResult<ResultType>(this->id,this->enum_string,this->value,this->step,this->time);
 		} /*}}}*/
 
@@ -136,5 +155,9 @@
 } /*}}}*/
 void GetResultName(char** pname){ /*{{{*/
-	EnumToStringx(pname,this->enum_type);
+	if(this->enum_type!=-1)EnumToStringx(pname,this->enum_type);
+	else{
+		char* name=xNew<char>(strlen(enum_string)+1); xMemCpy<char>(name,enum_string,strlen(enum_string)+1);
+		*pname=name;
+	}
 } /*}}}*/
 int GetStep(void){ /*{{{*/
Index: /issm/trunk-jpl/src/c/classes/FemModel.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/FemModel.cpp	(revision 16387)
+++ /issm/trunk-jpl/src/c/classes/FemModel.cpp	(revision 16388)
@@ -13,4 +13,5 @@
 #include "../shared/io/io.h"
 #include "./classes.h"
+#include "./modules/modules.h"
 #include "../shared/Enum/Enum.h"
 
@@ -503,4 +504,9 @@
 				results->AddObject(new GenericExternalResult<double>(results->Size()+1,MaxVelEnum,reCast<IssmPDouble>(output_value),step,time));
 			}
+			else if (StringToEnumx(output_string,false)==-1){
+				/*This response can only be computed by going into the output definitions: */
+				output_value=OutputDefinitionsResponsex(this,output_string);
+				results->AddObject(new GenericExternalResult<double>(results->Size()+1,output_string,reCast<IssmPDouble>(output_value),step,time));
+			}
 			else{
 				/*create this output in the element inputs, and then transfer to results:*/
Index: /issm/trunk-jpl/src/c/classes/IoModel.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/IoModel.cpp	(revision 16387)
+++ /issm/trunk-jpl/src/c/classes/IoModel.cpp	(revision 16388)
@@ -1080,4 +1080,173 @@
 }
 /*}}}*/
+/*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;
+	int* codes=NULL;
+
+	/*output: */
+	int   numstrings=0;
+	char** strings=NULL;
+
+	/*intermediary: */
+	char* string=NULL;
+	int   string_size;
+	int*   code=NULL;
+	fpos_t* file_positions=NULL;
+
+	/*recover my_rank:*/
+	my_rank=IssmComm::GetRank();
+
+	/*Get file pointers to beginning of the data (multiple instances of it): */
+	file_positions=this->SetFilePointersToData(&codes,NULL,&num_instances,data_enum);
+
+	if(num_instances){
+
+		strings=xNew<char*>(num_instances);
+
+
+		for(i=0;i<num_instances;i++){
+
+			fsetpos(fid,file_positions+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,fid)!=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,fid)!=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;
+		}
+
+	}
+	/*Free ressources:*/
+	xDelete<int>(codes);
+	
+	/*Assign output pointers: */
+	*pstrings=strings;
+	*pnumstrings=num_instances;
+}
+/*}}}*/
+/*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;
+	
+	fpos_t* file_positions=NULL;
+
+	/*output: */
+	IssmDouble** matrices=NULL;
+	int*     mdims=NULL;
+	int*     ndims=NULL;
+
+	/*intermediary: */
+	int     M, N;
+	IssmPDouble *pmatrix = NULL;
+	IssmDouble *matrix = NULL;
+	int*    codes=NULL;
+	int     code;
+
+	/*recover my_rank:*/
+	my_rank=IssmComm::GetRank();
+	
+	/*Get file pointers to beginning of the data (multiple instances of it): */
+	file_positions=this->SetFilePointersToData(&codes,NULL,&num_instances,data_enum);
+
+	if(num_instances){
+
+		/*Allocate matrices :*/
+		matrices=xNew<IssmDouble*>(num_instances);
+		mdims=xNew<int>(num_instances);
+		ndims=xNew<int>(num_instances);
+
+		for(i=0;i<num_instances;i++){
+
+			fsetpos(fid,file_positions+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,fid)!=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,fid)!=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,fid)!=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>(pmatrix);
+			}
+			else
+				matrix=NULL;
+			
+			
+			/*Assign: */
+			mdims[i]=M;
+			matrices[i]=matrix;
+			ndims[i]=N;
+		}
+	}
+			
+	/*Free ressources:*/
+	xDelete<int>(codes);
+
+	/*Assign output pointers: */
+	*pmatrices=matrices;
+	if(pmdims)*pmdims=mdims;
+	if(pndims)*pndims=ndims;
+	*pnumrecords=num_instances;
+}
+/*}}}*/
 /*FUNCTION IoModel::FetchDataToInput(Elements* elements,int vector_enum,IssmDouble default_value){{{*/
 void IoModel::FetchDataToInput(Elements* elements,int vector_enum,IssmDouble default_value){
@@ -1272,5 +1441,4 @@
 	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:*/
@@ -1281,2 +1449,105 @@
 }
 /*}}}*/
+/*FUNCTION IoModel::SetFilePointersToData{{{*/
+fpos_t* 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;
+	fpos_t* file_positions=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_positions = xNew<fpos_t>(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;
+				fgetpos(fid,file_positions+counter);
+				
+				/*backup and skip over the record, as we have more work to do: */
+				if(5<=record_code && record_code<=7) fseek(fid,-sizeof(int),SEEK_CUR);
+				fseek(fid,-sizeof(int),SEEK_CUR);
+				fseek(fid,-sizeof(int),SEEK_CUR);
+				
+				/*increment counter: */
+				counter++;
+			}
+
+			/*Read the record length, and use it to skip this record, as it has already been processed: */
+			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_positions;
+}
+/*}}}*/
Index: /issm/trunk-jpl/src/c/classes/IoModel.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/IoModel.h	(revision 16387)
+++ /issm/trunk-jpl/src/c/classes/IoModel.h	(revision 16388)
@@ -77,4 +77,6 @@
 		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,4 +85,5 @@
 		void        LastIndex(int *pindex);
 		FILE*       SetFilePointerToData(int* pcode,int* pvector_type, int data_enum);
+		fpos_t*     SetFilePointersToData(int** pcodes,int** pvector_types, int* pnum_instances, int data_enum);
 		void        DeclareIndependents(void);
 		void        StartTrace(void);
Index: /issm/trunk-jpl/src/c/classes/Massfluxatgate.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/Massfluxatgate.h	(revision 16388)
+++ /issm/trunk-jpl/src/c/classes/Massfluxatgate.h	(revision 16388)
@@ -0,0 +1,166 @@
+/*!\file Massfluxatgate.h
+ * \brief: header file for Massfluxatgate object
+ */
+
+#ifndef _MASSFLUXATGATE_H_
+#define _MASSFLUXATGATE_H_
+
+/*Headers:*/
+/*{{{*/
+#include "./Definition.h"
+#include "../datastructures/datastructures.h"
+#include "./Elements/Element.h"
+#include "./Elements/Elements.h"
+#include "./FemModel.h"
+/*}}}*/
+
+template <class doubletype> 
+class Massfluxatgate: public Object, public Definition{
+
+	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) {
+			
+			int i;
+
+			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]=reCast<int,doubletype>(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->x1,this->y1,this->x2,this->y2,this->elements); 
+		}
+		/*}}}*/
+		/*Definition virtual function resolutoin: */
+		/*FUNCTION char* Name() {{{*/
+		char*  Name(){
+			char* name2=NULL;
+
+			name2=xNew<char>(strlen(this->name)+1);
+			xMemCpy(name2,this->name,strlen(this->name)+1);
+
+			return name2;
+		}
+		/*}}}*/
+		/*FUNCTION doubletype* Response(FemModel* femmodel) {{{*/
+		 IssmDouble Response(FemModel* femmodel){
+
+			int          i,j;
+			Element     *element       = NULL;
+			IssmDouble mass_flux     = 0;
+			IssmDouble all_mass_flux = 0;
+
+			/*Go through segments, and then elements, and figure out which elements belong to a segment. 
+			 * When we find one, use the element to compute the mass flux on the segment: */
+			for(i=0;i<numsegments;i++){
+				for(j=0;j<femmodel->elements->Size();j++){
+					element=(Element*)femmodel->elements->GetObjectByOffset(j);
+					if (element->Id()==this->elements[i]){
+						/*We found the element which owns this segment, use it to compute the mass flux: */
+						mass_flux+=element->MassFlux(x1[i],y1[i],x2[i],y2[i],elements[i]);
+						break;
+					}
+				}
+			}
+
+			ISSM_MPI_Allreduce ( (void*)&mass_flux,(void*)&all_mass_flux,1,ISSM_MPI_DOUBLE,ISSM_MPI_SUM,IssmComm::GetComm());
+			mass_flux=all_mass_flux;
+			return mass_flux;
+		}
+			/*}}}*/
+};
+
+#endif  /* _MASSFLUXATGATE_H_ */
Index: /issm/trunk-jpl/src/c/classes/classes.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/classes.h	(revision 16387)
+++ /issm/trunk-jpl/src/c/classes/classes.h	(revision 16388)
@@ -17,4 +17,5 @@
 #include "./IndependentObject.h"
 #include "./Segment.h"
+#include "./Massfluxatgate.h"
 
 /*Constraints: */
Index: /issm/trunk-jpl/src/c/modules/ModelProcessorx/CreateOutputDefinitions.cpp
===================================================================
--- /issm/trunk-jpl/src/c/modules/ModelProcessorx/CreateOutputDefinitions.cpp	(revision 16388)
+++ /issm/trunk-jpl/src/c/modules/ModelProcessorx/CreateOutputDefinitions.cpp	(revision 16388)
@@ -0,0 +1,64 @@
+/*!\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 CreateOutputDefinitions(Parameters** pparameters,IoModel* iomodel){
+
+	int i,j;
+	
+	Parameters *parameters = NULL;
+	DataSet* output_definitions=NULL;
+	int*     output_definition_enums;
+	int      num_output_definitions;
+	int      numgates;
+	char**   gatenames=NULL;
+	IssmDouble** gatesegments=NULL;
+	int*         gatesegments_M=NULL;
+
+	/*Get parameters: */
+	parameters=*pparameters;
+
+	/*Create output_definitions dataset: */
+	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){
+				/*Deal with mass flux gates:{{{ */
+
+				/*Fetch segments and names: */
+				iomodel->FetchMultipleData(&gatenames,&numgates,MassfluxatgateNameEnum);
+				iomodel->FetchMultipleData(&gatesegments,&gatesegments_M,NULL,&numgates,MassfluxatgateSegmentsEnum);
+
+				for(j=0;j<numgates;j++){
+					output_definitions->AddObject(new Massfluxatgate<IssmDouble>(gatenames[j],gatesegments_M[j],gatesegments[j]));
+				}
+				/*Free ressources:*/
+				for(j=0;j<numgates;j++){
+					char* string=gatenames[j]; xDelete<char>(string);
+					IssmDouble* gate=gatesegments[j]; xDelete<IssmDouble>(gate);
+				}
+				xDelete<char*>(gatenames);
+				xDelete<IssmDouble*>(gatesegments);
+				xDelete<int>(gatesegments_M);
+				/*}}}*/
+			}
+			else _error_("output definition enum " << output_definition_enums[i] << "not supported yet!");
+		}
+	}
+	parameters->AddObject(new DataSetParam(OutputdefinitionEnum,output_definitions));
+
+	/*Free ressources:*/
+	delete output_definitions;
+	xDelete<int>(output_definition_enums);
+
+	/*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 16387)
+++ /issm/trunk-jpl/src/c/modules/ModelProcessorx/CreateParameters.cpp	(revision 16388)
@@ -214,4 +214,7 @@
 	/*}}}*/
 
+	/*Output definitions dataset: */
+	CreateOutputDefinitions(&parameters,iomodel);
+
 	/*Solution specific parameters*/
 	#ifdef _HAVE_HYDROLOGY_
Index: /issm/trunk-jpl/src/c/modules/ModelProcessorx/ModelProcessorx.h
===================================================================
--- /issm/trunk-jpl/src/c/modules/ModelProcessorx/ModelProcessorx.h	(revision 16387)
+++ /issm/trunk-jpl/src/c/modules/ModelProcessorx/ModelProcessorx.h	(revision 16388)
@@ -23,4 +23,5 @@
 void CreateParametersHydrologyDCInefficient(Parameters** pparameters,IoModel* iomodel,int solution_type,int analysis_type);
 void CreateParametersHydrologyDCEfficient(Parameters** pparameters,IoModel* iomodel,int solution_type,int analysis_type);
+void CreateOutputDefinitions(Parameters** pparameters,IoModel* iomodel);
 void UpdateElementsAndMaterialsControl(Elements* elements,Materials* materials, IoModel* iomodel);
 void UpdateElementsAndMaterialsDakota(Elements* elements,Materials* materials, IoModel* iomodel);
Index: /issm/trunk-jpl/src/c/modules/OutputDefinitionsResponsex/OutputDefinitionsResponsex.cpp
===================================================================
--- /issm/trunk-jpl/src/c/modules/OutputDefinitionsResponsex/OutputDefinitionsResponsex.cpp	(revision 16388)
+++ /issm/trunk-jpl/src/c/modules/OutputDefinitionsResponsex/OutputDefinitionsResponsex.cpp	(revision 16388)
@@ -0,0 +1,35 @@
+/*!\file OutputDefinitionsResponsex
+ * \brief retrieve vector from inputs in elements
+ */
+
+#include "./OutputDefinitionsResponsex.h"
+#include "../../shared/shared.h"
+#include "../../toolkits/toolkits.h"
+#include "../../classes/classes.h"
+
+IssmDouble OutputDefinitionsResponsex(FemModel* femmodel,char* output_string){
+
+	int i;
+	Definition* definition=NULL;
+	DataSet* output_definitions=NULL;
+	IssmDouble return_value;
+
+	/*Ok, go find the output definitions dataset in the parameters, where our responses are hiding: */
+	femmodel->parameters->FindParam(&output_definitions,OutputdefinitionEnum); _assert_(output_definitions);
+
+	/*Now, go through the output definitions, and retrieve the object which corresponds to our requested response, output_string: */
+	for (i=0;i<output_definitions->Size();i++){
+		
+		definition=dynamic_cast<Definition*>(output_definitions->GetObjectByOffset(i));
+
+		if (strcmp(definition->Name(),output_string)==0){
+			/*This is the object that we have been chasing for. compute the response and return: */
+			return_value=definition->Response(femmodel);
+			delete output_definitions;
+			return return_value;
+		}
+	}
+	/*If we are here, did not find the definition for this response, not good!: */
+	_error_("Could not find the response for output definition " << output_string << " because could not find the definition itself!");
+
+}
Index: /issm/trunk-jpl/src/c/modules/OutputDefinitionsResponsex/OutputDefinitionsResponsex.h
===================================================================
--- /issm/trunk-jpl/src/c/modules/OutputDefinitionsResponsex/OutputDefinitionsResponsex.h	(revision 16388)
+++ /issm/trunk-jpl/src/c/modules/OutputDefinitionsResponsex/OutputDefinitionsResponsex.h	(revision 16388)
@@ -0,0 +1,12 @@
+/*!\file:  OutputDefinitionsResponsexx.h
+*/ 
+
+#ifndef _OUTPUTDEFINITIONSRESPONSEXX_H
+#define _OUTPUTDEFINITIONSRESPONSEXX_H
+
+#include "../../classes/classes.h"
+
+/* local prototypes: */
+IssmDouble OutputDefinitionsResponsex(FemModel* femmodel,char* output_string);
+
+#endif  /* _OUTPUTDEFINITIONSRESPONSEXX_H */
Index: /issm/trunk-jpl/src/c/modules/modules.h
===================================================================
--- /issm/trunk-jpl/src/c/modules/modules.h	(revision 16387)
+++ /issm/trunk-jpl/src/c/modules/modules.h	(revision 16388)
@@ -72,4 +72,5 @@
 #include "./NodesDofx/NodesDofx.h"
 #include "./Orthx/Orthx.h"
+#include "./OutputDefinitionsResponsex/OutputDefinitionsResponsex.h"
 #include "./OutputResultsx/OutputResultsx.h"
 #include "./ConstraintsStatex/ConstraintsStatex.h"
Index: /issm/trunk-jpl/src/c/shared/Enum/EnumDefinitions.h
===================================================================
--- /issm/trunk-jpl/src/c/shared/Enum/EnumDefinitions.h	(revision 16387)
+++ /issm/trunk-jpl/src/c/shared/Enum/EnumDefinitions.h	(revision 16388)
@@ -546,4 +546,11 @@
 	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 16387)
+++ /issm/trunk-jpl/src/c/shared/Enum/EnumToStringx.cpp	(revision 16388)
@@ -535,4 +535,9 @@
 		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 16387)
+++ /issm/trunk-jpl/src/c/shared/Enum/StringToEnumx.cpp	(revision 16388)
@@ -547,4 +547,9 @@
 	      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/massfluxatgate.m
===================================================================
--- /issm/trunk-jpl/src/m/classes/massfluxatgate.m	(revision 16388)
+++ /issm/trunk-jpl/src/m/classes/massfluxatgate.m	(revision 16388)
@@ -0,0 +1,64 @@
+%MASSFLUXATGATE class definition
+%
+%   Usage:
+%      massfluxatgate=massfluxatgate();
+%      massfluxatgate=massfluxatgate('GateName','PathToExpFile');
+
+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/massfluxatgate.py
===================================================================
--- /issm/trunk-jpl/src/m/classes/massfluxatgate.py	(revision 16388)
+++ /issm/trunk-jpl/src/m/classes/massfluxatgate.py	(revision 16388)
@@ -0,0 +1,55 @@
+from fielddisplay import fielddisplay
+from EnumDefinitions import *
+from checkfield import *
+from WriteData import *
+from MeshProfileIntersection import *
+import os
+
+class massfluxatgate(object):
+	"""
+	MASSFLUXATEGATE class definition
+
+	   Usage:
+		  massfluxatgate=massfluxatgate('GateName','PathToExpFile')
+	"""
+
+	def __init__(self,name,profilename): # {{{
+		self.name           = name
+		self.profilename    = profilename
+		self.segments       = float('NaN')
+
+		#}}}
+	def __repr__(self): # {{{
+
+		string="   Massfluxatgate:"
+		string="%s\n%s"%(string,fielddisplay(self,'name','identifier for this massfluxatgate response'))
+		string="%s\n%s"%(string,fielddisplay(self,'profilename','name of file (shapefile or argus file) defining a profile (or gate)'))
+		return string
+		#}}}
+	def setdefaultparameters(self): # {{{
+		return self
+	#}}}
+	def checkconsistency(self,md,solution,analyses):    # {{{
+		
+		if  not isinstance(self.name, basestring):
+			raise RuntimeError("massfluxatgate error message: 'name' field should be a string!")
+			
+		if  not isinstance(self.profilename, basestring):
+			raise RuntimeError("massfluxatgate error message: 'profilename' field should be a string!") 
+		
+		#check the profilename points to a file!: 
+		if not os.path.isfile(self.profilename):
+			raise RuntimeError("massfluxatgate error message: file name for profile corresponding to gate does not point to a legitimate file on disk!")
+
+		return md
+	# }}}
+	def marshall(self,md,fid):    # {{{
+		
+		#before marshalling, we need to create the segments out of the profilename: 
+		self.segments=MeshProfileIntersection(md.mesh.elements,md.mesh.x,md.mesh.y,self.profilename)
+
+		#ok, marshall name and segments: 
+		WriteData(fid,'object',self,'fieldname','name','format','String')
+		WriteData(fid,'object',self,'fieldname','segments','format','DoubleMat','mattype',1)
+
+	# }}}
Index: /issm/trunk-jpl/src/m/classes/masstransport.py
===================================================================
--- /issm/trunk-jpl/src/m/classes/masstransport.py	(revision 16387)
+++ /issm/trunk-jpl/src/m/classes/masstransport.py	(revision 16388)
@@ -66,5 +66,5 @@
 		md = checkfield(md,'masstransport.min_thickness','>',0)
 		if md.masstransport.requested_outputs:
-			md = checkfield(md,'masstransport.requested_outputs','size',[1, float('NaN')])
+			md = checkfield(md,'masstransport.requested_outputs','cell',1)
 
 		return md
Index: /issm/trunk-jpl/src/m/classes/model.m
===================================================================
--- /issm/trunk-jpl/src/m/classes/model.m	(revision 16387)
+++ /issm/trunk-jpl/src/m/classes/model.m	(revision 16388)
@@ -45,4 +45,5 @@
 
 		results          = 0;
+		outputdefinition = 0;
 		radaroverlay     = 0;
 		miscellaneous    = 0;
@@ -1078,4 +1079,5 @@
 			md.radaroverlay     = radaroverlay();
 			md.results          = struct();
+			md.outputdefinition = outputdefinition();
 			md.miscellaneous    = miscellaneous();
 			md.private          = private();
@@ -1114,4 +1116,5 @@
 			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: /issm/trunk-jpl/src/m/classes/model.py
===================================================================
--- /issm/trunk-jpl/src/m/classes/model.py	(revision 16387)
+++ /issm/trunk-jpl/src/m/classes/model.py	(revision 16388)
@@ -33,4 +33,5 @@
 from flaim import flaim
 from inversion import inversion
+from outputdefinition import outputdefinition
 from qmu import qmu
 from results import results
@@ -88,4 +89,5 @@
 
 		self.results          = results()
+		self.outputdefinition = outputdefinition()
 		self.radaroverlay     = radaroverlay()
 		self.miscellaneous    = miscellaneous()
@@ -125,4 +127,5 @@
 		        'inversion',\
 		        'qmu',\
+		        'outputdefinition',\
 		        'results',\
 		        'radaroverlay',\
@@ -162,4 +165,5 @@
 		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("inversion","[%s,%s]" % ("1x1",obj.inversion.__class__.__name__),"parameters for inverse methods"))
 		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("qmu","[%s,%s]" % ("1x1",obj.qmu.__class__.__name__),"dakota properties"))
+		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("outputdefinition","[%s,%s]" % ("1x1",obj.outputdefinition.__class__.__name__),"output definition"))
 		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("results","[%s,%s]" % ("1x1",obj.results.__class__.__name__),"model results"))
 		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("radaroverlay","[%s,%s]" % ("1x1",obj.radaroverlay.__class__.__name__),"radar image for plot overlay"))
Index: /issm/trunk-jpl/src/m/classes/outputdefinition.m
===================================================================
--- /issm/trunk-jpl/src/m/classes/outputdefinition.m	(revision 16388)
+++ /issm/trunk-jpl/src/m/classes/outputdefinition.m	(revision 16388)
@@ -0,0 +1,56 @@
+%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);
+			classdefinition=class(obj.definitions{i});
+			classdefinition(1)=upper(classdefinition(1)); %so it matches our enums definitions.
+			obj.enums(i)=StringToEnum(classdefinition);
+		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/outputdefinition.py
===================================================================
--- /issm/trunk-jpl/src/m/classes/outputdefinition.py	(revision 16388)
+++ /issm/trunk-jpl/src/m/classes/outputdefinition.py	(revision 16388)
@@ -0,0 +1,51 @@
+from fielddisplay import fielddisplay
+from EnumDefinitions import *
+from StringToEnum import StringToEnum
+from checkfield import *
+from WriteData import *
+import numpy as npy
+
+class outputdefinition(object):
+	"""
+	OUTPUTDEFINITION class definition
+
+	   Usage:
+	      outputdefinition=outputdefinition();
+	"""
+
+	def __init__(self): # {{{
+		self.definitions                   = []
+		self.enums                         = float('NaN')
+		#}}}
+	def __repr__(self): # {{{
+		string="   Outputdefinitions:"
+
+		string="%s\n%s"%(string,fielddisplay(self,"definitions","list of potential outputs that can be requested, but which need additional data to be defined"))
+
+		return string
+		#}}}
+	def setdefaultparameters(self): # {{{
+		return self
+		#}}}
+	def checkconsistency(self,md,solution,analyses):    # {{{
+		
+		md = checkfield(md,'outputdefinition.definitions','cell',1)
+		for definition in self.definitions:
+			definition.checkconsistency(md,solution,analyses);
+
+	# }}}
+	def marshall(self,md,fid):    # {{{
+		
+		self.enums=npy.zeros(len(self.definitions),)
+		
+		for i in range(len(self.definitions)):
+			self.definitions[i].marshall(md,fid);
+			classdefinition=self.definitions[i].__class__.__name__
+			classdefinition=classdefinition[0].upper()+classdefinition[1:]
+			self.enums[i]=StringToEnum(classdefinition)[0]
+		
+		self.enums=npy.unique(self.enums);
+		
+		WriteData(fid,'object',self,'fieldname','enums','format','DoubleMat','mattype',1)
+
+	# }}}
Index: /issm/trunk-jpl/src/m/classes/steadystate.py
===================================================================
--- /issm/trunk-jpl/src/m/classes/steadystate.py	(revision 16387)
+++ /issm/trunk-jpl/src/m/classes/steadystate.py	(revision 16388)
@@ -52,5 +52,5 @@
 
 		if md.steadystate.requested_outputs:
-			md = checkfield(md,'steadystate.requested_outputs','size',[1, float('nan')])
+			md = checkfield(md,'steadystate.requested_outputs','cell',1)
 
 		return md
Index: /issm/trunk-jpl/src/m/classes/stressbalance.py
===================================================================
--- /issm/trunk-jpl/src/m/classes/stressbalance.py	(revision 16387)
+++ /issm/trunk-jpl/src/m/classes/stressbalance.py	(revision 16388)
@@ -124,5 +124,5 @@
 		md = checkfield(md,'stressbalance.loadingforce','size',[md.mesh.numberofvertices,3])
 		if md.stressbalance.requested_outputs:
-			md = checkfield(md,'stressbalance.requested_outputs','size',[1, float('NaN')])
+			md = checkfield(md,'stressbalance.requested_outputs','cell',1);
 
 		#singular solution
Index: /issm/trunk-jpl/src/m/classes/transient.py
===================================================================
--- /issm/trunk-jpl/src/m/classes/transient.py	(revision 16387)
+++ /issm/trunk-jpl/src/m/classes/transient.py	(revision 16388)
@@ -57,5 +57,5 @@
 		md = checkfield(md,'transient.isgia','numel',[1],'values',[0,1])
 		if md.transient.requested_outputs:
-			md = checkfield(md,'transient.requested_outputs','size',[1, float('nan')])
+			md = checkfield(md,'transient.requested_outputs','cell',1)
 
 		return md
Index: /issm/trunk-jpl/src/m/enum/EnumDefinitions.py
===================================================================
--- /issm/trunk-jpl/src/m/enum/EnumDefinitions.py	(revision 16387)
+++ /issm/trunk-jpl/src/m/enum/EnumDefinitions.py	(revision 16388)
@@ -527,4 +527,9 @@
 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/MassfluxatgateEnum.m
===================================================================
--- /issm/trunk-jpl/src/m/enum/MassfluxatgateEnum.m	(revision 16388)
+++ /issm/trunk-jpl/src/m/enum/MassfluxatgateEnum.m	(revision 16388)
@@ -0,0 +1,11 @@
+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: /issm/trunk-jpl/src/m/enum/MassfluxatgateNameEnum.m
===================================================================
--- /issm/trunk-jpl/src/m/enum/MassfluxatgateNameEnum.m	(revision 16388)
+++ /issm/trunk-jpl/src/m/enum/MassfluxatgateNameEnum.m	(revision 16388)
@@ -0,0 +1,11 @@
+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: /issm/trunk-jpl/src/m/enum/MassfluxatgateSegmentsEnum.m
===================================================================
--- /issm/trunk-jpl/src/m/enum/MassfluxatgateSegmentsEnum.m	(revision 16388)
+++ /issm/trunk-jpl/src/m/enum/MassfluxatgateSegmentsEnum.m	(revision 16388)
@@ -0,0 +1,11 @@
+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: /issm/trunk-jpl/src/m/enum/OutputdefinitionEnum.m
===================================================================
--- /issm/trunk-jpl/src/m/enum/OutputdefinitionEnum.m	(revision 16388)
+++ /issm/trunk-jpl/src/m/enum/OutputdefinitionEnum.m	(revision 16388)
@@ -0,0 +1,11 @@
+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: /issm/trunk-jpl/src/m/enum/OutputdefinitionEnumsEnum.m
===================================================================
--- /issm/trunk-jpl/src/m/enum/OutputdefinitionEnumsEnum.m	(revision 16388)
+++ /issm/trunk-jpl/src/m/enum/OutputdefinitionEnumsEnum.m	(revision 16388)
@@ -0,0 +1,11 @@
+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/test/Par/SquareEISMINT.par
===================================================================
--- /issm/trunk-jpl/test/Par/SquareEISMINT.par	(revision 16387)
+++ /issm/trunk-jpl/test/Par/SquareEISMINT.par	(revision 16388)
@@ -46,2 +46,12 @@
 md.timestepping.final_time=500.;
 md.timestepping.time_step=1;
+
+%output definitions: 
+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'])...
+	};
Index: /issm/trunk-jpl/test/Par/SquareEISMINT.py
===================================================================
--- /issm/trunk-jpl/test/Par/SquareEISMINT.py	(revision 16387)
+++ /issm/trunk-jpl/test/Par/SquareEISMINT.py	(revision 16388)
@@ -1,4 +1,5 @@
 import numpy
 from SetMarineIceSheetBC import SetMarineIceSheetBC
+from massfluxatgate import massfluxatgate
 
 #Ok, start defining model parameters here
@@ -49,2 +50,12 @@
 md.timestepping.final_time=500.
 md.timestepping.time_step=1
+
+#output definitions: 
+md.outputdefinition.definitions=[
+		massfluxatgate('MassFlux1',os.getcwd() + '/../Exp/MassFlux1.exp'),
+		massfluxatgate('MassFlux2',os.getcwd() + '/../Exp/MassFlux2.exp'),
+		massfluxatgate('MassFlux3',os.getcwd() + '/../Exp/MassFlux3.exp'),
+		massfluxatgate('MassFlux4',os.getcwd() + '/../Exp/MassFlux4.exp'),
+		massfluxatgate('MassFlux5',os.getcwd() + '/../Exp/MassFlux5.exp'),
+		massfluxatgate('MassFlux6',os.getcwd() + '/../Exp/MassFlux6.exp')
+	]
Index: /issm/trunk-jpl/test/Par/SquareSheetConstrained.par
===================================================================
--- /issm/trunk-jpl/test/Par/SquareSheetConstrained.par	(revision 16387)
+++ /issm/trunk-jpl/test/Par/SquareSheetConstrained.par	(revision 16388)
@@ -66,2 +66,12 @@
 A=dbstack;
 if (length(A)>2), md.miscellaneous.name=A(3).file(1:end-2); end
+
+%output definitions: 
+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'])...
+	};
Index: /issm/trunk-jpl/test/Par/SquareSheetConstrained.py
===================================================================
--- /issm/trunk-jpl/test/Par/SquareSheetConstrained.py	(revision 16387)
+++ /issm/trunk-jpl/test/Par/SquareSheetConstrained.py	(revision 16388)
@@ -7,4 +7,5 @@
 from paterson import paterson
 from SetIceSheetBC import SetIceSheetBC
+from massfluxatgate import massfluxatgate
 
 #Start defining model parameters here
@@ -77,2 +78,11 @@
 	md.miscellaneous.name = os.path.basename(inspect.stack()[2][1]).split('.')[0]
 
+#output definitions: 
+md.outputdefinition.definitions=[
+		massfluxatgate('MassFlux1',os.getcwd() + '/../Exp/MassFlux1.exp'),
+		massfluxatgate('MassFlux2',os.getcwd() + '/../Exp/MassFlux2.exp'),
+		massfluxatgate('MassFlux3',os.getcwd() + '/../Exp/MassFlux3.exp'),
+		massfluxatgate('MassFlux4',os.getcwd() + '/../Exp/MassFlux4.exp'),
+		massfluxatgate('MassFlux5',os.getcwd() + '/../Exp/MassFlux5.exp'),
+		massfluxatgate('MassFlux6',os.getcwd() + '/../Exp/MassFlux6.exp')
+	]
Index: /issm/trunk-jpl/test/Par/SquareSheetShelf.par
===================================================================
--- /issm/trunk-jpl/test/Par/SquareSheetShelf.par	(revision 16387)
+++ /issm/trunk-jpl/test/Par/SquareSheetShelf.par	(revision 16388)
@@ -64,2 +64,12 @@
 A=dbstack;
 if (length(A)>2), md.miscellaneous.name=A(3).file(1:end-2); end
+
+%output definitions: 
+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'])...
+	};
Index: /issm/trunk-jpl/test/Par/SquareSheetShelf.py
===================================================================
--- /issm/trunk-jpl/test/Par/SquareSheetShelf.py	(revision 16387)
+++ /issm/trunk-jpl/test/Par/SquareSheetShelf.py	(revision 16388)
@@ -7,4 +7,5 @@
 from paterson import paterson 
 from SetMarineIceSheetBC import SetMarineIceSheetBC
+from massfluxatgate import massfluxatgate
 
 #Start defining model parameters here
@@ -75,2 +76,12 @@
 if len(inspect.stack()) > 2:
 	md.miscellaneous.name = os.path.basename(inspect.stack()[2][1]).split('.')[0]
+	
+#output definitions: 
+md.outputdefinition.definitions=[
+		massfluxatgate('MassFlux1',os.getcwd() + '/../Exp/MassFlux1.exp'),
+		massfluxatgate('MassFlux2',os.getcwd() + '/../Exp/MassFlux2.exp'),
+		massfluxatgate('MassFlux3',os.getcwd() + '/../Exp/MassFlux3.exp'),
+		massfluxatgate('MassFlux4',os.getcwd() + '/../Exp/MassFlux4.exp'),
+		massfluxatgate('MassFlux5',os.getcwd() + '/../Exp/MassFlux5.exp'),
+		massfluxatgate('MassFlux6',os.getcwd() + '/../Exp/MassFlux6.exp')
+	]
Index: /issm/trunk-jpl/test/Par/SquareShelf.par
===================================================================
--- /issm/trunk-jpl/test/Par/SquareShelf.par	(revision 16387)
+++ /issm/trunk-jpl/test/Par/SquareShelf.par	(revision 16388)
@@ -57,2 +57,12 @@
 A=dbstack;
 if (length(A)>2), md.miscellaneous.name=A(3).file(1:end-2); end
+
+%output definitions: 
+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'])...
+	};
Index: /issm/trunk-jpl/test/Par/SquareShelf.py
===================================================================
--- /issm/trunk-jpl/test/Par/SquareShelf.py	(revision 16387)
+++ /issm/trunk-jpl/test/Par/SquareShelf.py	(revision 16388)
@@ -7,4 +7,5 @@
 from paterson import paterson
 from SetIceShelfBC import SetIceShelfBC
+from massfluxatgate import massfluxatgate
 
 #Start defining model parameters here
@@ -88,2 +89,12 @@
 if len(inspect.stack()) > 2:
 	md.miscellaneous.name=os.path.basename(inspect.stack()[2][1]).split('.')[0]
+	
+#output definitions: 
+md.outputdefinition.definitions=[
+		massfluxatgate('MassFlux1',os.getcwd() + '/../Exp/MassFlux1.exp'),
+		massfluxatgate('MassFlux2',os.getcwd() + '/../Exp/MassFlux2.exp'),
+		massfluxatgate('MassFlux3',os.getcwd() + '/../Exp/MassFlux3.exp'),
+		massfluxatgate('MassFlux4',os.getcwd() + '/../Exp/MassFlux4.exp'),
+		massfluxatgate('MassFlux5',os.getcwd() + '/../Exp/MassFlux5.exp'),
+		massfluxatgate('MassFlux6',os.getcwd() + '/../Exp/MassFlux6.exp')
+	]
Index: /issm/trunk-jpl/test/Par/SquareShelf2.par
===================================================================
--- /issm/trunk-jpl/test/Par/SquareShelf2.par	(revision 16387)
+++ /issm/trunk-jpl/test/Par/SquareShelf2.par	(revision 16388)
@@ -57,2 +57,12 @@
 A=dbstack;
 if (length(A)>2), md.miscellaneous.name=A(3).file(1:end-2); end
+
+%output definitions: 
+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'])...
+	};
Index: /issm/trunk-jpl/test/Par/SquareShelf2.py
===================================================================
--- /issm/trunk-jpl/test/Par/SquareShelf2.py	(revision 16387)
+++ /issm/trunk-jpl/test/Par/SquareShelf2.py	(revision 16388)
@@ -7,4 +7,5 @@
 from paterson import paterson
 from SetIceShelfBC import SetIceShelfBC
+from massfluxatgate import massfluxatgate
 
 #Start defining model parameters here
@@ -88,2 +89,12 @@
 if len(inspect.stack()) > 2:
 	md.miscellaneous.name=os.path.basename(inspect.stack()[2][1]).split('.')[0]
+	
+#output definitions: 
+md.outputdefinition.definitions=[
+		massfluxatgate('MassFlux1',os.getcwd() + '/../Exp/MassFlux1.exp'),
+		massfluxatgate('MassFlux2',os.getcwd() + '/../Exp/MassFlux2.exp'),
+		massfluxatgate('MassFlux3',os.getcwd() + '/../Exp/MassFlux3.exp'),
+		massfluxatgate('MassFlux4',os.getcwd() + '/../Exp/MassFlux4.exp'),
+		massfluxatgate('MassFlux5',os.getcwd() + '/../Exp/MassFlux5.exp'),
+		massfluxatgate('MassFlux6',os.getcwd() + '/../Exp/MassFlux6.exp')
+	]
Index: /issm/trunk-jpl/test/Par/SquareShelfConstrained.par
===================================================================
--- /issm/trunk-jpl/test/Par/SquareShelfConstrained.par	(revision 16387)
+++ /issm/trunk-jpl/test/Par/SquareShelfConstrained.par	(revision 16388)
@@ -61,2 +61,12 @@
 A=dbstack;
 if (length(A)>2), md.miscellaneous.name=A(3).file(1:end-2); end
+
+%output definitions: 
+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'])...
+	};
Index: /issm/trunk-jpl/test/Par/SquareShelfConstrained.py
===================================================================
--- /issm/trunk-jpl/test/Par/SquareShelfConstrained.py	(revision 16387)
+++ /issm/trunk-jpl/test/Par/SquareShelfConstrained.py	(revision 16388)
@@ -7,4 +7,5 @@
 from paterson import paterson
 from SetIceShelfBC import SetIceShelfBC
+from massfluxatgate import massfluxatgate
 
 #Start defining model parameters here
@@ -73,2 +74,11 @@
 	md.miscellaneous.name = os.path.basename(inspect.stack()[2][1]).split('.')[0]
 
+#output definitions: 
+md.outputdefinition.definitions=[
+		massfluxatgate('MassFlux1',os.getcwd() + '/../Exp/MassFlux1.exp'),
+		massfluxatgate('MassFlux2',os.getcwd() + '/../Exp/MassFlux2.exp'),
+		massfluxatgate('MassFlux3',os.getcwd() + '/../Exp/MassFlux3.exp'),
+		massfluxatgate('MassFlux4',os.getcwd() + '/../Exp/MassFlux4.exp'),
+		massfluxatgate('MassFlux5',os.getcwd() + '/../Exp/MassFlux5.exp'),
+		massfluxatgate('MassFlux6',os.getcwd() + '/../Exp/MassFlux6.exp')
+	]
Index: /issm/trunk-jpl/test/Par/SquareThermal.par
===================================================================
--- /issm/trunk-jpl/test/Par/SquareThermal.par	(revision 16387)
+++ /issm/trunk-jpl/test/Par/SquareThermal.par	(revision 16388)
@@ -43,2 +43,12 @@
 md.basalforcings.geothermalflux=zeros(md.mesh.numberofvertices,1); 
 md.basalforcings.geothermalflux(find(md.mask.groundedice_levelset>0.))=1.*10^-3; %1 mW/m^2
+
+%output definitions: 
+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'])...
+	};
Index: /issm/trunk-jpl/test/Par/SquareThermal.py
===================================================================
--- /issm/trunk-jpl/test/Par/SquareThermal.py	(revision 16387)
+++ /issm/trunk-jpl/test/Par/SquareThermal.py	(revision 16388)
@@ -2,4 +2,5 @@
 from paterson import paterson
 from SetMarineIceSheetBC import SetMarineIceSheetBC
+from massfluxatgate import massfluxatgate
 
 #Ok, start defining model parameters here
@@ -47,2 +48,12 @@
 md.basalforcings.geothermalflux=numpy.zeros((md.mesh.numberofvertices,1)) 
 md.basalforcings.geothermalflux[numpy.nonzero(md.mask.groundedice_levelset>0.)[0]]=1.*10**-3    #1 mW/m^2
+
+#output definitions: 
+md.outputdefinition.definitions=[
+		massfluxatgate('MassFlux1',os.getcwd() + '/../Exp/MassFlux1.exp'),
+		massfluxatgate('MassFlux2',os.getcwd() + '/../Exp/MassFlux2.exp'),
+		massfluxatgate('MassFlux3',os.getcwd() + '/../Exp/MassFlux3.exp'),
+		massfluxatgate('MassFlux4',os.getcwd() + '/../Exp/MassFlux4.exp'),
+		massfluxatgate('MassFlux5',os.getcwd() + '/../Exp/MassFlux5.exp'),
+		massfluxatgate('MassFlux6',os.getcwd() + '/../Exp/MassFlux6.exp')
+	]
