Index: /issm/trunk/test/NightlyRun/Id2Name.m
===================================================================
--- /issm/trunk/test/NightlyRun/Id2Name.m	(revision 4950)
+++ /issm/trunk/test/NightlyRun/Id2Name.m	(revision 4950)
@@ -0,0 +1,9 @@
+function name=Id2Name(id);
+%ID2NAME- return name of test
+%
+%   Usage:
+%      name=Id2Name(id);
+
+if     (id==201), name='SquareShelfDiagM2dSerial';
+elseif (id==202), name='SquareShelf...';
+else name='N/A'; end
Index: /issm/trunk/test/NightlyRun/runme.m
===================================================================
--- /issm/trunk/test/NightlyRun/runme.m	(revision 4950)
+++ /issm/trunk/test/NightlyRun/runme.m	(revision 4950)
@@ -0,0 +1,133 @@
+function varargout=runme(varargin)
+%RUNME - test deck for ISSM nightly runs
+%
+%   In a test deck directory (tests/Vertification/test01_IceShelfIceFrontM2d for example)
+%   The following command will launch all the existing tests for test01
+%   >> runme
+%   To run the tests in serial only
+%   >> runme('parallel',0)
+%   etc...
+%
+%   Available options:
+%      'analysis_type' followed by the desired SolutionEnum
+%      'parallel'      0: serial only
+%                      1: parallel only
+%      'procedure'     'check' : run the test (default)
+%                      'update': update the archive
+%                      'model' : prepare the model but no test is run
+%
+%   Usage:
+%      md=runme(varargin);
+%
+%   Examples:
+%      runme;
+%      runme('analysis_type',DiagnosticSolutionEnum);
+%      runme('analysis_type',DiagnosticSolutionEnum,'parallel',0);
+%      runme('procedure','update','analysis_type',DiagnosticSolutionEnum,'parallel',1);
+
+% This file can be run to check that the current version of issm is giving 
+% coherent results.
+% is square. Just run this file in Matlab, with a properly setup ISSM code. 
+% The results of this test will indicate if there is a difference between current computations 
+% and archived results.
+
+% Errors  between archived results and the current version will get flagged if they are not within 
+% a certain tolerance.
+
+%use ISSM_DIR generated by startup.m
+global ISSM_DIR
+
+%recover options
+options=pairoptions(varargin{:});
+
+%check arguments
+if nargout>1
+	help runme
+	error('runme error message: bad usage');
+end
+
+%GET procedure
+procedure=getfieldvalue(options,'procedure','check');
+if ~ismember(procedure,{'check','update'})
+	disp('runme warning: procedure not supported, defaulting to test ''check''')
+	procedure='check';
+end
+
+%GET ids
+list=dir;%use dir, as it seems to act OS independent
+list_ids=[];
+for i=1:numel(list),
+	if ( strncmpi(list(i).name,'test',4) &...                         %File name must start with 'test'
+			strncmpi(fliplr(list(i).name),fliplr('.m'),2)&...           %File name must end by '.m'
+			~strncmpi(fliplr(list(i).name),fliplr('_nightly.m'),10)),   %File name end should be different that '_nightly.m'
+		list_ids(end+1)=eval(list(i).name(end-4:end-2));             %Keep test id only (3 digits)
+	end
+end
+test_ids=getfieldvalue(options,'id',list_ids);
+test_ids=intersect(test_ids,list_ids);
+
+%Loop over tests and launch sequence
+for id=test_ids,
+	try,
+
+		%Execute test
+		eval(['test' num2str(id)]);
+		eval(['test' num2str(id) '_nightly']);
+
+		%UPDATE ARCHIVE?
+		archive_name=['Archive' num2str(id) ];
+		if strcmpi(procedure,'update'),
+
+			for k=1:length(field_names),
+				field=field_values{k};
+				eval([ archive_name '_field' num2str(k) ' =  field ;']);
+			end
+			eval(['save ./../Archives/' archive_name ' ' archive_name '_field*']);
+			disp(sprintf(['File ./../Archives/' archive_name ' saved\n']));
+
+			%ELSE: CHECK TEST
+		else,
+
+			%load archive
+			load(['./../Archives/' archive_name ]);
+
+			for k=1:length(field_names),
+
+				%Get field and tolerance
+				field=field_values{k};
+				fieldname=field_names{k};
+				tolerance=field_tolerances{k};
+
+				%compare to archive
+				eval(['archive=' archive_name '_field' num2str(k) ';']);
+				error_diff=full(max(abs(archive-field))/(max(abs(archive))+eps));
+
+				%disp test result
+				if (error_diff>tolerance);
+					disp(sprintf(['ERROR   difference: %-7.2g > %7.2g test id: %i test name: %s field: %s'],...
+						error_diff,tolerance,id,Id2Name(id),fieldname));
+				else
+					disp(sprintf(['SUCCESS difference: %-7.2g < %7.2g test id: %i test name: %s field: %s'],...
+						error_diff,tolerance,id,Id2Name(id),fieldname));
+				end
+			end
+		end
+
+	catch me,
+
+		%something went wrong, print failure message:
+		directory=strsplit(pwd,'/');
+		message=getReport(me)
+		fid=fopen([ISSM_DIR '/test/Verification/NightlyRun/matlaberror.log'], 'at');
+		fprintf(fid,'\n\nMatlab error occured in: %s\n\n',directory{end});
+		fprintf(fid,'%s',message);
+		fclose(fid);
+		%disp(sprintf(['\nFAILURE test: %s analysis_type: %s sub_analysis_type: %s qmu: %i control: %i control_fit: %s parallel: %i\n'],...
+			%testname,EnumAsString(analysis_type),EnumAsString(sub_analysis_type),qmu,control,control_fit,parallel));
+	end
+end
+
+%output md if requested
+if nargout==1
+	varargout{1}=md;
+end
Index: /issm/trunk/test/NightlyRun/test201.m
===================================================================
--- /issm/trunk/test/NightlyRun/test201.m	(revision 4950)
+++ /issm/trunk/test/NightlyRun/test201.m	(revision 4950)
@@ -0,0 +1,5 @@
+md=mesh(model,'../Exp/Square.exp',150000);
+md=geography(md,'all','');
+md=parameterize(md,'../Par/SquareShelf.par');
+md=setelementstype(md,'macayeal','all');
+md=solve(md,'analysis_type',DiagnosticSolutionEnum);
Index: /issm/trunk/test/NightlyRun/test201_nightly.m
===================================================================
--- /issm/trunk/test/NightlyRun/test201_nightly.m	(revision 4950)
+++ /issm/trunk/test/NightlyRun/test201_nightly.m	(revision 4950)
@@ -0,0 +1,8 @@
+field_names     ={'Vx','Vy','Vel','Pressure'};
+field_tolerances={1e-13,1e-13,1e-13,1e-13};
+field_values={...
+	PatchToVec(md.results.DiagnosticSolution.Vx),...
+	PatchToVec(md.results.DiagnosticSolution.Vy),...
+	PatchToVec(md.results.DiagnosticSolution.Vel),...
+	PatchToVec(md.results.DiagnosticSolution.Pressure),...
+	};
Index: /issm/trunk/test/Par/SquareShelf.par
===================================================================
--- /issm/trunk/test/Par/SquareShelf.par	(revision 4949)
+++ /issm/trunk/test/Par/SquareShelf.par	(revision 4950)
@@ -1,8 +1,5 @@
 %Start defining model parameters here
 
