Index: ../trunk-jpl/src/m/inversions/marshallcostfunctions.m
===================================================================
--- ../trunk-jpl/src/m/inversions/marshallcostfunctions.m	(revision 0)
+++ ../trunk-jpl/src/m/inversions/marshallcostfunctions.m	(revision 18994)
@@ -0,0 +1,15 @@
+function data = marshallcostfunctions(cost_functions)
+	pos=find(cost_functions==101); data(pos)=SurfaceAbsVelMisfitEnum();
+	pos=find(cost_functions==102); data(pos)=SurfaceRelVelMisfitEnum();
+	pos=find(cost_functions==103); data(pos)=SurfaceLogVelMisfitEnum();
+	pos=find(cost_functions==104); data(pos)=SurfaceLogVxVyMisfitEnum();
+	pos=find(cost_functions==105); data(pos)=SurfaceAverageVelMisfitEnum();
+	pos=find(cost_functions==201); data(pos)=ThicknessAbsMisfitEnum();
+	pos=find(cost_functions==501); data(pos)=DragCoefficientAbsGradientEnum();
+	pos=find(cost_functions==502); data(pos)=RheologyBbarAbsGradientEnum();
+	pos=find(cost_functions==503); data(pos)=ThicknessAbsGradientEnum();
+	pos=find(cost_functions==504); data(pos)=ThicknessAlongGradientEnum();
+	pos=find(cost_functions==505); data(pos)=ThicknessAcrossGradientEnum();
+	pos=find(cost_functions==506); data(pos)=BalancethicknessMisfitEnum();
+	pos=find(cost_functions==507); data(pos)=RheologyBAbsGradientEnum();
+	pos=find(cost_functions==601); data(pos)=SurfaceAbsMisfitEnum();
Index: ../trunk-jpl/src/m/inversions/supportedcontrols.py
===================================================================
--- ../trunk-jpl/src/m/inversions/supportedcontrols.py	(revision 0)
+++ ../trunk-jpl/src/m/inversions/supportedcontrols.py	(revision 18994)
@@ -0,0 +1,2 @@
+def supportedcontrols():
+	return ['BalancethicknessThickeningRate','FrictionCoefficient','MaterialsRheologyBbar','DamageDbar','Vx','Vy']
Index: ../trunk-jpl/src/m/inversions/supportedcostfunctions.m
===================================================================
--- ../trunk-jpl/src/m/inversions/supportedcostfunctions.m	(revision 0)
+++ ../trunk-jpl/src/m/inversions/supportedcostfunctions.m	(revision 18994)
@@ -0,0 +1,3 @@
+function list = supportedcostfunctions(),
+
+	list = [101:105 201 501:507 601:604];
Index: ../trunk-jpl/src/m/inversions/marshallcostfunctions.py
===================================================================
--- ../trunk-jpl/src/m/inversions/marshallcostfunctions.py	(revision 0)
+++ ../trunk-jpl/src/m/inversions/marshallcostfunctions.py	(revision 18994)
@@ -0,0 +1,33 @@
+import copy
+from EnumDefinitions import *
+
+def marshallcostfunctions(cost_functions):
+
+	#copy list first
+	data=copy.deepcopy(cost_functions)
+
+	#convert to  Enums
+	pos=[i for i,x in enumerate(cost_functions) if x==101];
+	for i in pos: data[i]=SurfaceAbsVelMisfitEnum()        
+	pos=[i for i,x in enumerate(cost_functions) if x==102];
+	for i in pos: data[i]=SurfaceRelVelMisfitEnum()        
+	pos=[i for i,x in enumerate(cost_functions) if x==103];
+	for i in pos: data[i]=SurfaceLogVelMisfitEnum()        
+	pos=[i for i,x in enumerate(cost_functions) if x==104];
+	for i in pos: data[i]=SurfaceLogVxVyMisfitEnum()       
+	pos=[i for i,x in enumerate(cost_functions) if x==105];
+	for i in pos: data[i]=SurfaceAverageVelMisfitEnum()    
+	pos=[i for i,x in enumerate(cost_functions) if x==201];
+	for i in pos: data[i]=ThicknessAbsMisfitEnum()         
+	pos=[i for i,x in enumerate(cost_functions) if x==501];
+	for i in pos: data[i]=DragCoefficientAbsGradientEnum() 
+	pos=[i for i,x in enumerate(cost_functions) if x==502];
+	for i in pos: data[i]=RheologyBbarAbsGradientEnum()    
+	pos=[i for i,x in enumerate(cost_functions) if x==503];
+	for i in pos: data[i]=ThicknessAbsGradientEnum()       
+	pos=[i for i,x in enumerate(cost_functions) if x==504];
+	for i in pos: data[i]=ThicknessAlongGradientEnum()     
+	pos=[i for i,x in enumerate(cost_functions) if x==505];
+	for i in pos: data[i]=ThicknessAcrossGradientEnum()    
+
+	return data
Index: ../trunk-jpl/src/m/inversions/supportedcostfunctions.py
===================================================================
--- ../trunk-jpl/src/m/inversions/supportedcostfunctions.py	(revision 0)
+++ ../trunk-jpl/src/m/inversions/supportedcostfunctions.py	(revision 18994)
@@ -0,0 +1,2 @@
+def supportedcostfunctions():
+	return [101,102,103,104,105,201,501,502,503,504,505]
Index: ../trunk-jpl/src/m/classes/m1qn3inversion.py
===================================================================
--- ../trunk-jpl/src/m/classes/m1qn3inversion.py	(revision 18993)
+++ ../trunk-jpl/src/m/classes/m1qn3inversion.py	(revision 18994)
@@ -1,10 +1,12 @@
 import numpy
