Index: /issm/trunk/src/m/classes/balancethickness.m
===================================================================
--- /issm/trunk/src/m/classes/balancethickness.m	(revision 9853)
+++ /issm/trunk/src/m/classes/balancethickness.m	(revision 9854)
@@ -40,7 +40,11 @@
 		end % }}}
 		function checkconsistency(obj,md,solution,analyses) % {{{
+			%Early return
+			if solution~=BalancethicknessSolutionEnum, return; end
+
 			if ~ismember(md.balancethickness.stabilization,[0 1 3]),
 				checkmessage('model not consistent: balancethickness.stabilization should be a scalar (0 or 1 or 3)');
 			end
+
 		end % }}}
 		function disp(obj) % {{{
Index: /issm/trunk/src/m/classes/basalforcings.m
===================================================================
--- /issm/trunk/src/m/classes/basalforcings.m	(revision 9853)
+++ /issm/trunk/src/m/classes/basalforcings.m	(revision 9854)
@@ -37,6 +37,20 @@
 		function checkconsistency(obj,md,solution,analyses) % {{{
 
-			fields={'melting_rate','geothermalflux'};
+			fields={'geothermalflux'};
 			%checksize(md,'basalforcings',fields,[md.mesh.numberofvertices 1]);
+			if ismember(PrognosticAnalysisEnum,analyses),
+				fields={'melting_rate'};
+				checkforcing(md,'basalforcings',fields);
+			end
+			if ismember(BalancethicknessAnalysisEnum,analyses),
+				fields={'melting_rate'};
+				checksize(md,'basalforcings',fields,[md.mesh.numberofvertices 1]);
+				checknan(md, 'basalforcings',fields);
+			end
+			if ismember(ThermalAnalysisEnum,analyses),
+				fields={'geothermalflux'};
+				checksize(md,'basalforcings',fields,[md.mesh.numberofvertices 1]);
+				checknan(md, 'basalforcings',fields);
+			end
 		end % }}}
 		function disp(obj) % {{{
Index: /issm/trunk/src/m/classes/diagnostic.m
===================================================================
--- /issm/trunk/src/m/classes/diagnostic.m	(revision 9853)
+++ /issm/trunk/src/m/classes/diagnostic.m	(revision 9854)
@@ -103,4 +103,33 @@
 			end
 
+			if ismember(DiagnosticHorizAnalysisEnum,analyses),
+				%singular solution
+				if ~any((~isnan(md.diagnostic.spcvx)+~isnan(md.diagnostic.spcvy))==2),
+					checkmessage(['model ' md.miscellaneous.name ' is not well posed (singular). You need at least one node with fixed velocity!'])
+				end
+				%ROTATED SPC
+				%CHECK THAT EACH LINES CONTAINS ONLY NAN VALUES OR NO NAN VALUES
+				if any(sum(isnan(md.diagnostic.referential),2)~=0 & sum(isnan(md.diagnostic.referential),2)~=6),
+					checkmessage(['model ' md.miscellaneous.name ' has problem with rotated spc. Each line of diagnostic.referential should contain either only NaN values or no NaN values']);
+				end
+				%CHECK THAT THE TWO VECTORS PROVIDED ARE ORTHOGONAL
+				if any(sum(isnan(md.diagnostic.referential),2)==0),
+					pos=find(sum(isnan(md.diagnostic.referential),2)==0);
+					if any(dot(md.diagnostic.referential(pos,1:3),md.diagnostic.referential(pos,4:6))),
+						dot(md.diagnostic.referential(pos,1:3),md.diagnostic.referential(pos,4:6))
+						checkmessage(['model ' md.miscellaneous.name ' has problem with rotated spc. Vectors in diagnostic.referential (colums 1 to 3 and 4 to 6) must be orthogonal']);
+					end
+
+				end
+				%CHECK THAT ROTATION IS IN THE (X,Y) PLANE FOR 2D MODELS
+				if md.mesh.dimension==2,
+					pos=find(sum(isnan(md.diagnostic.referential),2)==0  & md.flowequation.vertex_equation==2);
+					if any(md.diagnostic.referential(pos,3:5)~=0);
+						checkmessage(['model ' md.miscellaneous.name ' has problem with rotated spc. The rotation should be in the (x,y) plane for 2D diagnostic models (nodeonmacayeal)']);
+					end
+				end
+
+			end
+
 		end % }}}
 		function disp(obj) % {{{
Index: /issm/trunk/src/m/classes/flowequation.m
===================================================================
--- /issm/trunk/src/m/classes/flowequation.m	(revision 9853)
+++ /issm/trunk/src/m/classes/flowequation.m	(revision 9854)
@@ -43,4 +43,36 @@
 		function checkconsistency(obj,md,solution,analyses) % {{{
 
+			if ismember(DiagnosticHorizAnalysisEnum,analyses),
+				%Check the size of flowequation.element_equation
+				fields={'element_equation'};
+				checksize(md,'flowequation',fields,[md.mesh.numberofelements 1]);
+				%Check the values of flowequation.element_equation
+				checkvalues(md,'flowequation',fields,[0:7]);
+				if (md.mesh.dimension==2),
+					checkvalues(md,'flowequation',fields,[1 2]);
+				end
+				if (md.flowequation.ismacayealpattyn==0 && md.flowequation.ishutter==0 && md.flowequation.isstokes==0),
+					checkmessage(['no elements type set for this model. at least one of ismacayealpattyn, ishutter and isstokes need to be =1']);
+				end
+
+				%VERTICESTYPE
+				%Check the size of verticess_type
+				fields={'vertex_equation'};
+				checksize(md,'flowequation',fields,[md.mesh.numberofvertices 1]);
+				%Check the values of flowequation.vertex_equation
+				checkvalues(md,'flowequation',fields,[0:7]);
+				if (md.mesh.dimension==2),
+					checkvalues(md,'flowequation',fields,[1 2]);
+				end
+				if (md.flowequation.ismacayealpattyn==0 && md.flowequation.ishutter==0 && md.flowequation.isstokes==0),
+					checkmessage(['no elements type set for this model. at least one of ismacayealpattyn, ishutter and isstokes need to be =1']);
+				end
+			end
+			if ismember(DiagnosticHutterAnalysisEnum,analyses),
+				if any(md.flowequation.element_equation==1 & md.mask.elementonfloatingice),
+					disp(sprintf('\n !!! Warning: Hutter''s model is not consistent on ice shelves !!!\n'));
+				end
+			end
+
 		end % }}}
 		function disp(obj) % {{{
Index: /issm/trunk/src/m/classes/geometry.m
===================================================================
--- /issm/trunk/src/m/classes/geometry.m	(revision 9853)
+++ /issm/trunk/src/m/classes/geometry.m	(revision 9854)
@@ -49,4 +49,9 @@
 				checkmessage(['equality thickness=surface-bed violated']);
 			end 
+
+			if ismember(PrognosticAnalysisEnum,analyses),
+				fields={'thickness'};
+				checkgreaterstrict(md,'geometry',fields,0);
+			end
 		end % }}}
 		function disp(obj) % {{{
Index: /issm/trunk/src/m/classes/hydrology.m
===================================================================
--- /issm/trunk/src/m/classes/hydrology.m	(revision 9853)
+++ /issm/trunk/src/m/classes/hydrology.m	(revision 9854)
@@ -51,4 +51,11 @@
 		function checkconsistency(obj,md,solution,analyses) % {{{
 
+			%Early return
+			if ~ismember(HydrologyAnalysisEnum,analyses), return; end
+
+
+			fields={'spcwatercolumn'};
+			checkforcing(md,'hydrology',fields);
+
 		end % }}}
 		function disp(obj) % {{{
Index: /issm/trunk/src/m/classes/initialization.m
===================================================================
--- /issm/trunk/src/m/classes/initialization.m	(revision 9853)
+++ /issm/trunk/src/m/classes/initialization.m	(revision 9854)
@@ -42,5 +42,34 @@
 		end % }}}
 		function checkconsistency(obj,md,solution,analyses) % {{{
-
+			if ismember(DiagnosticHorizAnalysisEnum,analyses)
+				if ~isnan(md.initialization.vx) & ~isnan(md.initialization.vy),
+					fields={'vx','vy'};
+					checknan(md, 'initialization',fields);
+					checksize(md,'initialization',fields,[md.mesh.numberofvertices 1]);
+				end
+			end
+			if ismember(PrognosticAnalysisEnum,analyses),
+				fields={'vx','vy'};
+				checknan(md, 'initialization',fields);
+				checksize(md,'initialization',fields,[md.mesh.numberofvertices 1]);
+			end
+			if ismember(HydrologyAnalysisEnum,analyses),
+				fields={'watercolumn'};
+				checksize(md,'initialization',fields,[md.mesh.numberofvertices 1]);
+			end
+			if ismember(BalancethicknessAnalysisEnum,analyses),
+				fields={'vx','vy'};
+				checksize(md,'initialization',fields,[md.mesh.numberofvertices 1]);
+				checknan(md, 'initialization',fields);
+				%Triangle with zero velocity
+				if any(sum(abs(md.initialization.vx(md.elements)),2)==0 & sum(abs(md.initialization.vy(md.elements)),2)==0)
+					checkmessage('model not consistent: at least one triangle has all its vertices with a zero velocity');
+				end
+			end
+			if ismember(ThermalAnalysisEnum,analyses),
+				fields={'vx','vy','vz','pressure'};
+				checksize(md,'initialization',fields,[md.mesh.numberofvertices 1]);
+				checknan(md, 'initialization',fields);
+			end
 		end % }}}
 		function disp(obj) % {{{
Index: /issm/trunk/src/m/classes/mesh.m
===================================================================
--- /issm/trunk/src/m/classes/mesh.m	(revision 9853)
+++ /issm/trunk/src/m/classes/mesh.m	(revision 9854)
@@ -146,4 +146,6 @@
 						checkgreaterstrict(md,'mesh',fields,0);
 					end
+				case ThermalSolutionEnum,
+					if md.mesh.dimension~=3, checkmessage('thermal solution only supported on 3d meshes'); end
 			end
 		end % }}}
Index: /issm/trunk/src/m/classes/prognostic.m
===================================================================
--- /issm/trunk/src/m/classes/prognostic.m	(revision 9853)
+++ /issm/trunk/src/m/classes/prognostic.m	(revision 9854)
@@ -47,11 +47,18 @@
 		end % }}}
 		function checkconsistency(obj,md,solution,analyses) % {{{
+
+			%Early return,
+			if ~ismember(PrognosticAnalysisEnum,analyses), return; end
+
+			if ~ismember(md.prognostic.hydrostatic_adjustment,{'Absolute' 'Incremental'}),
+				checkmessage(['model not consistent: model ' md.miscellaneous.name ' prognostic.hydrostatic_adjustment field should be AbsoluteEnum or IncrementalEnum']);
+			end
+
+			fields={'spcthickness'};
+			checkforcing(md,'prognostic',fields);
 			if ~ismember(obj.stabilization,[0 1 3]),
 				checkmessage('prognostic.stabilization should be a scalar (0 or 1 or 3)');
 			end
 
-			if ~ismember(md.prognostic.hydrostatic_adjustment,{'Absolute' 'Incremental'}),
-				checkmessage(['model not consistent: model ' md.miscellaneous.name ' prognostic.hydrostatic_adjustment field should be AbsoluteEnum or IncrementalEnum']);
-			end
 		end % }}}
 		function disp(obj) % {{{
Index: /issm/trunk/src/m/classes/surfaceforcings.m
===================================================================
--- /issm/trunk/src/m/classes/surfaceforcings.m	(revision 9853)
+++ /issm/trunk/src/m/classes/surfaceforcings.m	(revision 9854)
@@ -37,4 +37,13 @@
 		function checkconsistency(obj,md,solution,analyses) % {{{
 
+			if ismember(PrognosticAnalysisEnum,analyses),
+				fields={'mass_balance'};
+				checkforcing(md,'surfaceforcings',fields);
+			end
+			if ismember(BalancethicknessAnalysisEnum,analyses),
+				fields={'mass_balance'};
+				checksize(md,'surfaceforcings',fields,[md.mesh.numberofvertices 1]);
+				checknan(md, 'surfaceforcings',fields);
+			end
 		end % }}}
 		function disp(obj) % {{{
Index: /issm/trunk/src/m/classes/thermal.m
===================================================================
--- /issm/trunk/src/m/classes/thermal.m	(revision 9853)
+++ /issm/trunk/src/m/classes/thermal.m	(revision 9854)
@@ -51,7 +51,14 @@
 		end % }}}
 		function checkconsistency(obj,md,solution,analyses) % {{{
+
+			%Early return
+			if ~ismember(ThermalAnalysisEnum,analyses), return; end
+
 			if ~ismember(obj.stabilization,[0 1 2]),
 				checkmessage('thermal.stabilization should be a scalar (0 or 1 or 2)');
 			end
+
+			fields={'spctemperature'};
+			checkforcing(md,'thermal',fields);
 
 		end % }}}
Index: /issm/trunk/src/m/classes/transient.m
===================================================================
--- /issm/trunk/src/m/classes/transient.m	(revision 9853)
+++ /issm/trunk/src/m/classes/transient.m	(revision 9854)
@@ -45,4 +45,9 @@
 		end % }}}
 		function checkconsistency(obj,md,solution,analyses) % {{{
+
+			%Early return
+			if solution~=TransientSolutionEnum, return; end
+
+			%check flags
 			if ~ismember(md.transient.isdiagnostic,[0 1]),
 				checkmessage('model not consistent: transient.isdiagnostic should be a scalar (1 or 0)');
@@ -56,4 +61,14 @@
 			if ~ismember(md.transient.isgroundingline,[0 1]),
 				checkmessage('model not consistent: transient.isgroundingline should be a scalar (1 or 0)');
+			end
+
+			%check that groundingline is not activated in serial model
+			if md.transient.isgroundingline & strcmp(md.cluster.name,'none'),
+				checkmessage(['model not consistent: ' md.private.solution ' is only implemented in parallel mode !']);
+			end
+
+			%Check that grounding line migration is in 2d
+			if md.transient.isgroundingline & md.mesh.dimension~=2
+				checkmessage(['model not consistent: for a ' md.private.solution ' computation, the grounding line module is only implemented in 2d !']);
 			end
 
