Index: /issm/trunk/test/NightlyRun/Id2Name.m
===================================================================
--- /issm/trunk/test/NightlyRun/Id2Name.m	(revision 5032)
+++ /issm/trunk/test/NightlyRun/Id2Name.m	(revision 5033)
@@ -109,4 +109,12 @@
 elseif (id==335), name='SquareSheetConstrainedSteaH3dSerial';
 elseif (id==336), name='SquareSheetConstrainedSteaH3dParallel';
+elseif (id==337), name='SquareSheetConstrainedCMDragM2dSerial';
+elseif (id==338), name='SquareSheetConstrainedCMDragM2dParallel';
+elseif (id==339), name='SquareSheetConstrainedCMDragM3dSerial';
+elseif (id==340), name='SquareSheetConstrainedCMDragM3dParallel';
+elseif (id==341), name='SquareSheetConstrainedCMDragP3dSerial';
+elseif (id==342), name='SquareSheetConstrainedCMDragP3dParallel';
+elseif (id==343), name='SquareSheetConstrainedCMDragS3dSerial';
+elseif (id==344), name='SquareSheetConstrainedCMDragS3dParallel';
 elseif (id==401), name='SquareSheetShelfDiagM2dSerial';
 elseif (id==402), name='SquareSheetShelfDiagM2dParallel';
Index: /issm/trunk/test/NightlyRun/test337.m
===================================================================
--- /issm/trunk/test/NightlyRun/test337.m	(revision 5033)
+++ /issm/trunk/test/NightlyRun/test337.m	(revision 5033)
@@ -0,0 +1,21 @@
+md=mesh(model,'../Exp/Square.exp',200000);
+md=geography(md,'','');
+md=parameterize(md,'../Par/SquareSheetConstrained.par');
+md=setelementstype(md,'macayeal','all');
+
+%control parameters
+md.control_analysis=1;
+md.control_type='drag_coefficient';
+md.cm_min=1;
+md.cm_max=200;
+md.nsteps=2;
+md.fit=2*ones(md.nsteps,1);
+md.weights=ones(md.numberofgrids,1);
+md.optscal=3*ones(md.nsteps,1);
+md.maxiter=2*ones(md.nsteps,1);
+md.cm_jump=0.3*ones(md.nsteps,1);
+%md.cm_noisedmp=2*10^-7;
+md.vx_obs=md.vx; md.vy_obs=md.vy;
+
+md.cluster='none';
+md=solve(md,'analysis_type',DiagnosticSolutionEnum);
Index: /issm/trunk/test/NightlyRun/test337_nightly.m
===================================================================
--- /issm/trunk/test/NightlyRun/test337_nightly.m	(revision 5033)
+++ /issm/trunk/test/NightlyRun/test337_nightly.m	(revision 5033)
@@ -0,0 +1,11 @@
+field_names     ={'Gradient' 'Misfits' 'DragCoefficient' 'Pressure' 'Vel' 'Vx' 'Vy'};
+field_tolerances={1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13};
+field_values={...
+	PatchToVec(md.results.DiagnosticSolution.Gradient),...
+	md.results.DiagnosticSolution.J,...
+	PatchToVec(md.results.DiagnosticSolution.DragCoefficient),...
+	PatchToVec(md.results.DiagnosticSolution.Pressure),...
+	PatchToVec(md.results.DiagnosticSolution.Vel),...
+	PatchToVec(md.results.DiagnosticSolution.Vx),...
+	PatchToVec(md.results.DiagnosticSolution.Vy)
+};
Index: /issm/trunk/test/NightlyRun/test338.m
===================================================================
--- /issm/trunk/test/NightlyRun/test338.m	(revision 5033)
+++ /issm/trunk/test/NightlyRun/test338.m	(revision 5033)
@@ -0,0 +1,21 @@
+md=mesh(model,'../Exp/Square.exp',200000);
+md=geography(md,'','');
+md=parameterize(md,'../Par/SquareSheetConstrained.par');
+md=setelementstype(md,'macayeal','all');
+
+%control parameters
+md.control_analysis=1;
+md.control_type='drag_coefficient';
+md.cm_min=1;
+md.cm_max=200;
+md.nsteps=2;
+md.fit=2*ones(md.nsteps,1);
+md.weights=ones(md.numberofgrids,1);
+md.optscal=3*ones(md.nsteps,1);
+md.maxiter=2*ones(md.nsteps,1);
+md.cm_jump=0.3*ones(md.nsteps,1);
+md.cm_noisedmp=2*10^-7;
+md.vx_obs=md.vx; md.vy_obs=md.vy;
+
+md.cluster=oshostname();
+md=solve(md,'analysis_type',DiagnosticSolutionEnum);
Index: /issm/trunk/test/NightlyRun/test338_nightly.m
===================================================================
--- /issm/trunk/test/NightlyRun/test338_nightly.m	(revision 5033)
+++ /issm/trunk/test/NightlyRun/test338_nightly.m	(revision 5033)
@@ -0,0 +1,11 @@
+field_names     ={'Gradient' 'Misfits' 'DragCoefficient' 'Pressure' 'Vel' 'Vx' 'Vy'};
+field_tolerances={1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13};
+field_values={...
+	PatchToVec(md.results.DiagnosticSolution.Gradient),...
+	md.results.DiagnosticSolution.J,...
+	PatchToVec(md.results.DiagnosticSolution.DragCoefficient),...
+	PatchToVec(md.results.DiagnosticSolution.Pressure),...
+	PatchToVec(md.results.DiagnosticSolution.Vel),...
+	PatchToVec(md.results.DiagnosticSolution.Vx),...
+	PatchToVec(md.results.DiagnosticSolution.Vy)
+};
Index: /issm/trunk/test/NightlyRun/test339.m
===================================================================
--- /issm/trunk/test/NightlyRun/test339.m	(revision 5032)
+++ /issm/trunk/test/NightlyRun/test339.m	(revision 5033)
@@ -1,8 +1,22 @@
-md=mesh(model,'../Exp/Square.exp',180000);
+md=mesh(model,'../Exp/Square.exp',200000);
 md=geography(md,'','');
 md=parameterize(md,'../Par/SquareSheetConstrained.par');