-import copy
 from fielddisplay import fielddisplay
 from EnumDefinitions import *
 from StringToEnum import StringToEnum
 from checkfield import checkfield
 from WriteData import WriteData
+from supportedcontrols import supportedcontrols
+from supportedcostfunctions import supportedcostfunctions
+from marshallcostfunctions import marshallcostfunctions
 
 class m1qn3inversion(object):
 	'''
@@ -118,12 +120,12 @@
 
 		md = checkfield(md,'fieldname','inversion.iscontrol','values',[0,1])
 		md = checkfield(md,'fieldname','inversion.incomplete_adjoint','values',[0,1])
-		md = checkfield(md,'fieldname','inversion.control_parameters','cell',1,'values',['BalancethicknessThickeningRate','FrictionCoefficient','MaterialsRheologyBbar','DamageDbar','Vx','Vy','Thickness'])
+		md = checkfield(md,'fieldname','inversion.control_parameters','cell',1,'values',supportedcontrols())
 		md = checkfield(md,'fieldname','inversion.maxsteps','numel',[1],'>=',0)
 		md = checkfield(md,'fieldname','inversion.maxiter','numel',[1],'>=',0)
 		md = checkfield(md,'fieldname','inversion.dxmin','numel',[1],'>',0.)
 		md = checkfield(md,'fieldname','inversion.gttol','numel',[1],'>',0.)
-		md = checkfield(md,'fieldname','inversion.cost_functions','size',[num_costfunc],'values',[101,102,103,104,105,201,501,502,503,504,505])
+		md = checkfield(md,'fieldname','inversion.cost_functions','size',[num_costfunc],'values',supportedcostfunctions())
 		md = checkfield(md,'fieldname','inversion.cost_functions_coefficients','size',[md.mesh.numberofvertices,num_costfunc],'>=',0)
 		md = checkfield(md,'fieldname','inversion.min_parameters','size',[md.mesh.numberofvertices,num_controls])
 		md = checkfield(md,'fieldname','inversion.max_parameters','size',[md.mesh.numberofvertices,num_controls])
@@ -165,29 +167,7 @@
 
 		#process cost functions
 		num_cost_functions=numpy.size(self.cost_functions)
-		data=copy.deepcopy(self.cost_functions)
-		pos=[i for i,x in enumerate(self.cost_functions) if x==101];
-		for i in pos: data[i]=SurfaceAbsVelMisfitEnum()        
-		pos=[i for i,x in enumerate(self.cost_functions) if x==102];
-		for i in pos: data[i]=SurfaceRelVelMisfitEnum()        
-		pos=[i for i,x in enumerate(self.cost_functions) if x==103];
-		for i in pos: data[i]=SurfaceLogVelMisfitEnum()        
-		pos=[i for i,x in enumerate(self.cost_functions) if x==104];
-		for i in pos: data[i]=SurfaceLogVxVyMisfitEnum()       
-		pos=[i for i,x in enumerate(self.cost_functions) if x==105];
-		for i in pos: data[i]=SurfaceAverageVelMisfitEnum()    
-		pos=[i for i,x in enumerate(self.cost_functions) if x==201];
-		for i in pos: data[i]=ThicknessAbsMisfitEnum()         
-		pos=[i for i,x in enumerate(self.cost_functions) if x==501];
-		for i in pos: data[i]=DragCoefficientAbsGradientEnum() 
-		pos=[i for i,x in enumerate(self.cost_functions) if x==502];
-		for i in pos: data[i]=RheologyBbarAbsGradientEnum()    
-		pos=[i for i,x in enumerate(self.cost_functions) if x==503];
-		for i in pos: data[i]=ThicknessAbsGradientEnum()       
-		pos=[i for i,x in enumerate(self.cost_functions) if x==504];
-		for i in pos: data[i]=ThicknessAlongGradientEnum()     
-		pos=[i for i,x in enumerate(self.cost_functions) if x==505];
-		for i in pos: data[i]=ThicknessAcrossGradientEnum()    
+		data=marshallcostfunctions(self.cost_functions)
 		WriteData(fid,'data',numpy.array(data).reshape(1,-1),'enum',InversionCostFunctionsEnum(),'format','DoubleMat','mattype',3)
 		WriteData(fid,'data',num_cost_functions,'enum',InversionNumCostFunctionsEnum(),'format','Integer')
 	# }}}
Index: ../trunk-jpl/src/m/classes/m1qn3inversion.m
===================================================================
--- ../trunk-jpl/src/m/classes/m1qn3inversion.m	(revision 18993)
+++ ../trunk-jpl/src/m/classes/m1qn3inversion.m	(revision 18994)
@@ -73,15 +73,13 @@
 
 			md = checkfield(md,'fieldname','inversion.iscontrol','values',[0 1]);
 			md = checkfield(md,'fieldname','inversion.incomplete_adjoint','values',[0 1]);
-			md = checkfield(md,'fieldname','inversion.control_parameters','cell',1,'values',...
-				{'BalancethicknessThickeningRate' 'FrictionCoefficient' 'MaterialsRheologyBbar' 'DamageDbar',...
-				'Vx' 'Vy' 'Thickness' 'BalancethicknessOmega' 'BalancethicknessApparentMassbalance','MaterialsRheologyB'});
+			md = checkfield(md,'fieldname','inversion.control_parameters','cell',1,'values',supportedcontrols());
 			md = checkfield(md,'fieldname','inversion.control_scaling_factors','size',[1 num_controls],'>',0,'NaN',1);
 			md = checkfield(md,'fieldname','inversion.maxsteps','numel',1,'>=',0);
 			md = checkfield(md,'fieldname','inversion.maxiter','numel',1,'>=',0);
 			md = checkfield(md,'fieldname','inversion.dxmin','numel',1,'>',0);
 			md = checkfield(md,'fieldname','inversion.gttol','numel',1,'>',0);
-			md = checkfield(md,'fieldname','inversion.cost_functions','size',[1 num_costfunc],'values',[101:105 201 501:507 601:604]);
+			md = checkfield(md,'fieldname','inversion.cost_functions','size',[1 num_costfunc],'values',supportedcostfunctions());
 			md = checkfield(md,'fieldname','inversion.cost_functions_coefficients','size',[md.mesh.numberofvertices num_costfunc],'>=',0);
 			md = checkfield(md,'fieldname','inversion.min_parameters','size',[md.mesh.numberofvertices num_controls]);
 			md = checkfield(md,'fieldname','inversion.max_parameters','size',[md.mesh.numberofvertices num_controls]);
@@ -166,21 +164,7 @@
 
 			%process cost functions
 			num_cost_functions=size(obj.cost_functions,2);
-			data=obj.cost_functions;
-			pos=find(obj.cost_functions==101); data(pos)=SurfaceAbsVelMisfitEnum();
-			pos=find(obj.cost_functions==102); data(pos)=SurfaceRelVelMisfitEnum();
-			pos=find(obj.cost_functions==103); data(pos)=SurfaceLogVelMisfitEnum();
-			pos=find(obj.cost_functions==104); data(pos)=SurfaceLogVxVyMisfitEnum();
-			pos=find(obj.cost_functions==105); data(pos)=SurfaceAverageVelMisfitEnum();
-			pos=find(obj.cost_functions==201); data(pos)=ThicknessAbsMisfitEnum();
-			pos=find(obj.cost_functions==501); data(pos)=DragCoefficientAbsGradientEnum();
-			pos=find(obj.cost_functions==502); data(pos)=RheologyBbarAbsGradientEnum();
-			pos=find(obj.cost_functions==503); data(pos)=ThicknessAbsGradientEnum();
-			pos=find(obj.cost_functions==504); data(pos)=ThicknessAlongGradientEnum();
-			pos=find(obj.cost_functions==505); data(pos)=ThicknessAcrossGradientEnum();
-			pos=find(obj.cost_functions==506); data(pos)=BalancethicknessMisfitEnum();
-			pos=find(obj.cost_functions==507); data(pos)=RheologyBAbsGradientEnum();
-			pos=find(obj.cost_functions==601); data(pos)=SurfaceAbsMisfitEnum();
+			data=marshallcostfunctions(obj.cost_functions);
 			WriteData(fid,'data',data,'enum',InversionCostFunctionsEnum(),'format','DoubleMat','mattype',3);
 			WriteData(fid,'data',num_cost_functions,'enum',InversionNumCostFunctionsEnum(),'format','Integer');
 		end % }}}
Index: ../trunk-jpl/src/m/classes/inversionvalidation.m
===================================================================
--- ../trunk-jpl/src/m/classes/inversionvalidation.m	(revision 18993)
+++ ../trunk-jpl/src/m/classes/inversionvalidation.m	(revision 18994)
@@ -56,11 +56,9 @@
 
 			md = checkfield(md,'fieldname','inversion.iscontrol','values',[0 1]);
 			md = checkfield(md,'fieldname','inversion.incomplete_adjoint','values',[0 1]);
-			md = checkfield(md,'fieldname','inversion.control_parameters','cell',1,'values',...
-				{'BalancethicknessThickeningRate' 'FrictionCoefficient' 'MaterialsRheologyBbar' 'DamageDbar' 'Vx' 'Vy' 'Thickness',...
-				'BalancethicknessOmega' 'BalancethicknessApparentMassbalance','MaterialsRheologyB'});
+			md = checkfield(md,'fieldname','inversion.control_parameters','cell',1,'values',supportedcontrols());
 			md = checkfield(md,'fieldname','inversion.control_scaling_factors','size',[1 num_controls],'>',0,'NaN',1);
-			md = checkfield(md,'fieldname','inversion.cost_functions','size',[1 num_costfunc],'values',[101:105 201 501:507 601:604]);
+			md = checkfield(md,'fieldname','inversion.cost_functions','size',[1 num_costfunc],'values',supportedcostfunctions());
 			md = checkfield(md,'fieldname','inversion.cost_functions_coefficients','size',[md.mesh.numberofvertices num_costfunc],'>=',0);
 			md = checkfield(md,'fieldname','inversion.min_parameters','size',[md.mesh.numberofvertices num_controls]);
 			md = checkfield(md,'fieldname','inversion.max_parameters','size',[md.mesh.numberofvertices num_controls]);
@@ -136,21 +134,7 @@
 
 			%process cost functions
 			num_cost_functions=size(obj.cost_functions,2);
-			data=obj.cost_functions;
-			pos=find(obj.cost_functions==101); data(pos)=SurfaceAbsVelMisfitEnum();
-			pos=find(obj.cost_functions==102); data(pos)=SurfaceRelVelMisfitEnum();
-			pos=find(obj.cost_functions==103); data(pos)=SurfaceLogVelMisfitEnum();
-			pos=find(obj.cost_functions==104); data(pos)=SurfaceLogVxVyMisfitEnum();
-			pos=find(obj.cost_functions==105); data(pos)=SurfaceAverageVelMisfitEnum();
-			pos=find(obj.cost_functions==201); data(pos)=ThicknessAbsMisfitEnum();
-			pos=find(obj.cost_functions==501); data(pos)=DragCoefficientAbsGradientEnum();
-			pos=find(obj.cost_functions==502); data(pos)=RheologyBbarAbsGradientEnum();
-			pos=find(obj.cost_functions==503); data(pos)=ThicknessAbsGradientEnum();
-			pos=find(obj.cost_functions==504); data(pos)=ThicknessAlongGradientEnum();
-			pos=find(obj.cost_functions==505); data(pos)=ThicknessAcrossGradientEnum();
-			pos=find(obj.cost_functions==506); data(pos)=BalancethicknessMisfitEnum();
-			pos=find(obj.cost_functions==507); data(pos)=RheologyBAbsGradientEnum();
-			pos=find(obj.cost_functions==601); data(pos)=SurfaceAbsMisfitEnum();
+			data=marshallcostfunctions(obj.cost_functions);
 			WriteData(fid,'data',data,'enum',InversionCostFunctionsEnum(),'format','DoubleMat','mattype',3);
 			WriteData(fid,'data',num_cost_functions,'enum',InversionNumCostFunctionsEnum(),'format','Integer');
 		end % }}}
Index: ../trunk-jpl/src/m/classes/inversion.py
===================================================================
--- ../trunk-jpl/src/m/classes/inversion.py	(revision 18993)
+++ ../trunk-jpl/src/m/classes/inversion.py	(revision 18994)
@@ -1,10 +1,12 @@
 import numpy
-import copy
 from fielddisplay import fielddisplay
 from EnumDefinitions import *
 from StringToEnum import StringToEnum
 from checkfield import checkfield
 from WriteData import WriteData
+from supportedcontrols import supportedcontrols
+from supportedcostfunctions import supportedcostfunctions
+from marshallcostfunctions import marshallcostfunctions
 
 class inversion(object):
 	"""
@@ -118,11 +120,11 @@
 
 		md = checkfield(md,'fieldname','inversion.iscontrol','values',[0,1])
 		md = checkfield(md,'fieldname','inversion.incomplete_adjoint','values',[0,1])
-		md = checkfield(md,'fieldname','inversion.control_parameters','cell',1,'values',['BalancethicknessThickeningRate','FrictionCoefficient','MaterialsRheologyBbar','DamageDbar','Vx','Vy'])
+		md = checkfield(md,'fieldname','inversion.control_parameters','cell',1,'values',supportedcontrols())
 		md = checkfield(md,'fieldname','inversion.nsteps','numel',[1],'>=',0)
 		md = checkfield(md,'fieldname','inversion.maxiter_per_step','size',[md.inversion.nsteps],'>=',0)
 		md = checkfield(md,'fieldname','inversion.step_threshold','size',[md.inversion.nsteps])
-		md = checkfield(md,'fieldname','inversion.cost_functions','size',[num_costfunc],'values',[101,102,103,104,105,201,501,502,503,504,505])
+		md = checkfield(md,'fieldname','inversion.cost_functions','size',[num_costfunc],'values',supportedcostfunctions())
 		md = checkfield(md,'fieldname','inversion.cost_functions_coefficients','size',[md.mesh.numberofvertices,num_costfunc],'>=',0)
 		md = checkfield(md,'fieldname','inversion.gradient_scaling','size',[md.inversion.nsteps,num_controls])
 		md = checkfield(md,'fieldname','inversion.min_parameters','size',[md.mesh.numberofvertices,num_controls])
@@ -172,29 +174,7 @@
 
 		#process cost functions
 		num_cost_functions=numpy.size(self.cost_functions)
-		data=copy.deepcopy(self.cost_functions)
-		pos=[i for i,x in enumerate(self.cost_functions) if x==101];
-		for i in pos: data[i]=SurfaceAbsVelMisfitEnum()        
-		pos=[i for i,x in enumerate(self.cost_functions) if x==102];
-		for i in pos: data[i]=SurfaceRelVelMisfitEnum()        
-		pos=[i for i,x in enumerate(self.cost_functions) if x==103];
-		for i in pos: data[i]=SurfaceLogVelMisfitEnum()        
-		pos=[i for i,x in enumerate(self.cost_functions) if x==104];
-		for i in pos: data[i]=SurfaceLogVxVyMisfitEnum()       
-		pos=[i for i,x in enumerate(self.cost_functions) if x==105];
-		for i in pos: data[i]=SurfaceAverageVelMisfitEnum()    
-		pos=[i for i,x in enumerate(self.cost_functions) if x==201];
-		for i in pos: data[i]=ThicknessAbsMisfitEnum()         
-		pos=[i for i,x in enumerate(self.cost_functions) if x==501];
-		for i in pos: data[i]=DragCoefficientAbsGradientEnum() 
-		pos=[i for i,x in enumerate(self.cost_functions) if x==502];
-		for i in pos: data[i]=RheologyBbarAbsGradientEnum()    
-		pos=[i for i,x in enumerate(self.cost_functions) if x==503];
-		for i in pos: data[i]=ThicknessAbsGradientEnum()       
-		pos=[i for i,x in enumerate(self.cost_functions) if x==504];
-		for i in pos: data[i]=ThicknessAlongGradientEnum()     
-		pos=[i for i,x in enumerate(self.cost_functions) if x==505];
-		for i in pos: data[i]=ThicknessAcrossGradientEnum()    
+		data=marshallcostfunctions(self.cost_functions)
 		WriteData(fid,'data',numpy.array(data).reshape(1,-1),'enum',InversionCostFunctionsEnum(),'format','DoubleMat','mattype',3)
 		WriteData(fid,'data',num_cost_functions,'enum',InversionNumCostFunctionsEnum(),'format','Integer')
 	# }}}
Index: ../trunk-jpl/src/m/classes/taoinversion.m
===================================================================
--- ../trunk-jpl/src/m/classes/taoinversion.m	(revision 18993)
+++ ../trunk-jpl/src/m/classes/taoinversion.m	(revision 18994)
@@ -85,8 +85,7 @@
 
 			md = checkfield(md,'fieldname','inversion.iscontrol','values',[0 1]);
 			md = checkfield(md,'fieldname','inversion.incomplete_adjoint','values',[0 1]);
-			md = checkfield(md,'fieldname','inversion.control_parameters','cell',1,'values',...
-				{'BalancethicknessThickeningRate' 'FrictionCoefficient' 'MaterialsRheologyBbar' 'MaterialsRheologyZbar' 'Vx' 'Vy' 'Thickness'});
+			md = checkfield(md,'fieldname','inversion.control_parameters','cell',1,'values',supportedcontrols());
 			md = checkfield(md,'fieldname','inversion.maxsteps','numel',1,'>=',0);
 			md = checkfield(md,'fieldname','inversion.maxiter','numel',1,'>=',0);
 			md = checkfield(md,'fieldname','inversion.fatol','numel',1,'>=',0);
@@ -103,7 +102,7 @@
 				md = checkfield(md,'fieldname','inversion.algorithm','values',{'tao_blmvm','tao_cg','tao_lmvm'});
 			end
 
-			md = checkfield(md,'fieldname','inversion.cost_functions','size',[1 num_costfunc],'values',[101:105 201 501:506]);
+			md = checkfield(md,'fieldname','inversion.cost_functions','size',[1 num_costfunc],'values',supportedcostfunctions());
 			md = checkfield(md,'fieldname','inversion.cost_functions_coefficients','size',[md.mesh.numberofvertices num_costfunc],'>=',0);
 			md = checkfield(md,'fieldname','inversion.min_parameters','size',[md.mesh.numberofvertices num_controls]);
 			md = checkfield(md,'fieldname','inversion.max_parameters','size',[md.mesh.numberofvertices num_controls]);
@@ -186,20 +185,7 @@
 
 			%process cost functions
 			num_cost_functions=size(obj.cost_functions,2);
-			data=obj.cost_functions;
-			pos=find(obj.cost_functions==101); data(pos)=SurfaceAbsVelMisfitEnum();
-			pos=find(obj.cost_functions==102); data(pos)=SurfaceRelVelMisfitEnum();
-			pos=find(obj.cost_functions==103); data(pos)=SurfaceLogVelMisfitEnum();
-			pos=find(obj.cost_functions==104); data(pos)=SurfaceLogVxVyMisfitEnum();
-			pos=find(obj.cost_functions==105); data(pos)=SurfaceAverageVelMisfitEnum();
-			pos=find(obj.cost_functions==201); data(pos)=ThicknessAbsMisfitEnum();
-			pos=find(obj.cost_functions==501); data(pos)=DragCoefficientAbsGradientEnum();
-			pos=find(obj.cost_functions==502); data(pos)=RheologyBbarAbsGradientEnum();
-			pos=find(obj.cost_functions==503); data(pos)=ThicknessAbsGradientEnum();
-			pos=find(obj.cost_functions==504); data(pos)=ThicknessAlongGradientEnum();
-			pos=find(obj.cost_functions==505); data(pos)=ThicknessAcrossGradientEnum();
-			pos=find(obj.cost_functions==506); data(pos)=BalancethicknessMisfitEnum();
-			pos=find(obj.cost_functions==507); data(pos)=Balancethickness2MisfitEnum();
+			data=marshallcostfunctions(obj.cost_functions);
 			WriteData(fid,'data',data,'enum',InversionCostFunctionsEnum(),'format','DoubleMat','mattype',3);
 			WriteData(fid,'data',num_cost_functions,'enum',InversionNumCostFunctionsEnum(),'format','Integer');
 		end % }}}
Index: ../trunk-jpl/src/m/classes/inversion.m
===================================================================
--- ../trunk-jpl/src/m/classes/inversion.m	(revision 18993)
+++ ../trunk-jpl/src/m/classes/inversion.m	(revision 18994)
@@ -135,7 +135,7 @@
 			md = checkfield(md,'fieldname','inversion.nsteps','numel',1,'>=',0);
 			md = checkfield(md,'fieldname','inversion.maxiter_per_step','size',[md.inversion.nsteps 1],'>=',0);
 			md = checkfield(md,'fieldname','inversion.step_threshold','size',[md.inversion.nsteps 1]);
-			md = checkfield(md,'fieldname','inversion.cost_functions','size',[1 num_costfunc],'values',[101:105 201 501:507 601:604]);
+			md = checkfield(md,'fieldname','inversion.cost_functions','size',[1 num_costfunc],'values',supportedcostfunctions());
 			md = checkfield(md,'fieldname','inversion.cost_functions_coefficients','size',[md.mesh.numberofvertices num_costfunc],'>=',0);
 			md = checkfield(md,'fieldname','inversion.gradient_scaling','size',[md.inversion.nsteps num_controls]);
 			md = checkfield(md,'fieldname','inversion.min_parameters','size',[md.mesh.numberofvertices num_controls]);
@@ -226,21 +226,7 @@
 
 			%process cost functions
 			num_cost_functions=size(obj.cost_functions,2);
-			data=obj.cost_functions;
-			pos=find(obj.cost_functions==101); data(pos)=SurfaceAbsVelMisfitEnum();
-			pos=find(obj.cost_functions==102); data(pos)=SurfaceRelVelMisfitEnum();
-			pos=find(obj.cost_functions==103); data(pos)=SurfaceLogVelMisfitEnum();
-			pos=find(obj.cost_functions==104); data(pos)=SurfaceLogVxVyMisfitEnum();
-			pos=find(obj.cost_functions==105); data(pos)=SurfaceAverageVelMisfitEnum();
-			pos=find(obj.cost_functions==201); data(pos)=ThicknessAbsMisfitEnum();
-			pos=find(obj.cost_functions==501); data(pos)=DragCoefficientAbsGradientEnum();
-			pos=find(obj.cost_functions==502); data(pos)=RheologyBbarAbsGradientEnum();
-			pos=find(obj.cost_functions==503); data(pos)=ThicknessAbsGradientEnum();
-			pos=find(obj.cost_functions==504); data(pos)=ThicknessAlongGradientEnum();
-			pos=find(obj.cost_functions==505); data(pos)=ThicknessAcrossGradientEnum();
-			pos=find(obj.cost_functions==506); data(pos)=BalancethicknessMisfitEnum();
-			pos=find(obj.cost_functions==507); data(pos)=RheologyBAbsGradientEnum();
-			pos=find(obj.cost_functions==601); data(pos)=SurfaceAbsMisfitEnum();
+			data=marshallcostfunctions(obj.cost_functions);
 			WriteData(fid,'data',data,'enum',InversionCostFunctionsEnum(),'format','DoubleMat','mattype',3);
 			WriteData(fid,'data',num_cost_functions,'enum',InversionNumCostFunctionsEnum(),'format','Integer');
 		end % }}}