-%dynamics
-md.verbose=0;
-md.artificial_diffusivity=1;
-
+%Geometry
 hmin=300;
 hmax=1000;
@@ -13,23 +10,29 @@
 md.surface=md.bed+md.thickness;
 
-md.drag_type=2; %0 none 1 plastic 2 viscous
-md.drag_coefficient=200*ones(md.numberofgrids,1); %q=1.
-%Take care of iceshelves: no basal drag
-pos=find(md.elementoniceshelf);
-md.drag_coefficient(md.elements(pos,:))=0;
-md.drag_p=ones(md.numberofelements,1);
-md.drag_q=ones(md.numberofelements,1);
-md.viscosity_overshoot=0.3;
+%Initial velocity 
+load('./../Data/SquareShelf.data','-mat');
+md.vx=InterpFromMeshToMesh2d(index,x,y,vx,md.x,md.y,0);
+md.vy=InterpFromMeshToMesh2d(index,x,y,vy,md.x,md.y,0);
+clear vx vy x y index;
 
-%Create temperature and rheology
+%Materials
 md.observed_temperature=(273-20)*ones(md.numberofgrids,1);
 md.rheology_B=paterson(md.observed_temperature);
 md.rheology_n=3*ones(md.numberofelements,1);
 
-%Deal with boundary conditions:
-md=SetIceShelfBC(md,'Front.exp');
+%Friction
+pos=find(md.elementoniceshelf);
+md.drag_coefficient=20*ones(md.numberofgrids,1);
+md.drag_coefficient(md.elements(pos,:))=0;
+md.drag_p=ones(md.numberofelements,1);
+md.drag_q=ones(md.numberofelements,1);
 
-%Parallel options
+%Numerical parameters
+md.viscosity_overshoot=0.3;
+md.verbose=0;
+md.artificial_diffusivity=1;
 md.np=3;
-md.time=50;
 md.waitonlock=30;
+
+%Boundary conditions:
+md=SetIceShelfBC(md,'./../Exp/SquareFront.exp');
Index: /issm/trunk/test/Validation/ISMIP/TestA/Square.par
===================================================================
--- /issm/trunk/test/Validation/ISMIP/TestA/Square.par	(revision 4949)
+++ /issm/trunk/test/Validation/ISMIP/TestA/Square.par	(revision 4950)
@@ -24,3 +24,5 @@
 md=SetIceSheetBC(md);
 
-md.np=3;
+md.np=10;
+md.cluster=oshostname();
+md.verbose=10;
