Index: /issm/trunk/src/m/model/ismodelselfconsistent.m
===================================================================
--- /issm/trunk/src/m/model/ismodelselfconsistent.m	(revision 8248)
+++ /issm/trunk/src/m/model/ismodelselfconsistent.m	(revision 8249)
@@ -351,4 +351,26 @@
 				if any(find(md.spcthickness(pos,1)==0)),
 					error(['model not consistent: model ' md.name ' has some grids with 0 thickness']);
+				end
+			end
+
+			%ROTATED SPC
+			%CHECK THAT EACH LINES CONTAINS ONLY NAN VALUES OR NO NAN VALUES
+			if any(sum(isnan(md.diagnostic_ref),2)~=0 & sum(isnan(md.diagnostic_ref),2)~=6),
+				error(['model not consistent: model ' md.name ' has problem with rotated spc. Each line of diagnostic_ref 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_ref),2)==0),
+				pos=find(sum(isnan(md.diagnostic_ref),2)==0);
+				if any(dot(md.diagnostic_ref(pos,1:3),md.diagnostic_ref(pos,4:6))),
+					dot(md.diagnostic_ref(pos,1:3),md.diagnostic_ref(pos,4:6))
+					error(['model not consistent: model ' md.name ' has problem with rotated spc. Vectors in diagnostic_ref (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 any(md.gridonmacayeal),
+				pos=find(sum(isnan(md.diagnostic_ref),2)==0  & md.gridonmacayeal);
+				if any(md.diagnostic_ref(pos,3:5)~=0);
+					error(['model not consistent: model ' md.name ' has problem with rotated spc. The rotation should be in the (x,y) plane for 2D diagnostic models (gridonmacayeal)']);
 				end
 			end
