Index: /issm/trunk-jpl/src/m/contrib/paraview/exportVTK.py
===================================================================
--- /issm/trunk-jpl/src/m/contrib/paraview/exportVTK.py	(revision 18514)
+++ /issm/trunk-jpl/src/m/contrib/paraview/exportVTK.py	(revision 18515)
@@ -1,4 +1,3 @@
 import numpy
-
 def exportVTK(filename,model,options):
     '''
@@ -27,5 +26,9 @@
 
 #get the element related variables
-points=[model.mesh.x model.mesh.y model.mesh.z]
+if model.mesh.shape[0]==2:
+    points=[model.mesh.x model.mesh.y zeros(model.mesh.numberofvertices,1)];
+else:
+    points=[model.mesh.x model.mesh.y model.mesh.z]
+
 [num_of_points,dim]=numpy.size(points)
 [num_of_elt]=numpy.size(model.mesh.elements,1)
@@ -42,14 +45,18 @@
 #this is the result structure
 res_struct=model.results
-#Getting all the solutions of the model
-solnames=fields(res_struct)
-num_of_sols=numpy.length(solnames)
-num_of_timesteps=1
-#%building solutionstructure 
-for solution in num_of_sols:
-    sol_struct{i}=res_struct.(solnames{i});
-    #looking for multiple time steps
-    if(numpy.size(sol_struct{i},2)>num_of_timesteps):
-        num_of_timesteps=numpy.size(sol_struct{i},2);
+if (len(fields(res_struct))>0):
+    #Getting all the solutions of the model
+    solnames=fields(res_struct)
+    num_of_sols=numpy.length(solnames)
+    num_of_timesteps=1
+    #%building solutionstructure 
+    for solution in num_of_sols:
+        sol_struct{i}=res_struct.(solnames{i});
+        #looking for multiple time steps
+        if(numpy.size(sol_struct{i},2)>num_of_timesteps):
+            num_of_timesteps=numpy.size(sol_struct{i},2);
+
+else:
+    num_of_timesteps=1
 
 for step in num_of_timesteps:
@@ -73,18 +80,19 @@
 	
     fid.write('CELLS %d %d\n' % num_of_elt % num_of_elt*(point_per_elt+1))
-	s='%d'
-	for j=1:point_per_elt:
-            s=horzcat(s,{' %d'})
+    s='%d'
+    for j=1:point_per_elt:
+        s=horzcat(s,{' %d'})
         
-	s=cell2mat(horzcat(s,{'\n'}))
-	fid.write(fid,s,[(point_per_elt)*ones(num_of_elt,1) model.mesh.elements-1]transpose)
-	
-	fid.write(fid,'CELL_TYPES %d\n',num_of_elt)
-	s='%d\n'
-	fid.write(fid,s,celltype*ones(num_of_elt,1))
-	fid.write(fid,'POINT_DATA %s \n',num2str(num_of_points))
-
-	#loop over the different solution structures
-	for j=1:num_of_sols:
+    s=cell2mat(horzcat(s,{'\n'}))
+    fid.write(fid,s,[(point_per_elt)*ones(num_of_elt,1) model.mesh.elements-1]transpose)
+    
+    fid.write(fid,'CELL_TYPES %d\n',num_of_elt)
+    s='%d\n'
+    fid.write(fid,s,celltype*ones(num_of_elt,1))
+    fid.write(fid,'POINT_DATA %s \n',num2str(num_of_points))
+    
+    #loop over the different solution structures
+    if 'num_of_sols' in locals():
+        for j=1:num_of_sols:
             #dealing with results on different timesteps
             if(numpy.size(sol_struct{j},2)>timestep):
@@ -92,5 +100,5 @@
             else:
                 timestep = numpy.size(sol_struct{j},2)
-	  
+                
             #getting the number of fields in the solution
             fieldnames=fields(sol_struct{j}(timestep))
@@ -111,21 +119,21 @@
                     fid.write(s % sol_struct{j}(timestep).(fieldnames{k}))
                     
-                    #loop on arguments, if something other than result is asked, do
-                    #it now
-                for j= 1:nargin-2:
-                    res_struct=model.(varargin{j})
-                    fieldnames=fields(res_struct)
-                    num_of_fields=numpy.length(fieldnames)
-                    for k=1:num_of_fields:
-			if ((numel(res_struct.(fieldnames{k})))==num_of_points)
-				#paraview does not like NaN, replacing
-				nanval=find(isnan(res_struct.(fieldnames{k})))
-				res_struct.(fieldnames{k})(nanval)=-9999
-				#also checking for verry small value that mess up
-				smallval=(abs(res_struct.(fieldnames{k}))<1.0e-20)
-				res_struct.(fieldnames{k})(smallval)=0.0
-				fid.write(fid,'SCALARS %s float 1 \n',fieldnames{k})
-				fid.write(fid,'LOOKUP_TABLE default\n')
-				s='%e\n'
-				fid.write(fid,s,res_struct.(fieldnames{k}))
-	fid.close();
+    #loop on arguments, if something other than result is asked, do
+    #it now
+    for j= 1:nargin-2:
+        res_struct=model.(varargin{j})
+        fieldnames=fields(res_struct)
+        num_of_fields=numpy.length(fieldnames)
+        for k=1:num_of_fields:
+            if ((numel(res_struct.(fieldnames{k})))==num_of_points):
+                #paraview does not like NaN, replacing
+                nanval=find(isnan(res_struct.(fieldnames{k})))
+                res_struct.(fieldnames{k})(nanval)=-9999
+                #also checking for verry small value that mess up
+                smallval=(abs(res_struct.(fieldnames{k}))<1.0e-20)
+                res_struct.(fieldnames{k})(smallval)=0.0
+                fid.write(fid,'SCALARS %s float 1 \n',fieldnames{k})
+                fid.write(fid,'LOOKUP_TABLE default\n')
+                s='%e\n'
+                fid.write(fid,s,res_struct.(fieldnames{k}))
+    fid.close();
