Index: issm/trunk-jpl/src/c/classes/FemModel.cpp
===================================================================
--- issm/trunk-jpl/src/c/classes/FemModel.cpp	(revision 13721)
+++ issm/trunk-jpl/src/c/classes/FemModel.cpp	(revision 13722)
@@ -380,8 +380,5 @@
 void FemModel::Responsex(IssmDouble* responses,const char* response_descriptor,bool process_units,int weight_index){/*{{{*/
 
-
-	int response_descriptor_enum;
-
-	response_descriptor_enum=StringToEnumx(response_descriptor);
+	int response_descriptor_enum=StringToEnumx(response_descriptor);
 	this->Responsex(responses, response_descriptor_enum, process_units, weight_index);
 
@@ -396,14 +393,14 @@
 		case IceVolumeEnum:              IceVolumex(               responses, elements,nodes, vertices, loads, materials, parameters,process_units); break;
 		case MinVelEnum:                 MinVelx(                  responses, elements,nodes, vertices, loads, materials, parameters,process_units); break;
-		case MaxVelEnum:                 MaxVelx(                  responses, elements,nodes, vertices, loads, materials, parameters,process_units); break;
+		case MaxVelEnum:                 this->MaxVelx(                  responses,process_units); break;
 		case MinVxEnum:                  MinVxx(                   responses, elements,nodes, vertices, loads, materials, parameters,process_units); break;
-		case MaxVxEnum:                  MaxVxx(                   responses, elements,nodes, vertices, loads, materials, parameters,process_units); break;
-		case MaxAbsVxEnum:               MaxAbsVxx(                responses, elements,nodes, vertices, loads, materials, parameters,process_units); break;
+		case MaxVxEnum:                  this->MaxVxx(                   responses,process_units); break;
+		case MaxAbsVxEnum:               this->MaxAbsVxx(                responses,process_units); break;
 		case MinVyEnum:                  MinVyx(                   responses, elements,nodes, vertices, loads, materials, parameters,process_units); break;
-		case MaxVyEnum:                  MaxVyx(                   responses, elements,nodes, vertices, loads, materials, parameters,process_units); break;
-		case MaxAbsVyEnum:               MaxAbsVyx(                responses, elements,nodes, vertices, loads, materials, parameters,process_units); break;
+		case MaxVyEnum:                  this->MaxVyx(                   responses,process_units); break;
+		case MaxAbsVyEnum:               this->MaxAbsVyx(                responses,process_units); break;
 		case MinVzEnum:                  MinVzx(                   responses, elements,nodes, vertices, loads, materials, parameters,process_units); break;
-		case MaxVzEnum:                  MaxVzx(                   responses, elements,nodes, vertices, loads, materials, parameters,process_units); break;
-		case MaxAbsVzEnum:               MaxAbsVzx(                responses, elements,nodes, vertices, loads, materials, parameters,process_units); break;
+		case MaxVzEnum:                  this->MaxVzx(                   responses,process_units); break;
+		case MaxAbsVzEnum:               this->MaxAbsVzx(                responses,process_units); break;
 		case MassFluxEnum:               this->MassFluxx(          responses,process_units); break;
 		case SurfaceAbsVelMisfitEnum:    SurfaceAbsVelMisfitx(     responses, elements,nodes, vertices, loads, materials, parameters,process_units,weight_index); break;
@@ -414,6 +411,6 @@
 		case ThicknessAbsMisfitEnum:     ThicknessAbsMisfitx(      responses, elements,nodes, vertices, loads, materials, parameters,process_units,weight_index); break;
 		case ThicknessAbsGradientEnum:   this->ThicknessAbsGradientx(    responses, process_units,weight_index); break;
-		case ThicknessAlongGradientEnum:   ThicknessAlongGradientx(    responses, elements,nodes, vertices, loads, materials, parameters,process_units,weight_index); break;
-		case ThicknessAcrossGradientEnum:   ThicknessAcrossGradientx(    responses, elements,nodes, vertices, loads, materials, parameters,process_units,weight_index); break;
+		case ThicknessAlongGradientEnum: ThicknessAlongGradientx(    responses, elements,nodes, vertices, loads, materials, parameters,process_units,weight_index); break;
+		case ThicknessAcrossGradientEnum:ThicknessAcrossGradientx(    responses, elements,nodes, vertices, loads, materials, parameters,process_units,weight_index); break;
 		case TotalSmbEnum:					TotalSmbx(                responses, elements,nodes, vertices, loads, materials, parameters,process_units); break;
 		case RheologyBbarAbsGradientEnum:RheologyBbarAbsGradientx( responses, elements,nodes, vertices, loads, materials, parameters,process_units,weight_index); break;
@@ -590,6 +587,6 @@
 
 	/*Free ressources:*/
-	for(i=0;j<M;i++){
-		IssmDouble* matrix=array[j];
+	for(i=0;i<M;i++){
+		IssmDouble* matrix=array[i];
 		xDelete<IssmDouble>(matrix);
 	}
@@ -600,4 +597,186 @@
 	/*Assign output pointers: */
 	*pmass_flux=mass_flux;
+
+}/*}}}*/
+void FemModel::MaxAbsVxx(IssmDouble* pmaxabsvx,bool process_units){/*{{{*/
+
+	int i;
+	IssmDouble maxabsvx;
+	IssmDouble node_maxabsvx;
+	IssmDouble element_maxabsvx;
+
+	/*Go through elements, and request velocity: */
+	maxabsvx=-INFINITY;
+	for(i=0;i<this->elements->Size();i++){
+		Element* element=(Element*)this->elements->GetObjectByOffset(i);
+		element->MaxAbsVx(&element_maxabsvx,process_units);
+		if(element_maxabsvx>maxabsvx) maxabsvx=element_maxabsvx;
+	}
+
+	/*Figure out maximum across the cluster: */
+#ifdef _HAVE_MPI_
+	MPI_Reduce(&maxabsvx,&node_maxabsvx,1,MPI_DOUBLE,MPI_MAX,0,IssmComm::GetComm() );
+	MPI_Bcast(&node_maxabsvx,1,MPI_DOUBLE,0,IssmComm::GetComm());   
+	maxabsvx=node_maxabsvx;
+#endif
+
+	/*Assign output pointers:*/
+	*pmaxabsvx=maxabsvx;
+
+}/*}}}*/
+void FemModel::MaxAbsVyx(IssmDouble* pmaxabsvy,bool process_units){/*{{{*/
+
+	int i;
+	IssmDouble maxabsvy;
+	IssmDouble node_maxabsvy;
+	IssmDouble element_maxabsvy;
+
+	/*Go through elements, and request velocity: */
+	maxabsvy=-INFINITY;
+	for(i=0;i<this->elements->Size();i++){
+		Element* element=(Element*)this->elements->GetObjectByOffset(i);
+		element->MaxAbsVy(&element_maxabsvy,process_units);
+		if(element_maxabsvy>maxabsvy) maxabsvy=element_maxabsvy;
+	}
+
+	/*Figure out maximum across the cluster: */
+#ifdef _HAVE_MPI_
+	MPI_Reduce(&maxabsvy,&node_maxabsvy,1,MPI_DOUBLE,MPI_MAX,0,IssmComm::GetComm() );
+	MPI_Bcast(&node_maxabsvy,1,MPI_DOUBLE,0,IssmComm::GetComm());   
+	maxabsvy=node_maxabsvy;
+#endif
+
+	/*Assign output pointers:*/
+	*pmaxabsvy=maxabsvy;
+
+}/*}}}*/
+void FemModel::MaxAbsVzx(IssmDouble* pmaxabsvz,bool process_units){/*{{{*/
+
+	int i;
+	IssmDouble maxabsvz;
+	IssmDouble node_maxabsvz;
+	IssmDouble element_maxabsvz;
+
+	/*Go through elements, and request velocity: */
+	maxabsvz=-INFINITY;
+	for(i=0;i<this->elements->Size();i++){
+		Element* element=(Element*)this->elements->GetObjectByOffset(i);
+		element->MaxAbsVz(&element_maxabsvz,process_units);
+		if(element_maxabsvz>maxabsvz) maxabsvz=element_maxabsvz;
+	}
+
+	/*Figure out maximum across the cluster: */
+#ifdef _HAVE_MPI_
+	MPI_Reduce(&maxabsvz,&node_maxabsvz,1,MPI_DOUBLE,MPI_MAX,0,IssmComm::GetComm() );
+	MPI_Bcast(&node_maxabsvz,1,MPI_DOUBLE,0,IssmComm::GetComm());   
+	maxabsvz=node_maxabsvz;
+#endif
+
+	/*Assign output pointers:*/
+	*pmaxabsvz=maxabsvz;
+
+}/*}}}*/
+void FemModel::MaxVelx(IssmDouble* pmaxvel,bool process_units){/*{{{*/
+
+	int i;
+	IssmDouble maxvel;
+	IssmDouble node_maxvel;
+	IssmDouble element_maxvel;
+
+	/*Go through elements, and request velocity: */
+	maxvel=-INFINITY;
+	for(i=0;i<this->elements->Size();i++){
+		Element* element=(Element*)this->elements->GetObjectByOffset(i);
+		element->MaxVel(&element_maxvel,process_units);
+		if(element_maxvel>maxvel) maxvel=element_maxvel;
+	}
+
+	/*Figure out maximum across the cluster: */
+#ifdef _HAVE_MPI_
+	MPI_Reduce(&maxvel,&node_maxvel,1,MPI_DOUBLE,MPI_MAX,0,IssmComm::GetComm() );
+	MPI_Bcast(&node_maxvel,1,MPI_DOUBLE,0,IssmComm::GetComm());   
+	maxvel=node_maxvel;
+#endif
+
+	/*Assign output pointers:*/
+	*pmaxvel=maxvel;
+
+}/*}}}*/
+void FemModel::MaxVxx(IssmDouble* pmaxvx,bool process_units){/*{{{*/
+
+	int i;
+	IssmDouble maxvx;
+	IssmDouble node_maxvx;
+	IssmDouble element_maxvx;
+
+	/*Go through elements, and request velocity: */
+	maxvx=-INFINITY;
+	for(i=0;i<this->elements->Size();i++){
+		Element* element=(Element*)this->elements->GetObjectByOffset(i);
+		element->MaxVx(&element_maxvx,process_units);
+		if(element_maxvx>maxvx) maxvx=element_maxvx;
+	}
+
+	/*Figure out maximum across the cluster: */
+#ifdef _HAVE_MPI_
+	MPI_Reduce(&maxvx,&node_maxvx,1,MPI_DOUBLE,MPI_MAX,0,IssmComm::GetComm() );
+	MPI_Bcast(&node_maxvx,1,MPI_DOUBLE,0,IssmComm::GetComm());   
+	maxvx=node_maxvx;
+#endif
+
+	/*Assign output pointers:*/
+	*pmaxvx=maxvx;
+
+}/*}}}*/
+void FemModel::MaxVyx(IssmDouble* pmaxvy,bool process_units){/*{{{*/
+
+	int i;
+	IssmDouble maxvy;
+	IssmDouble node_maxvy;
+	IssmDouble element_maxvy;
+
+	/*Go through elements, and request velocity: */
+	maxvy=-INFINITY;
+	for(i=0;i<this->elements->Size();i++){
+		Element* element=(Element*)this->elements->GetObjectByOffset(i);
+		element->MaxVy(&element_maxvy,process_units);
+		if(element_maxvy>maxvy) maxvy=element_maxvy;
+	}
+
+	/*Figure out maximum across the cluster: */
+#ifdef _HAVE_MPI_
+	MPI_Reduce(&maxvy,&node_maxvy,1,MPI_DOUBLE,MPI_MAX,0,IssmComm::GetComm() );
+	MPI_Bcast(&node_maxvy,1,MPI_DOUBLE,0,IssmComm::GetComm());   
+	maxvy=node_maxvy;
+#endif
+
+	/*Assign output pointers:*/
+	*pmaxvy=maxvy;
+
+}/*}}}*/
+void FemModel::MaxVzx(IssmDouble* pmaxvz,bool process_units){/*{{{*/
+
+	int i;
+	IssmDouble maxvz;
+	IssmDouble node_maxvz;
+	IssmDouble element_maxvz;
+
+	/*Go through elements, and request velocity: */
+	maxvz=-INFINITY;
+	for(i=0;i<this->elements->Size();i++){
+		Element* element=(Element*)this->elements->GetObjectByOffset(i);
+		element->MaxVz(&element_maxvz,process_units);
+		if(element_maxvz>maxvz) maxvz=element_maxvz;
+	}
+
+	/*Figure out maximum across the cluster: */
+#ifdef _HAVE_MPI_
+	MPI_Reduce(&maxvz,&node_maxvz,1,MPI_DOUBLE,MPI_MAX,0,IssmComm::GetComm() );
+	MPI_Bcast(&node_maxvz,1,MPI_DOUBLE,0,IssmComm::GetComm());   
+	maxvz=node_maxvz;
+#endif
+
+	/*Assign output pointers:*/
+	*pmaxvz=maxvz;
 
 }/*}}}*/
