Index: /issm/trunk/src/m/classes/@pairoptions/buildlist.m
===================================================================
--- /issm/trunk/src/m/classes/@pairoptions/buildlist.m	(revision 2373)
+++ /issm/trunk/src/m/classes/@pairoptions/buildlist.m	(revision 2373)
@@ -0,0 +1,22 @@
+function options=buildlist(options,varargin),
+%BUILDLIST - build list of options from input
+%
+%   Usage:
+%      options=buildlist(options,varargin)
+
+%check length of input
+if mod((nargin-1),2),
+	error('buildlist error message: an even number of options is required')
+end
+
+%go through varargin and build list of options
+for i=1:(nargin-1)/2,
+	if ischar(varargin{2*i-1}),
+		options.list{end+1,1}=varargin{2*i-1};
+		options.list{end,2}=varargin{2*i};
+	else
+		%option is not a string, ignore it
+		disp(['pairoptions info: option number ' num2str(i) ' is not a string, it will be ignored']);
+		continue
+	end
+end
Index: /issm/trunk/src/m/classes/@pairoptions/display.m
===================================================================
--- /issm/trunk/src/m/classes/@pairoptions/display.m	(revision 2373)
+++ /issm/trunk/src/m/classes/@pairoptions/display.m	(revision 2373)
@@ -0,0 +1,8 @@
+function display(pairoptions)
+%DISPLAY - displays the fields of a pairoptions element
+%
+%   echo function for 'pairoptions' class
+
+disp(sprintf('\n%s = \n',inputname(1)));
+disp(sprintf('   type: %s',pairoptions.type));
+disp(sprintf('   options: (%ix%i)',size(pairoptions.list,1),size(pairoptions.list,2)));
Index: /issm/trunk/src/m/classes/@pairoptions/exist.m
===================================================================
--- /issm/trunk/src/m/classes/@pairoptions/exist.m	(revision 2373)
+++ /issm/trunk/src/m/classes/@pairoptions/exist.m	(revision 2373)
@@ -0,0 +1,25 @@
+function bool=exist(pairoptions,optioname),
+%EXIST - check if the option exist
+%
+%   Usage:
+%      bool=exist(pairoptions,optioname)
+
+%some argument checking: 
+if ((nargin~=2) | (nargout~=1)),
+	help exist
+	error('exist error message: bad usage');
+end
+
+if ~ischar(optioname),
+	error('exist error message: optioname should be a string');
+end
+
+%Recover option
+bool=0;
+for i=1:size(pairoptions.list,1),
+	if strcmpi(pairoptions.list{i,1},optioname)
+		bool=1;
+		return
+	end
+end
+
Index: /issm/trunk/src/m/classes/@pairoptions/getoption.m
===================================================================
--- /issm/trunk/src/m/classes/@pairoptions/getoption.m	(revision 2373)
+++ /issm/trunk/src/m/classes/@pairoptions/getoption.m	(revision 2373)
@@ -0,0 +1,24 @@
+function value=getoption(pairoptions,optioname),
+%GETOPTION - get the value of an option
+%
+%   Usage:
+%      value=getoption(pairoptions,optioname)
+
+%some argument checking: 
+if ((nargin~=2) | (nargout~=1)),
+	help getoption
+	error('getoption error message: bad usage');
+end
+
+if ~ischar(optioname),
+	error('getoption error message: optioname should be a string');
+end
+
+%Recover option
+value='option not found';
+for i=1:size(pairoptions.list,1),
+	if strcmpi(pairoptions.list{i,1},optioname)
+		value=pairoptions.list{i,2};
+		return
+	end
+end
Index: /issm/trunk/src/m/classes/@pairoptions/pairoptions.m
===================================================================
--- /issm/trunk/src/m/classes/@pairoptions/pairoptions.m	(revision 2373)
+++ /issm/trunk/src/m/classes/@pairoptions/pairoptions.m	(revision 2373)
@@ -0,0 +1,36 @@
+function options = pairoptions(varargin),
+%PAIROPTIONS - constructor for pairoptions object
+%
+%   Usage:
+%      pairoptions = pairoptions
+
+%check length of input
+if mod(nargin,2)==1,
+	error('pairoption error message: an even number of options is required')
+end
+
+%get calling function name
+a=dbstack;
+if length(a)>1,
+	functionname=a(2).file(1:end-2);
+else
+	functionname='';
+end
+
+%create a pairoption object
+if nargin==0,
+
+	options.list=cell(0,2);
+	options.type=functionname;
+	options=class(options,'pairoptions');
+
+else
+
+	options.list=cell(0,2);
+	options.type=functionname;
+	options=class(options,'pairoptions');
+
+	%initialize list
+	options=buildlist(options,varargin{:});
+
+end
Index: /issm/trunk/src/m/classes/@pairoptions/subsref.m
===================================================================
--- /issm/trunk/src/m/classes/@pairoptions/subsref.m	(revision 2373)
+++ /issm/trunk/src/m/classes/@pairoptions/subsref.m	(revision 2373)
@@ -0,0 +1,10 @@
+function pairoptions = subsref(pairoptions,index)
+%SUBSREF - handles indexed references to objects
+%
+%   the first argument is the object and the second one a structure array
+%   Usage:
+%      pairoptions = subsref(pairoptions,index)
+% 
+%   See also SUBSASGN
+
+pairoptions=builtin('subsref',pairoptions,index);
Index: /issm/trunk/src/m/classes/public/parametercontrol.m
===================================================================
--- /issm/trunk/src/m/classes/public/parametercontrol.m	(revision 2373)
+++ /issm/trunk/src/m/classes/public/parametercontrol.m	(revision 2373)
@@ -0,0 +1,94 @@
+function md=parametercontrol(md,varargin),
+%PARAMETERCONTROL - control method parameterization
+%
+%   Usage:
+%       md=parametercontrol(md,varargin)
+
+%process options
+options=pairoptions(varargin{:});
+
+%control type and analysis
+md.control_type='drag';
+md.control_analysis=1;
+
+%nsteps
+if exist(options,'nsteps'),
+	nsteps=getoption(options,'nsteps');
+	if (length(nsteps)~=1 | nsteps>0 | floor(nsteps)==nsteps)
+		md.nsteps=100;
+	else
+		md.nsteps=nsteps;
+	end
+else
+	md.nsteps=100;
+end
+
+%eps_cm
+if exist(options,'eps_cm'),
+	eps_cm=getoption(options,'eps_cm');
+	if (length(eps_cm)~=1 | eps_cm<0 )
+		md.eps_cm=NaN;
+	else
+		md.eps_cm=eps_cm;
+	end
+else
+	md.eps_cm=NaN;
+end
+
+%maxiter
+if exist(options,'maxiter'),
+	maxiter=getoption(options,'maxiter');
+	if (any(maxiter<0) | any(floor(maxiter)~=maxiter))
+		md.maxiter=10*ones(md.nsteps,1);
+	else
+		md.maxiter=repmat(maxiter(:),md.nsteps,1);
+		md.maxiter(md.nsteps+1:end)=[];
+	end
+else
+	md.maxiter=10*ones(md.nsteps,1);
+end
+
+%cm_jump
+if exist(options,'cm_jump'),
+	cm_jump=getoption(options,'cm_jump');
+	if ~isreal(cm_jump)
+		md.cm_jump=0.8*ones(md.nsteps,1);
+	else
+		md.cm_jump=repmat(cm_jump(:),md.nsteps,1);
+		md.cm_jump(md.nsteps+1:end)=[];
+	end
+else
+	md.cm_jump=0.8*ones(md.nsteps,1);
+end
+
+%fit
+found=0;
+if exist(options,'fit'),
+	fit=getoption(options,'fit');
+	if ~any(fit~=0 & fit~=1 & fit~=2),
+		md.fit=repmat(fit(:),md.nsteps,1);
+		md.fit(md.nsteps+1:end)=[];
+		found=1;
+	end
+end
+if ~found
+	third=ceil(md.nsteps/3);
+	md.fit=[2*ones(third,1);0*ones(third,1);repmat([0;0;2;0],third,1)];
+	md.fit(md.nsteps+1:end)=[];
+end
+
+%optscal
+found=0;
+if exist(options,'optscal'),
+	optscal=getoption(options,'optscal');
+	if ~any(optscal<0),
+		md.optscal=repmat(optscal(:),md.nsteps,1);
+		md.optscal(md.nsteps+1:end)=[];
+		found=1;
+	end
+end
+if ~found
+	third=ceil(md.nsteps/3);
+	md.optscal=[15*ones(third,1);10*ones(third,1);repmat([10;10;20;10],third,1)];
+	md.optscal(md.nsteps+1:end)=[];
+end