-md=extrude(md,4,1);
-md=setelementstype(md,'hutter','all');
+md=extrude(md,3,1);
+md=setelementstype(md,'macayeal','all');
+
+%control parameters
+md.control_analysis=1;
+md.control_type='drag_coefficient';
+md.cm_min=1;
+md.cm_max=200;
+md.nsteps=2;
+md.fit=2*ones(md.nsteps,1);
+md.weights=ones(md.numberofgrids,1);
+md.optscal=3*ones(md.nsteps,1);
+md.maxiter=2*ones(md.nsteps,1);
+md.cm_jump=0.3*ones(md.nsteps,1);
+md.cm_noisedmp=2*10^-7;
+md.vx_obs=md.vx; md.vy_obs=md.vy;
+
 md.cluster='none';
-md.dt=0;
-md=solve(md,'analysis_type',SteadystateSolutionEnum);
+md=solve(md,'analysis_type',DiagnosticSolutionEnum);
Index: /issm/trunk/test/NightlyRun/test339_nightly.m
===================================================================
--- /issm/trunk/test/NightlyRun/test339_nightly.m	(revision 5032)
+++ /issm/trunk/test/NightlyRun/test339_nightly.m	(revision 5033)
@@ -1,12 +1,11 @@
-field_names     ={'Vx','Vy','Vz','Vel','Pressure','Temperature','MeltingRate'};
-field_tolerances={1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13
+field_names     ={'Gradient' 'Misfits' 'DragCoefficient' 'Pressure' 'Vel' 'Vx' 'Vy'};
+field_tolerances={1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13};
+field_values={...
+	PatchToVec(md.results.DiagnosticSolution.Gradient),...
+	md.results.DiagnosticSolution.J,...
+	PatchToVec(md.results.DiagnosticSolution.DragCoefficient),...
+	PatchToVec(md.results.DiagnosticSolution.Pressure),...
+	PatchToVec(md.results.DiagnosticSolution.Vel),...
+	PatchToVec(md.results.DiagnosticSolution.Vx),...
+	PatchToVec(md.results.DiagnosticSolution.Vy)
 };
-field_values={...
-	PatchToVec(md.results.SteadystateSolution.Vx),...
-	PatchToVec(md.results.SteadystateSolution.Vy),...
-	PatchToVec(md.results.SteadystateSolution.Vz),...
-	PatchToVec(md.results.SteadystateSolution.Vel),...
-	PatchToVec(md.results.SteadystateSolution.Pressure),...
-	PatchToVec(md.results.SteadystateSolution.Temperature),...
-	PatchToVec(md.results.SteadystateSolution.MeltingRate),...
-	};
Index: /issm/trunk/test/NightlyRun/test340.m
===================================================================
--- /issm/trunk/test/NightlyRun/test340.m	(revision 5032)
+++ /issm/trunk/test/NightlyRun/test340.m	(revision 5033)
@@ -1,8 +1,22 @@
-md=mesh(model,'../Exp/Square.exp',180000);
+md=mesh(model,'../Exp/Square.exp',200000);
 md=geography(md,'','');
 md=parameterize(md,'../Par/SquareSheetConstrained.par');
-md=extrude(md,4,1);
-md=setelementstype(md,'hutter','all');
+md=extrude(md,3,1);
+md=setelementstype(md,'macayeal','all');
+
+%control parameters
+md.control_analysis=1;
+md.control_type='drag_coefficient';
+md.cm_min=1;
+md.cm_max=200;
+md.nsteps=2;
+md.fit=2*ones(md.nsteps,1);
+md.weights=ones(md.numberofgrids,1);
+md.optscal=3*ones(md.nsteps,1);
+md.maxiter=2*ones(md.nsteps,1);
+md.cm_jump=0.3*ones(md.nsteps,1);
+md.cm_noisedmp=2*10^-7;
+md.vx_obs=md.vx; md.vy_obs=md.vy;
+
 md.cluster=oshostname();
-md.dt=0;
-md=solve(md,'analysis_type',SteadystateSolutionEnum);
+md=solve(md,'analysis_type',DiagnosticSolutionEnum);
Index: /issm/trunk/test/NightlyRun/test340_nightly.m
===================================================================
--- /issm/trunk/test/NightlyRun/test340_nightly.m	(revision 5032)
+++ /issm/trunk/test/NightlyRun/test340_nightly.m	(revision 5033)
@@ -1,12 +1,11 @@
-field_names     ={'Vx','Vy','Vz','Vel','Pressure','Temperature','MeltingRate'};
-field_tolerances={1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13
+field_names     ={'Gradient' 'Misfits' 'DragCoefficient' 'Pressure' 'Vel' 'Vx' 'Vy'};
+field_tolerances={1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13};
+field_values={...
+	PatchToVec(md.results.DiagnosticSolution.Gradient),...
+	md.results.DiagnosticSolution.J,...
+	PatchToVec(md.results.DiagnosticSolution.DragCoefficient),...
+	PatchToVec(md.results.DiagnosticSolution.Pressure),...
+	PatchToVec(md.results.DiagnosticSolution.Vel),...
+	PatchToVec(md.results.DiagnosticSolution.Vx),...
+	PatchToVec(md.results.DiagnosticSolution.Vy)
 };
-field_values={...
-	PatchToVec(md.results.SteadystateSolution.Vx),...
-	PatchToVec(md.results.SteadystateSolution.Vy),...
-	PatchToVec(md.results.SteadystateSolution.Vz),...
-	PatchToVec(md.results.SteadystateSolution.Vel),...
-	PatchToVec(md.results.SteadystateSolution.Pressure),...
-	PatchToVec(md.results.SteadystateSolution.Temperature),...
-	PatchToVec(md.results.SteadystateSolution.MeltingRate),...
-	};
Index: /issm/trunk/test/NightlyRun/test341.m
===================================================================
--- /issm/trunk/test/NightlyRun/test341.m	(revision 5033)
+++ /issm/trunk/test/NightlyRun/test341.m	(revision 5033)
@@ -0,0 +1,22 @@
+md=mesh(model,'../Exp/Square.exp',200000);
+md=geography(md,'','');
+md=parameterize(md,'../Par/SquareSheetConstrained.par');
+md=extrude(md,3,1);
+md=setelementstype(md,'pattyn','all');
+
+%control parameters
+md.control_analysis=1;
+md.control_type='drag_coefficient';
+md.cm_min=1;
+md.cm_max=200;
+md.nsteps=2;
+md.fit=1*ones(md.nsteps,1);
+md.weights=ones(md.numberofgrids,1);
+md.optscal=3*ones(md.nsteps,1);
+md.maxiter=2*ones(md.nsteps,1);
+md.cm_jump=0.3*ones(md.nsteps,1);
+md.cm_noisedmp=2*10^-7;
+md.vx_obs=md.vx; md.vy_obs=md.vy;
+
+md.cluster='none';
+md=solve(md,'analysis_type',DiagnosticSolutionEnum);
Index: /issm/trunk/test/NightlyRun/test341_nightly.m
===================================================================
--- /issm/trunk/test/NightlyRun/test341_nightly.m	(revision 5033)
+++ /issm/trunk/test/NightlyRun/test341_nightly.m	(revision 5033)
@@ -0,0 +1,11 @@
+field_names     ={'Gradient' 'Misfits' 'DragCoefficient' 'Pressure' 'Vel' 'Vx' 'Vy'};
+field_tolerances={1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13};
+field_values={...
+	PatchToVec(md.results.DiagnosticSolution.Gradient),...
+	md.results.DiagnosticSolution.J,...
+	PatchToVec(md.results.DiagnosticSolution.DragCoefficient),...
+	PatchToVec(md.results.DiagnosticSolution.Pressure),...
+	PatchToVec(md.results.DiagnosticSolution.Vel),...
+	PatchToVec(md.results.DiagnosticSolution.Vx),...
+	PatchToVec(md.results.DiagnosticSolution.Vy)
+};
Index: /issm/trunk/test/NightlyRun/test342.m
===================================================================
--- /issm/trunk/test/NightlyRun/test342.m	(revision 5033)
+++ /issm/trunk/test/NightlyRun/test342.m	(revision 5033)
@@ -0,0 +1,22 @@
+md=mesh(model,'../Exp/Square.exp',200000);
+md=geography(md,'','');
+md=parameterize(md,'../Par/SquareSheetConstrained.par');
+md=extrude(md,3,1);
+md=setelementstype(md,'pattyn','all');
+
+%control parameters
+md.control_analysis=1;
+md.control_type='drag_coefficient';
+md.cm_min=1;
+md.cm_max=200;
+md.nsteps=2;
+md.fit=1*ones(md.nsteps,1);
+md.weights=ones(md.numberofgrids,1);
+md.optscal=3*ones(md.nsteps,1);
+md.maxiter=2*ones(md.nsteps,1);
+md.cm_jump=0.3*ones(md.nsteps,1);
+md.cm_noisedmp=2*10^-7;
+md.vx_obs=md.vx; md.vy_obs=md.vy;
+
+md.cluster=oshostname();
+md=solve(md,'analysis_type',DiagnosticSolutionEnum);
Index: /issm/trunk/test/NightlyRun/test342_nightly.m
===================================================================
--- /issm/trunk/test/NightlyRun/test342_nightly.m	(revision 5033)
+++ /issm/trunk/test/NightlyRun/test342_nightly.m	(revision 5033)
@@ -0,0 +1,11 @@
+field_names     ={'Gradient' 'Misfits' 'DragCoefficient' 'Pressure' 'Vel' 'Vx' 'Vy'};
+field_tolerances={1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13};
+field_values={...
+	PatchToVec(md.results.DiagnosticSolution.Gradient),...
+	md.results.DiagnosticSolution.J,...
+	PatchToVec(md.results.DiagnosticSolution.DragCoefficient),...
+	PatchToVec(md.results.DiagnosticSolution.Pressure),...
+	PatchToVec(md.results.DiagnosticSolution.Vel),...
+	PatchToVec(md.results.DiagnosticSolution.Vx),...
+	PatchToVec(md.results.DiagnosticSolution.Vy)
+};
Index: /issm/trunk/test/NightlyRun/test343.m
===================================================================
--- /issm/trunk/test/NightlyRun/test343.m	(revision 5033)
+++ /issm/trunk/test/NightlyRun/test343.m	(revision 5033)
@@ -0,0 +1,22 @@
+md=mesh(model,'../Exp/Square.exp',200000);
+md=geography(md,'','');
+md=parameterize(md,'../Par/SquareSheetConstrained.par');
+md=extrude(md,3,1);
+md=setelementstype(md,'macayeal','all','stokes','all');
+
+%control parameters
+md.control_analysis=1;
+md.control_type='drag_coefficient';
+md.cm_min=1;
+md.cm_max=200;
+md.nsteps=2;
+md.fit=4*ones(md.nsteps,1);
+md.weights=ones(md.numberofgrids,1);
+md.optscal=3*ones(md.nsteps,1);
+md.maxiter=2*ones(md.nsteps,1);
+md.cm_jump=0.3*ones(md.nsteps,1);
+md.cm_noisedmp=2*10^-7;
+md.vx_obs=md.vx; md.vy_obs=md.vy;
+
+md.cluster='none';
+md=solve(md,'analysis_type',DiagnosticSolutionEnum);
Index: /issm/trunk/test/NightlyRun/test343_nightly.m
===================================================================
--- /issm/trunk/test/NightlyRun/test343_nightly.m	(revision 5033)
+++ /issm/trunk/test/NightlyRun/test343_nightly.m	(revision 5033)
@@ -0,0 +1,11 @@
+field_names     ={'Gradient' 'Misfits' 'DragCoefficient' 'Pressure' 'Vel' 'Vx' 'Vy'};
+field_tolerances={1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13};
+field_values={...
+	PatchToVec(md.results.DiagnosticSolution.Gradient),...
+	md.results.DiagnosticSolution.J,...
+	PatchToVec(md.results.DiagnosticSolution.DragCoefficient),...
+	PatchToVec(md.results.DiagnosticSolution.Pressure),...
+	PatchToVec(md.results.DiagnosticSolution.Vel),...
+	PatchToVec(md.results.DiagnosticSolution.Vx),...
+	PatchToVec(md.results.DiagnosticSolution.Vy)
+};
Index: /issm/trunk/test/NightlyRun/test344.m
===================================================================
--- /issm/trunk/test/NightlyRun/test344.m	(revision 5033)
+++ /issm/trunk/test/NightlyRun/test344.m	(revision 5033)
@@ -0,0 +1,22 @@
+md=mesh(model,'../Exp/Square.exp',200000);
+md=geography(md,'','');
+md=parameterize(md,'../Par/SquareSheetConstrained.par');
+md=extrude(md,3,1);
+md=setelementstype(md,'macayeal','all','stokes','all');
+
+%control parameters
+md.control_analysis=1;
+md.control_type='drag_coefficient';
+md.cm_min=1;
+md.cm_max=200;
+md.nsteps=2;
+md.fit=4*ones(md.nsteps,1);
+md.weights=ones(md.numberofgrids,1);
+md.optscal=3*ones(md.nsteps,1);
+md.maxiter=2*ones(md.nsteps,1);
+md.cm_jump=0.3*ones(md.nsteps,1);
+md.cm_noisedmp=2*10^-7;
+md.vx_obs=md.vx; md.vy_obs=md.vy;
+
+md.cluster=oshostname();
+md=solve(md,'analysis_type',DiagnosticSolutionEnum);
Index: /issm/trunk/test/NightlyRun/test344_nightly.m
===================================================================
--- /issm/trunk/test/NightlyRun/test344_nightly.m	(revision 5033)
+++ /issm/trunk/test/NightlyRun/test344_nightly.m	(revision 5033)
@@ -0,0 +1,11 @@
+field_names     ={'Gradient' 'Misfits' 'DragCoefficient' 'Pressure' 'Vel' 'Vx' 'Vy'};
+field_tolerances={1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13};
+field_values={...
+	PatchToVec(md.results.DiagnosticSolution.Gradient),...
+	md.results.DiagnosticSolution.J,...
+	PatchToVec(md.results.DiagnosticSolution.DragCoefficient),...
+	PatchToVec(md.results.DiagnosticSolution.Pressure),...
+	PatchToVec(md.results.DiagnosticSolution.Vel),...
+	PatchToVec(md.results.DiagnosticSolution.Vx),...
+	PatchToVec(md.results.DiagnosticSolution.Vy)
+};
