Index: /issm/trunk/examples/Greenland/runme.m
===================================================================
--- /issm/trunk/examples/Greenland/runme.m	(revision 20547)
+++ /issm/trunk/examples/Greenland/runme.m	(revision 20548)
@@ -1,4 +1,4 @@
 clear all;
-steps=[1 2 3 4 5];
+steps=[1];
 
 %Location of SeaRISE dataset
@@ -146,5 +146,5 @@
 	lat  = ncread(ncbox,'lat');
 	lon  = ncread(ncbox,'lon');
-	smbbox = ncread(ncbox,'SMB');
+	smbbox = ncread(ncbox,'MassFlux');
 	[x1 y1]=ll2xy(lat,lon,+1,45,70);
 
Index: /issm/trunk/examples/ISMIP/CheatyRunme.m
===================================================================
--- /issm/trunk/examples/ISMIP/CheatyRunme.m	(revision 20547)
+++ /issm/trunk/examples/ISMIP/CheatyRunme.m	(revision 20548)
@@ -3,5 +3,5 @@
 %step 8 is specific to ISMIPF
 
-steps=[1:7];
+steps=[1];
 
 % parameter file to be used, choose between CheatyIsmipA.par or CheatyIsmipF.par
Index: /issm/trunk/examples/IceBridge/Greenland.par
===================================================================
--- /issm/trunk/examples/IceBridge/Greenland.par	(revision 20547)
+++ /issm/trunk/examples/IceBridge/Greenland.par	(revision 20548)
@@ -62,6 +62,6 @@
 
 disp('   Interpolating surface mass balance');
-md.surfaceforcings.mass_balance=InterpFromGridToMesh(x1,y1,smb,md.mesh.x,md.mesh.y,0);
-md.surfaceforcings.mass_balance=md.surfaceforcings.mass_balance*md.materials.rho_water/md.materials.rho_ice;
+md.smb.mass_balance=InterpFromGridToMesh(x1,y1,smb,md.mesh.x,md.mesh.y,0);
+md.smb.mass_balance=md.smb.mass_balance*md.materials.rho_water/md.materials.rho_ice;
 
 disp('   Construct basal friction parameters');
Index: /issm/trunk/examples/IceBridge/Greenland_cheatsheet.par
===================================================================
--- /issm/trunk/examples/IceBridge/Greenland_cheatsheet.par	(revision 20547)
+++ /issm/trunk/examples/IceBridge/Greenland_cheatsheet.par	(revision 20548)
@@ -66,6 +66,6 @@
 
 disp('   Interpolating surface mass balance');
-md.surfaceforcings.mass_balance=InterpFromGridToMesh(x1,y1,smb,md.mesh.x,md.mesh.y,0);
-md.surfaceforcings.mass_balance=md.surfaceforcings.mass_balance*md.materials.rho_water/md.materials.rho_ice;
+md.smb.mass_balance=InterpFromGridToMesh(x1,y1,smb,md.mesh.x,md.mesh.y,0);
+md.smb.mass_balance=md.smb.mass_balance*md.materials.rho_water/md.materials.rho_ice;
 
 disp('   Construct basal friction parameters');
Index: /issm/trunk/examples/IceBridge/Greenland_noOIB.par
===================================================================
--- /issm/trunk/examples/IceBridge/Greenland_noOIB.par	(revision 20547)
+++ /issm/trunk/examples/IceBridge/Greenland_noOIB.par	(revision 20548)
@@ -40,6 +40,6 @@
 
 disp('   Interpolating surface mass balance');
-md.surfaceforcings.mass_balance=InterpFromGridToMesh(x1,y1,smb,md.mesh.x,md.mesh.y,0);
-md.surfaceforcings.mass_balance=md.surfaceforcings.mass_balance*md.materials.rho_water/md.materials.rho_ice;
+md.smb.mass_balance=InterpFromGridToMesh(x1,y1,smb,md.mesh.x,md.mesh.y,0);
+md.smb.mass_balance=md.smb.mass_balance*md.materials.rho_water/md.materials.rho_ice;
 
 disp('   Construct basal friction parameters');
Index: /issm/trunk/examples/IceBridge/runme.m
===================================================================
--- /issm/trunk/examples/IceBridge/runme.m	(revision 20547)
+++ /issm/trunk/examples/IceBridge/runme.m	(revision 20548)
@@ -46,5 +46,5 @@
 
 	md = setmask(md,'','');
-	md = parameterize(md,'./Greenland_cheatsheet.par');
+	md = parameterize(md,'./Greenland.par');
 	%md = parameterize(md,'./Greenland_noOIB.par');
 	md = setflowequation(md,'SSA','all');
@@ -108,5 +108,5 @@
 	smb = InterpFromGridToMesh(x1,y1,smb',md.mesh.x,md.mesh.y,0)*1000/md.materials.rho_ice;
 	smb = [smb smb smb-1.0];
-	md.surfaceforcings.mass_balance = [smb;1 10 20];
+	md.smb.mass_balance = [smb;1 10 20];
 
 	%Set transient options, run for 20 years, saving every year
@@ -117,5 +117,5 @@
 	%Additional options
 	md.inversion.iscontrol=0;
-	md.transient.requested_outputs={'IceVolume','TotalSmb','SurfaceforcingsMassBalance'};
+	md.transient.requested_outputs={'IceVolume','TotalSmb','SmbMassBalance'};
 	md.verbose=verbose('solution',true,'module',true,'convergence',true);
 
@@ -134,5 +134,5 @@
 	plotmodel(md,'data',md.results.TransientSolution(end).Vel,'caxis',[1e-1 6000],...
 		'log', 10, 'title', 'Velocity (m/y)','gridded',1, ...
-		'data', md.results.TransientSolution(end).SurfaceforcingsMassBalance, ...
+		'data', md.results.TransientSolution(end).SmbMassBalance, ...
 		'title', 'Surface mass balance (m/y)','gridded',1, ...
 		'data',md.results.TransientSolution(end).Thickness,...
@@ -146,5 +146,5 @@
 	%Plot surface mass balance
 	surfmb=[]; for i=1:100; surfmb=[surfmb ...
-		md.results.TransientSolution(i).SurfaceforcingsMassBalance]; end
+		md.results.TransientSolution(i).SmbMassBalance]; end
 	subplot(3,1,1); plot([0.2:0.2:20],mean(surfmb)); title('Mean Surface mass balance');
 
Index: /issm/trunk/examples/IceflowModels/EISMINT.par
===================================================================
--- /issm/trunk/examples/IceflowModels/EISMINT.par	(revision 20547)
+++ /issm/trunk/examples/IceflowModels/EISMINT.par	(revision 20548)
@@ -29,5 +29,5 @@
 sb=10^-2/1000.; %m/yr/m
 rel=450.*1000.; %m
-md.surfaceforcings.mass_balance=min(smb_max,sb*(rel-radius));
+md.smb.mass_balance=min(smb_max,sb*(rel-radius));
 
 disp('      creating velocities');
Index: /issm/trunk/examples/Jakobshavn/Jks.par
===================================================================
--- /issm/trunk/examples/Jakobshavn/Jks.par	(revision 20547)
+++ /issm/trunk/examples/Jakobshavn/Jks.par	(revision 20548)
@@ -38,6 +38,6 @@
 
 disp('   Interpolating surface mass balance');
-md.surfaceforcings.mass_balance=InterpFromGridToMesh(x1,y1,smb,md.mesh.x,md.mesh.y,0);
-md.surfaceforcings.mass_balance=md.surfaceforcings.mass_balance*md.materials.rho_water/md.materials.rho_ice;
+md.smb.mass_balance=InterpFromGridToMesh(x1,y1,smb,md.mesh.x,md.mesh.y,0);
+md.smb.mass_balance=md.smb.mass_balance*md.materials.rho_water/md.materials.rho_ice;
 
 disp('   Construct basal friction parameters');
Index: /issm/trunk/examples/Jakobshavn/runme.m
===================================================================
--- /issm/trunk/examples/Jakobshavn/runme.m	(revision 20547)
+++ /issm/trunk/examples/Jakobshavn/runme.m	(revision 20548)
@@ -1,3 +1,3 @@
-steps=[4];
+steps=[1];
 
 if any(steps==1)
Index: /issm/trunk/examples/UncertaintyQuantification/runme.m
===================================================================
--- /issm/trunk/examples/UncertaintyQuantification/runme.m	(revision 20547)
+++ /issm/trunk/examples/UncertaintyQuantification/runme.m	(revision 20548)
@@ -1,4 +1,4 @@
 %PIG Uncertainty Quantification Application
-steps=[1:3]; 
+steps=[1]; 
 
 if any(steps==1) 
@@ -140,8 +140,17 @@
 
 	md.stressbalance.restol=10^-5; %tighten tolerances for UQ analyses
+
+	%Turn off verbosity
+	md.verbose=verbose(0);
 	
 	%solve
 	md.qmu.isdakota=1; md.inversion.iscontrol=0;
 	md.cluster=generic('name',oshostname,'np',4);
+
+	%Dakota runs in parallel with a master/slave configuration.
+	% At least 2 cpu's are needed to run the UQ
+	md.qmu.params.evaluation_scheduling='master';
+	md.qmu.params.processors_per_evaluation=md.cluster.np-1;
+
 	md=solve(md,StressbalanceSolutionEnum,'overwrite','y');
 
@@ -217,4 +226,10 @@
 	md.inversion.iscontrol=0;
 	md.cluster=generic('name',oshostname,'np',2);
+
+	%Dakota runs in parallel with a master/slave configuration.
+	% At least 2 cpu's are needed to run the UQ
+	md.qmu.params.evaluation_scheduling='master';
+	md.qmu.params.processors_per_evaluation=md.cluster.np-1
+
 	md.verbose=verbose('qmu',true);
 	md=solve(md,StressbalanceSolutionEnum,'overwrite','y');
Index: /issm/trunk/jenkins/jenkins.sh
===================================================================
--- /issm/trunk/jenkins/jenkins.sh	(revision 20547)
+++ /issm/trunk/jenkins/jenkins.sh	(revision 20548)
@@ -7,4 +7,7 @@
 rm -rf $ISSM_DIR/nightlylog
 mkdir  $ISSM_DIR/nightlylog
+
+#Server URI
+SERVER='https://ross.ics.uci.edu:8080'
 
 #Get configuration
@@ -44,5 +47,5 @@
 	#Get changes from jenkins itself (svn requires credentials)
 	rm -rf changes
-	wget http://ross.ics.uci.edu:8080/job/$JOB_NAME/$BUILD_NUMBER/changes > /dev/null 2>&1
+	wget $SERVER/job/$JOB_NAME/$BUILD_NUMBER/changes > /dev/null 2>&1
 
 	#Process html page and get the list of files that has changed (tricky...)
@@ -60,8 +63,8 @@
 	if [ ! -z "$(cat $ISSM_DIR/TEMP | grep externalpackages)" ] ; then
 		echo "  -- checking for changed externalpackages... yes";
-		ISSM_EXTERNALPACKAGES="install"
+		ISSM_EXTERNALPACKAGES="yes"
 	else
 		echo "  -- checking for changed externalpackages... no";
-		ISSM_EXTERNALPACKAGES="none"
+		ISSM_EXTERNALPACKAGES="no"
 	fi
 
@@ -89,5 +92,5 @@
 	echo "  -- checking for reconfiguration... yes";
 	echo "  -- checking for recompilation... yes";
-	ISSM_EXTERNALPACKAGES="install"
+	ISSM_EXTERNALPACKAGES="yes"
 	ISSM_RECONFIGURE="yes"
 	ISSM_COMPILATION="yes"
@@ -97,5 +100,5 @@
 echo $SVN_REVISION_1 > $ISSM_DIR/svn_revision_old
 #}}}
-#install/none external packages    (ISSM_EXTERNALPACKAGES){{{
+#Install external packages    (ISSM_EXTERNALPACKAGES){{{
 
 #Jenkins xml files for individual packages
@@ -115,7 +118,6 @@
 	cd $ISSM_DIR/externalpackages/$PACKAGENAME
 
-	#install if requested or if install does not exist
-	if [ "$ISSM_EXTERNALPACKAGES" == "install" ] || [ ! -d install ] || [ ! "$(ls -A install)" ];
-	then
+	#install if requested or if previous install has not been successful
+	if [ "$ISSM_EXTERNALPACKAGES" == "yes" ] || [ ! -f SUCCESS ]; then
 		echo "======================================================";
 		echo "       Installing $PACKAGENAME                        ";
@@ -126,11 +128,11 @@
 			echo "    ERROR: installation of $PACKAGENAME failed        ";
 			echo "======================================================";
-			#erase install directory, so that next time, we still try and compile this!
-			rm -rf install
 			echo "<testcase classname=\"externalpackages\" name=\"$PACKAGENAME\">" >> $EXTERNAL_TEST_FILE
 			echo '<failure message="failure">External packages did not install right. Check it.</failure>' >> $EXTERNAL_TEST_FILE
 			echo '</testcase>' >> $EXTERNAL_TEST_FILE
+			exit 1
 		else
 			echo "<testcase classname=\"externalpackages\" name=\"$PACKAGENAME\"/>" >> $EXTERNAL_TEST_FILE
+			touch SUCCESS
 		fi
 		source $ISSM_DIR/etc/environment.sh
Index: /issm/trunk/src/c/Makefile.am
===================================================================
--- /issm/trunk/src/c/Makefile.am	(revision 20547)
+++ /issm/trunk/src/c/Makefile.am	(revision 20548)
@@ -534,5 +534,4 @@
 			./shared/TriMesh/SplitMeshForRifts.cpp\
 			./shared/TriMesh/TriMeshUtils.cpp\
-			./modules/TriaSearchx/TriaSearchx.cpp\
 			./modules/TriMeshx/TriMeshx.cpp\
 			./modules/TriMeshProcessRiftsx/TriMeshProcessRiftsx.cpp\
@@ -594,4 +593,7 @@
 if !STANDALONE_LIBRARIES
 libISSMCore_la_LIBADD = $(PETSCLIB) $(TAOLIB) $(M1QN3LIB) $(PLAPACKLIB) $(MUMPSLIB) $(SUPERLULIB) $(SPOOLESLIB) $(SCALAPACKLIB) $(BLACSLIB) $(HYPRELIB) $(SPAILIB) $(PROMETHEUSLIB) $(PASTIXLIB) $(MLLIB) $(DAKOTALIB) $(METISLIB) $(CHACOLIB) $(SCOTCHLIB) $(BLASLAPACKLIB) $(MKLLIB) $(MPILIB) $(MATHLIB) $(GRAPHICSLIB) $(MULTITHREADINGLIB) $(OSLIBS) $(GSLLIB)   $(ADOLCLIB) $(AMPILIB) $(METEOIOLIB) $(SNOWPACKLIB)
+if FORTRAN
+libISSMCore_la_LIBADD += $(FLIBS) $(FORTRANLIB)
+endif
 endif
 endif
@@ -645,5 +647,4 @@
 libISSMOverload_la_CFLAGS  = -D_C_ -fPIC $(COPTFLAGS) $(CFLAGS)
 #}}}
-
 #Executable {{{
 if ANDROID
Index: /issm/trunk/src/c/analyses/LevelsetAnalysis.cpp
===================================================================
--- /issm/trunk/src/c/analyses/LevelsetAnalysis.cpp	(revision 20547)
+++ /issm/trunk/src/c/analyses/LevelsetAnalysis.cpp	(revision 20548)
@@ -77,8 +77,4 @@
 /*Finite element Analysis*/
 void           LevelsetAnalysis::Core(FemModel* femmodel){/*{{{*/
-
-	#if !defined(_DEVELOPMENT_)
-	_error_("Not implemented yet");
-	#endif
 
 	/*parameters: */
Index: /issm/trunk/src/c/classes/Elements/PentaRef.cpp
===================================================================
--- /issm/trunk/src/c/classes/Elements/PentaRef.cpp	(revision 20547)
+++ /issm/trunk/src/c/classes/Elements/PentaRef.cpp	(revision 20548)
@@ -443,5 +443,5 @@
 
 	/*Get nodal functions derivatives in reference triangle*/
-	IssmDouble* dbasis_ref=xNew<IssmDouble>(3*numnodes);
+	IssmDouble dbasis_ref[3*NUMNODESMAX];
 	GetNodalFunctionsDerivativesReference(dbasis_ref,gauss,finiteelement);
 
@@ -461,7 +461,4 @@
 		dbasis[numnodes*2+i]=Jinv[2][0]*dbasis_ref[0*numnodes+i]+Jinv[2][1]*dbasis_ref[1*numnodes+i]+Jinv[2][2]*dbasis_ref[2*numnodes+i];
 	}
-
-	/*Clean up*/
-	xDelete<IssmDouble>(dbasis_ref);
 }
 /*}}}*/
Index: /issm/trunk/src/c/classes/Elements/SegRef.cpp
===================================================================
--- /issm/trunk/src/c/classes/Elements/SegRef.cpp	(revision 20547)
+++ /issm/trunk/src/c/classes/Elements/SegRef.cpp	(revision 20548)
@@ -146,5 +146,5 @@
 
 	/*Get nodal functions derivatives in reference triangle*/
-	IssmDouble* dbasis_ref=xNew<IssmDouble>(numnodes);
+	IssmDouble dbasis_ref[1*NUMNODESMAX];
 	GetNodalFunctionsDerivativesReference(dbasis_ref,gauss,finiteelement); 
 
@@ -158,8 +158,4 @@
 		dbasis[i] = Jinv*dbasis_ref[i];
 	}
-
-	/*Clean up*/
-	xDelete<IssmDouble>(dbasis_ref);
-
 }
 /*}}}*/
Index: /issm/trunk/src/c/classes/Elements/TetraRef.cpp
===================================================================
--- /issm/trunk/src/c/classes/Elements/TetraRef.cpp	(revision 20547)
+++ /issm/trunk/src/c/classes/Elements/TetraRef.cpp	(revision 20548)
@@ -225,5 +225,5 @@
 
 	/*Get nodal functions derivatives in reference triangle*/
-	IssmDouble* dbasis_ref=xNew<IssmDouble>(3*numnodes);
+	IssmDouble dbasis_ref[3*NUMNODESMAX];
 	GetNodalFunctionsDerivativesReference(dbasis_ref,gauss,finiteelement); 
 
@@ -243,7 +243,4 @@
 		dbasis[numnodes*2+i]=Jinv[2][0]*dbasis_ref[0*numnodes+i]+Jinv[2][1]*dbasis_ref[1*numnodes+i]+Jinv[2][2]*dbasis_ref[2*numnodes+i];
 	}
-
-	/*Clean up*/
-	xDelete<IssmDouble>(dbasis_ref);
 }
 /*}}}*/
Index: /issm/trunk/src/c/classes/Elements/TriaRef.cpp
===================================================================
--- /issm/trunk/src/c/classes/Elements/TriaRef.cpp	(revision 20547)
+++ /issm/trunk/src/c/classes/Elements/TriaRef.cpp	(revision 20548)
@@ -197,5 +197,5 @@
 
 	/*Get nodal functions derivatives in reference triangle*/
-	IssmDouble* dbasis_ref=xNew<IssmDouble>(2*numnodes);
+	IssmDouble dbasis_ref[2*NUMNODESMAX];
 	GetNodalFunctionsDerivativesReference(dbasis_ref,gauss,finiteelement); 
 
@@ -211,7 +211,4 @@
 		dbasis[numnodes*1+i] = Jinv[1][0]*dbasis_ref[0*numnodes+i]+Jinv[1][1]*dbasis_ref[1*numnodes+i];
 	}
-
-	/*Clean up*/
-	xDelete<IssmDouble>(dbasis_ref);
 
 }
Index: /issm/trunk/src/c/modules/modules.h
===================================================================
--- /issm/trunk/src/c/modules/modules.h	(revision 20547)
+++ /issm/trunk/src/c/modules/modules.h	(revision 20548)
@@ -89,5 +89,4 @@
 #include "./SpcNodesx/SpcNodesx.h"
 #include "./SurfaceAreax/SurfaceAreax.h"
-#include "./TriaSearchx/TriaSearchx.h"
 #include "./TriMeshx/TriMeshx.h"
 #include "./TriMeshProcessRiftsx/TriMeshProcessRiftsx.h"
Index: /issm/trunk/src/m/boundaryconditions/SetMarineIceSheetBC.m
===================================================================
--- /issm/trunk/src/m/boundaryconditions/SetMarineIceSheetBC.m	(revision 20547)
+++ /issm/trunk/src/m/boundaryconditions/SetMarineIceSheetBC.m	(revision 20548)
@@ -40,5 +40,5 @@
 pos=find(md.mesh.vertexonboundary & ~vertexonicefront);
 if isempty(pos),
-	warning('SetMarineIceSheetBC warning: ice front all around the glacier, no dirichlet found. Dirichlet must be added manually')
+	disp('SetMarineIceSheetBC warning: ice front all around the glacier, no dirichlet applied')
 end
 md.stressbalance.spcvx=NaN*ones(md.mesh.numberofvertices,1);
Index: /issm/trunk/src/m/classes/calving.m
===================================================================
--- /issm/trunk/src/m/classes/calving.m	(revision 20547)
+++ /issm/trunk/src/m/classes/calving.m	(revision 20548)
@@ -39,6 +39,6 @@
 			if (solution~=TransientSolutionEnum() | md.transient.ismovingfront==0), return; end
 
-			md = checkfield(md,'fieldname','calving.calvingrate(1:md.mesh.numberofvertices,:)','>=',0,'timeseries',1,'NaN',1,'Inf',1);
-			md = checkfield(md,'fieldname','calving.meltingrate(1:md.mesh.numberofvertices,:)','>=',0,'timeseries',1,'NaN',1,'Inf',1);
+			md = checkfield(md,'fieldname','calving.calvingrate','>=',0,'timeseries',1,'NaN',1,'Inf',1);
+			md = checkfield(md,'fieldname','calving.meltingrate','>=',0,'timeseries',1,'NaN',1,'Inf',1);
 		end % }}}
 		function disp(self) % {{{
Index: /issm/trunk/src/m/classes/clusters/generic_static.m
===================================================================
--- /issm/trunk/src/m/classes/clusters/generic_static.m	(revision 20547)
+++ /issm/trunk/src/m/classes/clusters/generic_static.m	(revision 20548)
@@ -51,8 +51,26 @@
 		function BuildQueueScript(cluster,dirname,modelname,solution,io_gather,isvalgrind,isgprof,isdakota) % {{{
 
+			%Check that issm.exe exists in the right path
+			if ~exist([cluster.codepath '/issm.exe'],'file'),
+				error(['File ' cluster.codepath '/issm.exe does not exist']);
+			end
+
+			%Now process codepath and replace empty spaces with \ to avoid errors in queuing script
+			codepath2=strrep(cluster.codepath,' ','\ ');
+
+			%write queuing script
+			%what is the executable being called?
+			executable='issm.exe';
+			if isdakota,
+				version=IssmConfig('_DAKOTA_VERSION_'); version=str2num(version(1:3));
+				if (version>=6),
+					executable='issm_dakota.exe';
+				end
+			end
+
 			%write queuing script 
 			fid=fopen([modelname '.queue'],'w');
 			fprintf(fid,'#!%s\n',cluster.shell);
-			fprintf(fid,[cluster.codepath '/mpiexec -np %i %s/issm.exe %s %s %s \n'],cluster.np,cluster.codepath,EnumToString(solution),'./',modelname);
+			fprintf(fid,['%s/mpiexec -np %i %s/%s %s %s %s \n'],codepath2,cluster.np,codepath2,executable,EnumToString(solution),'./',modelname);
 			fclose(fid);
 
Index: /issm/trunk/src/m/classes/clusters/lonestar.m
===================================================================
--- /issm/trunk/src/m/classes/clusters/lonestar.m	(revision 20547)
+++ /issm/trunk/src/m/classes/clusters/lonestar.m	(revision 20548)
@@ -123,8 +123,14 @@
 				 fprintf(fid,['module load ' cluster.modules{i} '\n']);
 			 end
+
+			 %fprintf(fid,'export KMP_AFFINITY="granularity=fine,compact,verbose" \n\n');
+
 			 if length(find(cluster.email=='@'))>0
-				 fprintf(fid,'#SBATCH --mail-user=%s \n',cluster.email);
-				 fprintf(fid,'#SBATCH --mail-type=end \n\n');
+				 %fprintf(fid,'#SBATCH --mail-user=%s \n',cluster.email);
+				 %fprintf(fid,'#SBATCH --mail-type=end \n\n');
+
+				 fprintf(fid,'ssh login1 "mail -s ''SLURM Jobid=${SLURM_JOBID} Name=${SLURM_JOB_NAME} Began on Lonestar 5.'' %s <<< ''Job Started'' " \n\n',cluster.email);
 			 end
+
 			 fprintf(fid,'export PATH="$PATH:."\n\n');
 			 fprintf(fid,'export ISSM_DIR="%s/../"\n',cluster.codepath); %FIXME
@@ -134,4 +140,9 @@
 			 if ~io_gather, %concatenate the output files:
 				 fprintf(fid,'cat %s.outbin.* > %s.outbin',modelname,modelname);
+			 end
+
+			 if length(find(cluster.email=='@'))>0
+				 fprintf(fid,'\n');
+				 fprintf(fid,'ssh login1 "mail -s ''SLURM Jobid=${SLURM_JOBID} Name=${SLURM_JOB_NAME} Ended on Lonestar 5.'' %s <<< ''Job Ended'' " \n\n',cluster.email);
 			 end
 			 fclose(fid);
Index: /issm/trunk/src/m/classes/clusters/pfe.m
===================================================================
--- /issm/trunk/src/m/classes/clusters/pfe.m	(revision 20547)
+++ /issm/trunk/src/m/classes/clusters/pfe.m	(revision 20548)
@@ -92,5 +92,14 @@
 					 end
 				 end
-			 
+			 elseif strcmpi(cluster.processor,'bro'),
+				 if cluster.hyperthreading,
+					 if ((cluster.cpuspernode>56 ) | (cluster.cpuspernode<1)),
+						 md = checkmessage(md,'cpuspernode should be between 1 and 56 for ''bro'' processors in hyperthreading mode');
+					 end
+				 else
+					 if ((cluster.cpuspernode>28 ) | (cluster.cpuspernode<1)),
+						 md = checkmessage(md,'cpuspernode should be between 1 and 28 for ''bro'' processors');
+					 end
+				 end
 			 elseif strcmpi(cluster.processor,'has'),
 				 if cluster.hyperthreading,
Index: /issm/trunk/src/m/classes/independent.py
===================================================================
--- /issm/trunk/src/m/classes/independent.py	(revision 20547)
+++ /issm/trunk/src/m/classes/independent.py	(revision 20548)
@@ -2,4 +2,5 @@
 from pairoptions import pairoptions
 from fielddisplay import fielddisplay
+from checkfield import checkfield
 from MatlabFuncs import *
 from EnumDefinitions import *
@@ -52,5 +53,5 @@
 				raise TypeError("independent checkconsistency error: nods should be set to the size of the independent variable")
 
-		if self.fov_forward_indices:
+		if len(self.fov_forward_indices) > 0:
 			if not strcmpi(driver,'fov_forward'):
 				raise TypeError("cannot declare an independent with fov_forward_indices when the driver is not fov_forward!")
Index: /issm/trunk/src/m/classes/miscellaneous.m
===================================================================
--- /issm/trunk/src/m/classes/miscellaneous.m	(revision 20547)
+++ /issm/trunk/src/m/classes/miscellaneous.m	(revision 20548)
@@ -39,9 +39,13 @@
 		end % }}}
 		function savemodeljs(self,fid,modelname) % {{{
-		
+
 			writejsstring(fid,[modelname '.miscellaneous.notes'],self.notes);
 			writejsstring(fid,[modelname '.miscellaneous.name'],self.name);
 			if strcmpi(class(self.dummy),'double'),
-				writejs1Darray(fid,[modelname '.miscellaneous.dummy'],self.dummy);
+				if size(self.dummy,2)==1,
+					writejs1Darray(fid,[modelname '.miscellaneous.dummy'],self.dummy);
+				else
+					writejs2Darray(fid,[modelname '.miscellaneous.dummy'],self.dummy);
+				end
 			end
 
Index: /issm/trunk/src/m/classes/model.m
===================================================================
--- /issm/trunk/src/m/classes/model.m	(revision 20547)
+++ /issm/trunk/src/m/classes/model.m	(revision 20548)
@@ -208,5 +208,4 @@
 				md.smb.smbref=project2d(md,md.smb.smbref,md.mesh.numberoflayers);
 			end;
-			if ~isnan(md.balancethickness.thickening_rate), md.balancethickness.thickening_rate=project2d(md,md.balancethickness.thickening_rate,md.mesh.numberoflayers); end;
 
 			%results
Index: /issm/trunk/src/m/classes/model.py
===================================================================
--- /issm/trunk/src/m/classes/model.py	(revision 20547)
+++ /issm/trunk/src/m/classes/model.py	(revision 20548)
@@ -687,6 +687,4 @@
 			md.smb.mass_balance=project2d(md,md.smb.mass_balance,md.mesh.numberoflayers) 
 		
-		if not numpy.isnan(md.balancethickness.thickening_rate).all(): md.balancethickness.thickening_rate=project2d(md,md.balancethickness.thickening_rate,md.mesh.numberoflayers) 
-
 		#results
 		if not numpy.isnan(md.initialization.vx).all(): md.initialization.vx=DepthAverage(md,md.initialization.vx)
Index: /issm/trunk/src/m/coordsystems/gdaltransform.m
===================================================================
--- /issm/trunk/src/m/coordsystems/gdaltransform.m	(revision 20547)
+++ /issm/trunk/src/m/coordsystems/gdaltransform.m	(revision 20548)
@@ -6,10 +6,19 @@
 %
 %   Example: 
-%      [x,y] = gdaltransform(md.mesh.lat,md.mesh.long,'EPSG:3184','EPSG:3411'); 
+%      [x,y] = gdaltransform(md.mesh.long,md.mesh.lat,'EPSG:4326','EPSG:3031')
 %
 %   For reference: 
-%       EPSG: 4326 (lat,long)
-%       EPSG: 3411  (greenland, +proj=stere +lat_0=90 +lat_ts=70 +lon_0=-45 +k=1 +x_0=0 +y_0=0 +a=6378273 +b=6356889.449 +units=m +no_defs)
-%       EPSG: 3031 (antarctica, +proj=stere +lat_0=-90 +lat_ts=-71 +lon_0=0 +k=1 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs)
+%      EPSG: 4326 (lat,long)
+%      EPSG: 3411 (Greenland,  UPS 45W, 70N)
+%      EPSG: 3031 (Antarctica, UPS 0E,  71S)
+%
+%      ll2xy default projection Antarctica:
+%        +proj=stere +lat_0=-90 +lat_ts=-71 +lon_0=0 +k=1 +x_0=0 +y_0=0 +a=6378273 +b=6356889.448564109 +units=m +no_defs
+%      ll2xy default projection Greenland:
+%        +proj=stere +lat_0=90 +lat_ts=70 +lon_0=-45 +k=1 +x_0=0 +y_0=0 +a=6378273 +b=6356889.448564109 +units=m +no_defs
+%      Bamber's Greeland projection
+%        +proj=stere +lat_0=90 +lat_ts=71 +lon_0=-39 +k=1 +x_0=0 +y_0=0 +a=6378273 +b=6356889.448564109 +units=m +no_defs
+%
+%      To get proj.4 string from EPSG, use gdalsrsinfo. Example:    gdalsrsinfo "EPSG:4326" | grep "PROJ.4"
 
 	%give ourselves a unique temporary directory: 
@@ -17,11 +26,12 @@
 
 	fid=fopen([temproot '/.rand1234.txt'],'w');
-	for i=1:length(x),
-		fprintf(fid,'%g %g\n',x(i),y(i));
-	end
+	fprintf(fid,'%8g %8g\n',[x(:) y(:)]');
 	fclose(fid);
 
 	[s,r]=system(['gdaltransform -s_srs ',proj_in,' -t_srs ',proj_out,'  < ' temproot '/.rand1234.txt > ' temproot '/.rand1235.txt']);
-	A=textread([temproot '/.rand1235.txt']);
-	xout=A(:,1);
-	yout=A(:,2);
+	if s~=0 | ~isempty(deblank(r)),
+		error(r);
+	end
+	A=load([temproot '/.rand1235.txt']);
+	xout=A(:,1); xout=reshape(xout,size(x));
+	yout=A(:,2); yout=reshape(yout,size(y));
Index: sm/trunk/src/m/exp/downstreamflowlines.m
===================================================================
--- /issm/trunk/src/m/exp/downstreamflowlines.m	(revision 20547)
+++ 	(revision )
@@ -1,110 +1,0 @@
-function flowpath=downstreamflowlines(index,x,y,u,v,x0,y0,varargin)
-%DOWNSTREAMFLOWLINES - compute flowlines from a given set of seed points
-%
-%   Usage:
-%      flowpath=downstreamflowlines(index,x,y,u,v,x0,y0)
-%
-%   the velocity field is given by the couple (u,v) and the coordinates
-%   of the seed points are (x0,y0). One can use one or several seed 
-%   points
-%
-%   Example:
-%      flowpath=downstreamflowlines(md.mesh.elements,md.mesh.x,md.mesh.y,md.vx,md.initialization.vy,x0,y0)
-
-%check input size
-if nargin>9 | nargin<7,
-	help flowlines
-	error('flowlines error message: bad usage');
-end
-
-%check input
-if (length(x)~=length(y) | length(x)~=length(u) | length(x)~=length(v)),
-	error('flowlines error message: x,y,u and v must have the same length');
-end
-if length(x)<3,
-	error('flowlines error message: at least one element is required');
-end
-if length(x0)~=length(y0),
-	error('flowlines error message: x0 and y0 do not have the same length');
-end
-
-%get maxiter and precision
-if nargin==9
-	maxiter=varargin{1};%maximum number of iterations
-	precision=varargin{2}; %division of each segment (higer precision increases number of segments)
-else
-	maxiter=200; %maximum number of iterations
-	precision=1; %division of each segment (higer precision increases number of segments)
-end
-
-%check seed points
-tria=TriaSearch(index,x,y,x0,y0);
-pos=find(isnan(tria));
-x0(pos)=[];
-y0(pos)=[];
-
-%initialize other variables
-N=length(x0);
-X=x0; Y=y0;
-flowpath=struct('x',cell(N,1),'y',cell(N,1),'name','','density',1);
-for i=1:N,
-	flowpath(i).x=x0(i);
-	flowpath(i).y=y0(i);
-end
-done=zeros(N,1);
-
-%get avegared length of each element
-length_tria=1/3*(sqrt( (x(index(:,1))-x(index(:,2))).^2+(y(index(:,1))-y(index(:,2))).^2 )+...
-	sqrt((x(index(:,1))-x(index(:,3))).^2+(y(index(:,1))-y(index(:,3))).^2 )+...
-	sqrt((x(index(:,2))-x(index(:,3))).^2+(y(index(:,2))-y(index(:,3))).^2 ));
-
-%take velocity for each element
-u=u(index)*[1;1;1]/3;
-v=v(index)*[1;1;1]/3;
-
-%initialization:
-counter=1;
-
-while any(~done) 
-
-	%find current triangle
-	queue=find(~done);
-	tria=TriaSearch(index,x,y,X(queue),Y(queue));
-
-	%check that the point is actually inside a triangle of the mesh
-	listnan=find(isnan(tria));
-	for i=1:length(listnan)
-		%remove the last point
-		flowpath(queue(listnan(i))).x(end)=[];
-		flowpath(queue(listnan(i))).y(end)=[];
-		done(queue(listnan(i)))=1;
-	end
-	tria(listnan)=[]; 
-	queue(listnan)=[];
-
-	if isempty(tria),
-		break;
-	end
-
-	%velocity of the current triangle and norm it
-	ut=u(tria); vt=v(tria); normv=sqrt(ut.^2+vt.^2);
-	ut=ut./normv;vt=vt./normv;
-
-	%check counter
-	if counter>maxiter
-		disp(['Maximum number of iterations (' num2str(maxiter) ') reached while going forward'])
-		break
-	end
-	counter=counter+1;
-
-	%remove stagnant point
-	done(queue(find(ut==0 & vt==0)))=1;
-
-	%build next point
-	for i=1:length(queue)
-		X(queue(i))=flowpath(queue(i)).x(end)+ut(i)*length_tria(tria(i))/precision;
-		Y(queue(i))=flowpath(queue(i)).y(end)+vt(i)*length_tria(tria(i))/precision;
-		flowpath(queue(i)).x=[flowpath(queue(i)).x;flowpath(queue(i)).x(end)+ut(i)*length_tria(tria(i))/precision];
-		flowpath(queue(i)).y=[flowpath(queue(i)).y;flowpath(queue(i)).y(end)+vt(i)*length_tria(tria(i))/precision];
-	end
-end
Index: /issm/trunk/src/m/exp/flowlines.m
===================================================================
--- /issm/trunk/src/m/exp/flowlines.m	(revision 20547)
+++ /issm/trunk/src/m/exp/flowlines.m	(revision 20548)
@@ -3,5 +3,5 @@
 %
 %   Usage:
-%      flowpath=flowlines(index,x,y,u,v,x0,y0)
+%      flowpath=flowlines(index,x,y,u,v,x0,y0,varargin)
 %
 %   the velocity field is given by the couple (u,v) and the coordinates
@@ -10,11 +10,11 @@
 %
 %   Example:
-%      flowpath=flowlines(md.mesh.elements,md.mesh.x,md.mesh.y,md.vx,md.initialization.vy,x0,y0)
-
-%check input size
-if nargin>8 | nargin<7,
-	help flowlines
-	error('flowlines error message: bad usage');
-end
+%      flowpath=flowlines(md.mesh.elements,md.mesh.x,md.mesh.y,md.initialization.vx,md.initialization.vy,x0,y0)
+%
+%   Options:
+%      - 'maxiter':   how many steps upstream and downstream of the seed points (default: 200)
+%      - 'precision': division of each segment (higer precision increases number of segments, default: 1)
+%      - 'downstream':flow line upstream of the seed points (default: 1)
+%      - 'upstream':  flow line upstream of the seed points (default: 1)
 
 %check input
@@ -29,15 +29,14 @@
 end
 
-%get maxiter and precision
-if nargin==8
-	maxiter=varargin{1};
-else
-	maxiter=200; %maximum number of iterations
-end
-precision=1; %division of each segment (higer precision increases number of segments)
+%process options
+options    = pairoptions(varargin{:});
+maxiter    = getfieldvalue(options,'maxiter',200);
+precision  = getfieldvalue(options,'precision',1);
+downstream = getfieldvalue(options,'downstream',1);
+upstream   = getfieldvalue(options,'upstream',1);
 
-%check seed points
-tria=TriaSearch(index,x,y,x0,y0);
-%tria=tsearch(x,y,index,x0,y0);
+%Create triangulation once for all and check seed points
+trep = triangulation(index,x,y);
+tria = pointLocation(trep,[x0 y0]);
 pos=find(isnan(tria));
 x0(pos)=[];
@@ -63,104 +62,106 @@
 v=v(index)*[1;1;1]/3;
 
-%initialization:
-counter=1;
+if downstream,
+	%initialization:
+	counter=1;
 
-while any(~done) 
+	while any(~done) 
 
-	%find current triangle
-	queue=find(~done);
-	tria=TriaSearch(index,x,y,X(queue),Y(queue));
-	%tria=tsearch(x,y,index,X(queue),Y(queue));
+		%find current triangle
+		queue=find(~done);
+		tria = pointLocation(trep,[X(queue),Y(queue)]);
 
-	%check that the point is actually inside a triangle of the mesh
-	listnan=find(isnan(tria));
-	for i=1:length(listnan)
-		%remove the last point
-		flowpath(queue(listnan(i))).x(end)=[];
-		flowpath(queue(listnan(i))).y(end)=[];
-		done(queue(listnan(i)))=1;
-	end
-	tria(listnan)=[]; 
-	queue(listnan)=[];
+		%check that the point is actually inside a triangle of the mesh
+		listnan=find(isnan(tria));
+		for i=1:length(listnan)
+			%remove the last point
+			flowpath(queue(listnan(i))).x(end)=[];
+			flowpath(queue(listnan(i))).y(end)=[];
+			done(queue(listnan(i)))=1;
+		end
+		tria(listnan)=[]; 
+		queue(listnan)=[];
 
-	if isempty(tria),
-		break;
-	end
+		if isempty(tria),
+			break;
+		end
 
-	%velocity of the current triangle and norm it
-	ut=u(tria); vt=v(tria); normv=sqrt(ut.^2+vt.^2);
-	ut=ut./normv;vt=vt./normv;
+		%velocity of the current triangle and norm it
+		ut=u(tria); vt=v(tria); normv=max(eps,sqrt(ut.^2+vt.^2));
+		ut=ut./normv;vt=vt./normv;
 
-	%check counter
-	if counter>maxiter
-		disp(['Maximum number of iterations (' num2str(maxiter) ') reached while going forward'])
-		break
-	end
-	counter=counter+1;
+		%check counter
+		if counter>maxiter
+			disp(['Maximum number of iterations (' num2str(maxiter) ') reached while going forward'])
+			break
+		end
+		counter=counter+1;
 
-	%remove stagnant point
-	done(queue(find(ut==0 & vt==0)))=1;
+		%remove stagnant point
+		done(queue(find(ut==0 & vt==0)))=1;
 
-	%build next point
-	for i=1:length(queue)
-		X(queue(i))=flowpath(queue(i)).x(end)+ut(i)*length_tria(tria(i))/precision;
-		Y(queue(i))=flowpath(queue(i)).y(end)+vt(i)*length_tria(tria(i))/precision;
-		flowpath(queue(i)).x=[flowpath(queue(i)).x;flowpath(queue(i)).x(end)+ut(i)*length_tria(tria(i))/precision];
-		flowpath(queue(i)).y=[flowpath(queue(i)).y;flowpath(queue(i)).y(end)+vt(i)*length_tria(tria(i))/precision];
+		%build next point
+		for i=1:length(queue)
+			X(queue(i))=flowpath(queue(i)).x(end)+ut(i)*length_tria(tria(i))/precision;
+			Y(queue(i))=flowpath(queue(i)).y(end)+vt(i)*length_tria(tria(i))/precision;
+			flowpath(queue(i)).x=[flowpath(queue(i)).x;flowpath(queue(i)).x(end)+ut(i)*length_tria(tria(i))/precision];
+			flowpath(queue(i)).y=[flowpath(queue(i)).y;flowpath(queue(i)).y(end)+vt(i)*length_tria(tria(i))/precision];
+		end
 	end
 end
 
 %same process but reverse (vel=-vel) to have a vcomplete flow line
-queue=[];
-counter=1;
-X=x0; Y=y0;
-done=zeros(N,1);
+if upstream,
+	queue=[];
+	counter=1;
+	X=x0; Y=y0;
+	done=zeros(N,1);
 
-while any(~done) 
+	while any(~done) 
 
-	%find current triangle
-	queue=find(~done);
-	tria=TriaSearch(index,x,y,X(queue),Y(queue));
-	%tria=tsearch(x,y,index,X(queue),Y(queue));
+		%find current triangle
+		queue=find(~done);
+		tria = pointLocation(trep,[X(queue),Y(queue)]);
 
-	%check that the point is actually inside a triangle of the mesh
-	listnan=find(isnan(tria));
-	for i=1:length(listnan)
-		%remove the last point
-		flowpath(queue(listnan(i))).x(1)=[];
-		flowpath(queue(listnan(i))).y(1)=[];
-		done(queue(listnan(i)))=1;
-	end
-	tria(listnan)=[]; 
-	queue(listnan)=[];
+		%check that the point is actually inside a triangle of the mesh
+		listnan=find(isnan(tria));
+		for i=1:length(listnan)
+			%remove the last point
+			flowpath(queue(listnan(i))).x(1)=[];
+			flowpath(queue(listnan(i))).y(1)=[];
+			done(queue(listnan(i)))=1;
+		end
+		tria(listnan)=[]; 
+		queue(listnan)=[];
 
-	if isempty(tria),
-		break;
-	end
+		if isempty(tria),
+			break;
+		end
 
-	%velocity of the current triangle and norm it
-	ut=-u(tria); vt=-v(tria); normv=sqrt(ut.^2+vt.^2);
-	ut=ut./normv;vt=vt./normv;
+		%velocity of the current triangle and norm it
+		ut=-u(tria); vt=-v(tria); normv=max(eps,sqrt(ut.^2+vt.^2));
+		ut=ut./normv;vt=vt./normv;
 
-	%check counter
-	if counter>maxiter
-		disp(['Maximum number of iterations (' num2str(maxiter) ') reached while going backward'])
-		break
-	end
-	counter=counter+1;
+		%check counter
+		if counter>maxiter
+			disp(['Maximum number of iterations (' num2str(maxiter) ') reached while going backward'])
+			break
+		end
+		counter=counter+1;
 
-	%remove stagnant point
-	done(queue(find(ut==0 & vt==0)))=1;
+		%remove stagnant point
+		done(queue(find(ut==0 & vt==0)))=1;
 
-	%build next point
-	for i=1:length(queue)
-		X(queue(i))=flowpath(queue(i)).x(1)+ut(i)*length_tria(tria(i))/precision;
-		Y(queue(i))=flowpath(queue(i)).y(1)+vt(i)*length_tria(tria(i))/precision;
-		flowpath(queue(i)).x=[flowpath(queue(i)).x(1)+ut(i)*length_tria(tria(i))/precision; flowpath(queue(i)).x];
-		flowpath(queue(i)).y=[flowpath(queue(i)).y(1)+vt(i)*length_tria(tria(i))/precision; flowpath(queue(i)).y];
+		%build next point
+		for i=1:length(queue)
+			X(queue(i))=flowpath(queue(i)).x(1)+ut(i)*length_tria(tria(i))/precision;
+			Y(queue(i))=flowpath(queue(i)).y(1)+vt(i)*length_tria(tria(i))/precision;
+			flowpath(queue(i)).x=[flowpath(queue(i)).x(1)+ut(i)*length_tria(tria(i))/precision; flowpath(queue(i)).x];
+			flowpath(queue(i)).y=[flowpath(queue(i)).y(1)+vt(i)*length_tria(tria(i))/precision; flowpath(queue(i)).y];
+		end
 	end
 end
 
-%EXP compatibility
+%EXP compatibility (add name)
 for i=1:length(queue)
 	flowpath(queue(i)).name=['flowline' num2str(i)];
Index: /issm/trunk/src/m/mesh/patchglobe.m
===================================================================
--- /issm/trunk/src/m/mesh/patchglobe.m	(revision 20547)
+++ /issm/trunk/src/m/mesh/patchglobe.m	(revision 20548)
@@ -6,4 +6,12 @@
 	%recover basic options:
 	bandwidth=getfieldvalue(options,'bandwidth',100000);
+
+	%some checks on the mesh: 
+	if (isempty(mh.x) | isempty(mh.y) | isempty(mh.z) | isempty(mh.lat) | isempty(mh.long) | isempty(mh.r) ) 
+		error('patchglobe error message: 3D planet mesh has one of the following empty: ''x'',''y'',''z'',''lat'',''long'' or ''r''');
+	end
+	if (isempty(mh2d.x) | isempty(mh2d.y) | isempty(mh2d.lat) | isempty(mh2d.long)) 
+		error('patchglobe error message: 3D planet mesh has one of the following empty: ''x'',''y'',''lat'' or ''long''');
+	end
 
 	%give ourselves a unique temporary directory: 
Index: /issm/trunk/src/m/miscellaneous/transientrestart.m
===================================================================
--- /issm/trunk/src/m/miscellaneous/transientrestart.m	(revision 20547)
+++ /issm/trunk/src/m/miscellaneous/transientrestart.m	(revision 20548)
@@ -18,5 +18,5 @@
 
 %Change time
-md.timestepping.start_time = results.time/md.constants.yts;
+md.timestepping.start_time = results.time;
 
 %Change initialization fields
Index: /issm/trunk/src/m/plot/applyoptions.js
===================================================================
--- /issm/trunk/src/m/plot/applyoptions.js	(revision 20547)
+++ /issm/trunk/src/m/plot/applyoptions.js	(revision 20548)
@@ -11,5 +11,5 @@
 		if (options.getfieldvalue('colorbar')==1) {
 			//Handle movie data {{{
-			if (typeof data == 'string') {
+				if (typeof data == 'string') {
 				//throw Error('plot error message: data of type string');
 				return;
@@ -25,7 +25,8 @@
 					})
 				});
-				data = data[node['movieFrame']].slice(0,-1);
+				data = data[0].slice(0,-1);
 			} //}}}
 			//Variable options initialization {{{
+			
 			var caxis = options.getfieldvalue('caxis',[ArrayMin(data),ArrayMax(data)]);
 			var canvassize = options.getfieldvalue('canvassize',480);
@@ -47,12 +48,9 @@
 			var clabelitem;
 			var precision=options.getfieldvalue('colorbarprecision',3);
-			if (options.exist('log')) {
+			
+			if (options.getfieldvalue('log',10)!='off') {
 				for (var i = cdivisions; i >= 0; i--) {
-					if (caxisdelta*i/cdivisions==min) {
-						labels[i] = (caxis[0]).toPrecision(precision);
-					}
-					else {
-						labels[i] = (Math.exp(Math.log(caxisdelta)*i/cdivisions)+caxis[0]).toPrecision(precision);
-					}	
+					var scale = Math.log(caxis[1])-Math.log(caxis[0]);
+					labels[i] = (Math.exp(Math.log(caxis[0])+scale*(cdivisions-i)/cdivisions)).toPrecision(precision);
 				}
 			} else {
@@ -228,8 +226,16 @@
 	var cmap = options.getfieldvalue('cmap','jet');
 	var colorbar = colorbars[cmap];
-	for (var i = 0; i < colorbar.length; i++) {
-		color = colorbar[colorbar.length-i-1];
-		color = [Math.round(color[0]*255),Math.round(color[1]*255),Math.round(color[2]*255)];	
-		tgradient.addColorStop(i/colorbar.length,'rgba('+color.toString()+',1.0)');
+	if (options.getfieldvalue('log',10)!='off') {
+		for (var i = 0; i < colorbar.length; i++) {
+			color = colorbar[colorbar.length-i-1];
+			color = [Math.round(color[0]*255),Math.round(color[1]*255),Math.round(color[2]*255)];	
+			tgradient.addColorStop(1.0-Math.exp(Math.log((colorbar.length-i)/colorbar.length)/Math.log(options.getfieldvalue('log',10))*i/colorbar.length),'rgba('+color.toString()+',1.0)');
+		}
+	} else {
+		for (var i = 0; i < colorbar.length; i++) {
+			color = colorbar[colorbar.length-i-1];
+			color = [Math.round(color[0]*255),Math.round(color[1]*255),Math.round(color[2]*255)];	
+			tgradient.addColorStop(i/colorbar.length,'rgba('+color.toString()+',1.0)');
+		}
 	}
 	
Index: /issm/trunk/src/m/plot/manualcb.m
===================================================================
--- /issm/trunk/src/m/plot/manualcb.m	(revision 20547)
+++ /issm/trunk/src/m/plot/manualcb.m	(revision 20548)
@@ -62,6 +62,13 @@
 	ytick  = (ztick-zmin)/(zmax-zmin);
 else
-	ztick = getfieldvalue(options,'tick',round(logspace(log(zmin)/log(10),log(zmax)/log(10),8)));
+	%old method
+	ztick = getfieldvalue(options,'tick',round( logspace(log10(zmin),log10(zmax),8) ));
 	ytick = linspace(0,1,numel(ztick));
+
+	%New method
+	test=logspace(-10,10,21);
+	pos=find(test>=zmin & test<=zmax);
+	ztick= test(pos);
+	ytick= (log(ztick) - log(zmin))/(log(zmax) - log(zmin));
 end
 
@@ -69,16 +76,23 @@
 hold on
 numcolors=size(cmap,1);
-if strcmpi(getfieldvalue(options,'orientation','vertical'),'vertical'),
-	image_rgb = ind2rgb(repmat((1:numcolors)',1,2),cmap);
-else
-	image_rgb = ind2rgb(repmat((1:numcolors)',1,2)',cmap);
-end
 if 1,
 	%disappears somtimes
-	imagesc([0 1],[0 1],repmat(image_rgb,[1 10 1]));
+	if strcmpi(getfieldvalue(options,'orientation','vertical'),'vertical'),
+		image_rgb = ind2rgb(repmat((1:numcolors)',1,10),cmap);
+	else
+		image_rgb = ind2rgb(repmat((1:numcolors),10,1),cmap);
+	end
+
+	imagesc([0 1],[0 1],image_rgb);
 else
 	%Creates triangles when exported as pdf
-	for i=1:numcolors,
-		patch([0,0,1,1],[(i-1)/numcolors,i/numcolors,i/numcolors,(i-1)/numcolors],'none','FaceColor',cmap(i,:),'Clipping','off','EdgeColor','none')
+	if strcmpi(getfieldvalue(options,'orientation','vertical'),'vertical'),
+		for i=1:numcolors,
+			patch([0,0,1,1],[(i-1)/numcolors,i/numcolors,i/numcolors,(i-1)/numcolors],0,'FaceColor',cmap(i,:),'Clipping','off','EdgeColor','none')
+		end
+	else
+		for i=1:numcolors,
+			patch([(i-1)/numcolors,i/numcolors,i/numcolors,(i-1)/numcolors],[0,0,1,1],0,'FaceColor',cmap(i,:),'Clipping','off','EdgeColor','none')
+		end
 	end
 end
Index: /issm/trunk/src/m/plot/plot_overlay.js
===================================================================
--- /issm/trunk/src/m/plot/plot_overlay.js	(revision 20547)
+++ /issm/trunk/src/m/plot/plot_overlay.js	(revision 20548)
@@ -127,6 +127,12 @@
 		vertices[vertices.length] = vertex[2];
 		
-		texcoords[texcoords.length] = (x[i] - modelxlim[0]) / xrange;
-		texcoords[texcoords.length] = (y[i] - modelylim[0]) / yrange;
+		if (md.mesh.classname() == 'mesh3dsurface') {
+			texcoords[texcoords.length] = degrees(Math.atan2(y[i], x[i])) / 360 + 0.5;
+			texcoords[texcoords.length] = degrees(Math.asin(z[i] / magnitude)) / 180 + 0.5;
+		}
+		else {
+			texcoords[texcoords.length] = (x[i] - modelxlim[0]) / xrange;
+			texcoords[texcoords.length] = (y[i] - modelylim[0]) / yrange;
+		}
 	}
 
Index: /issm/trunk/src/m/plot/plot_unit.js
===================================================================
--- /issm/trunk/src/m/plot/plot_unit.js	(revision 20547)
+++ /issm/trunk/src/m/plot/plot_unit.js	(revision 20548)
@@ -96,4 +96,5 @@
 			else{ //triangular elements	
 				caxis = options.getfieldvalue('caxis',[ArrayMin(data),ArrayMax(data)]);
+				if (options.getfieldvalue('log','off')!='off') caxis = [Math.log10(caxis[0])/Math.log10(options.getfieldvalue('log',10)),Math.log10(caxis[1])/Math.log10(options.getfieldvalue('log',10))];
 				datamin = caxis[0];
 				datamax = caxis[1];
@@ -196,13 +197,14 @@
 					})
 				});
-				
-				for(var i = 0; i < data.length; i++){
-					//Prevent evaluation of datasubarray min/max if caxis exists
-					if (options.exist('caxis')) {
-						caxis = options.getfieldvalue('caxis');
-					}
-					else {
-						caxis = [ArrayMin(data[i]),ArrayMax(data[i].slice(0,-1))];
-					}
+				//Prevent evaluation of datasubarray min/max if caxis exists
+				if (options.exist('caxis')) {
+					caxis = options.getfieldvalue('caxis');
+				}
+				else {
+					caxis = [ArrayMin(data[0]),ArrayMax(data[0].slice(0,-1))];
+				}
+				if (options.getfieldvalue('log','off')!='off') caxis = [Math.log10(caxis[0])/Math.log10(options.getfieldvalue('log',10)),Math.log10(caxis[1])/Math.log10(options.getfieldvalue('log',10))];
+				
+				for(var i = 0; i < data.length; i++){					
 					datamin = caxis[0];
 					datamax = caxis[1];
Index: /issm/trunk/src/m/plot/processdata.js
===================================================================
--- /issm/trunk/src/m/plot/processdata.js	(revision 20547)
+++ /issm/trunk/src/m/plot/processdata.js	(revision 20548)
@@ -143,5 +143,5 @@
 
 		//log?
-		if (options.exist('log')){
+		if (options.getfieldvalue('log','off')!='off'){
 			var bounds=options.getfieldvalue('caxis',[ArrayMin(data),ArrayMax(data)]);
 			for(var i=0;i<md.mesh.numberofelements;i++)if(data[i]<bounds[0])data[i]=bounds[0];
@@ -151,5 +151,5 @@
 			for(var i=0;i<md.mesh.numberofelements;i++){
 				if(!IsNaN(data[i])){
-					data[i]=Math.log10(data[i])/Math.log10(options.getfieldvalue('log'));
+					data[i]=Math.log10(data[i])/Math.log10(options.getfieldvalue('log',10));
 				}
 			}
@@ -184,5 +184,5 @@
 
 		//log?
-		if (options.exist('log')){
+		if (options.getfieldvalue('log','off')!='off'){
 			var bounds=options.getfieldvalue('caxis',[ArrayMin(data),ArrayMax(data)]);
 			for(var i=0;i<md.mesh.numberofvertices;i++)if(data[i]<bounds[0])data[i]=bounds[0];
@@ -191,7 +191,7 @@
 				throw Error("Log option cannot be applied on negative values. Use caxis option (Rignot''s settings: [1.5 max(data)])");
 			}
-		   for(var i=0;i<md.mesh.numberofvertices;i++){
-			   data[i]=Math.log10(data[i])/Math.log10(options.getfieldvalue('log'));
-		   }
+			for(var i=0;i<md.mesh.numberofvertices;i++){
+			   data[i]=Math.log10(data[i])/Math.log10(options.getfieldvalue('log',10));
+			}
 		}
 	}
@@ -200,4 +200,31 @@
     if (datasize==md.mesh.numberofvertices+1){
         datatype=5;
+		
+		//log?	
+		if (options.getfieldvalue('log','off')!='off'){
+			var bounds=options.getfieldvalue('caxis',[ArrayMin(data),ArrayMax(data)]);
+			for(var i=0;i<md.mesh.numberofvertices;i++) {
+				for(var j=0;j<data[i].length;j++) {
+					if(data[i][j]<bounds[0])data[i][j]=bounds[0];
+				}
+			}
+			for(var i=0;i<md.mesh.numberofvertices;i++) {
+				for(var j=0;j<data[i].length;j++) {
+					if(data[i][j]>bounds[1])data[i][j]=bounds[1];
+				}
+			}
+			for(var i=0;i<md.mesh.numberofvertices;i++) {
+				for(var j=0;j<data[i].length;j++) {
+					if(data[i][j]<=0) {
+						throw Error("Log option cannot be applied on negative values. Use caxis option (Rignot''s settings: [1.5 max(data)])");
+					}
+				}
+			}
+			for(var i=0;i<md.mesh.numberofvertices;i++){
+				for(var j=0;j<data[i].length;j++) {
+					data[i][j]=Math.log10(data[i][j])/Math.log10(options.getfieldvalue('log',10));
+				}
+			}
+		}
     }
 	
Index: /issm/trunk/src/wrappers/matlab/Makefile.am
===================================================================
--- /issm/trunk/src/wrappers/matlab/Makefile.am	(revision 20547)
+++ /issm/trunk/src/wrappers/matlab/Makefile.am	(revision 20548)
@@ -61,5 +61,4 @@
 						 PropagateFlagsFromConnectivity.la\
 						 StringToEnum.la\
-						 TriaSearch.la\
 						 TriMesh.la\
 						 TriMeshProcessRifts.la\
@@ -250,7 +249,4 @@
 Shp2Kml_la_LIBADD = ${deps} $(SHAPELIBLIB) $(MPILIB) $(PETSCLIB) $(GSLLIB) $(PROJ4LIB)
 
-TriaSearch_la_SOURCES = ../TriaSearch/TriaSearch.cpp
-TriaSearch_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(GSLLIB) $(PROJ4LIB)
-
 TriMesh_la_SOURCES = ../TriMesh/TriMesh.cpp
 TriMesh_la_LIBADD = ${deps} $(MPILIB) $(PETSCLIB) $(TRIANGLELIB) $(GSLLIB) $(PROJ4LIB)
Index: /issm/trunk/test/NightlyRun/test124.m
===================================================================
--- /issm/trunk/test/NightlyRun/test124.m	(revision 20547)
+++ /issm/trunk/test/NightlyRun/test124.m	(revision 20548)
@@ -21,7 +21,7 @@
 	'Vx3','Vy3','Vel3','Pressure3','Bed3','Surface3','Thickness3'};
 field_tolerances={...
-	2e-09,3.0e-9,3.0e-9,1e-10,1e-13,1e-12,1e-12,...
-	1e-09,3e-10,8e-10,1e-10,1e-10,1e-10,1e-10,...
-	1e-09,3e-10,8e-10,1e-10,1e-10,1e-10,1e-10};
+	2e-09,3e-9,3.0e-9,1e-10,1e-13,1e-12,1e-12,...
+	2e-09,3e-9,8e-10,1e-10,1e-10,1e-10,1e-10,...
+	2e-09,3e-9,8e-10,1e-10,1e-10,1e-10,1e-10};
 field_values={...
 	(md.results.TransientSolution(1).Vx),...
Index: /issm/trunk/test/NightlyRun/test211.py
===================================================================
--- /issm/trunk/test/NightlyRun/test211.py	(revision 20547)
+++ /issm/trunk/test/NightlyRun/test211.py	(revision 20548)
@@ -28,7 +28,7 @@
 	'Vx3','Vy3','Vz3','Vel3','Pressure3','Bed3','Surface3','Thickness3','Temperature3','BasalforcingsGroundediceMeltingRate3']
 field_tolerances=[\
-	2e-08,2e-08,1e-06,2e-08,1e-08,1e-08,1e-08,1e-08,1e-08,1e-08,\
-	5e-07,5e-07,5e-05,1e-07,1e-08,1e-08,1e-08,1e-08,5e-08,2e-06,\
-	5e-06,5e-06,5e-05,5e-06,1e-07,5e-07,5e-07,5e-07,5e-06,5e-05]
+	2e-08,2e-08,2e-06,2e-08,1e-08,1e-08,1e-08,1e-08,1e-08,1e-08,\
+	5e-07,5e-07,5e-05,2e-07,1e-08,1e-08,1e-08,1e-08,6e-08,2e-06,\
+	5e-06,5e-06,5e-05,5e-06,5e-07,5e-07,5e-07,5e-07,5e-06,5e-05]
 field_values=[\
 	md.results.TransientSolution[0].Vx,\
Index: /issm/trunk/test/NightlyRun/test3020.py
===================================================================
--- /issm/trunk/test/NightlyRun/test3020.py	(revision 20547)
+++ /issm/trunk/test/NightlyRun/test3020.py	(revision 20548)
@@ -62,6 +62,6 @@
 
 md=solve(md,TransientSolutionEnum())
-V0=md.results.TransientSolution[2].IceVolume
-MaxV0=md.results.TransientSolution[2].MaxVel
+V0=md.results.TransientSolution[-1].IceVolume
+MaxV0=md.results.TransientSolution[-1].MaxVel
 
 #backward
@@ -74,6 +74,6 @@
 
 md=solve(md,TransientSolutionEnum())
-V2=md.results.TransientSolution[2].IceVolume
-MaxV2=md.results.TransientSolution[2].MaxVel
+V2=md.results.TransientSolution[-1].IceVolume
+MaxV2=md.results.TransientSolution[-1].MaxVel
 
 #compute resulting derivative
Index: /issm/trunk/test/NightlyRun/test404.m
===================================================================
--- /issm/trunk/test/NightlyRun/test404.m	(revision 20547)
+++ /issm/trunk/test/NightlyRun/test404.m	(revision 20548)
@@ -10,5 +10,5 @@
 %Fields and tolerances to track changes
 field_names     ={'Vx','Vy','Vz','Vel','Pressure'};
-field_tolerances={6e-07,6e-07,2e-06,1e-06,3e-07};
+field_tolerances={6e-07,6e-07,2e-06,1e-06,5e-07};
 field_values={...
 	(md.results.StressbalanceSolution.Vx),...
Index: /issm/trunk/test/NightlyRun/test404.py
===================================================================
--- /issm/trunk/test/NightlyRun/test404.py	(revision 20547)
+++ /issm/trunk/test/NightlyRun/test404.py	(revision 20548)
@@ -20,5 +20,5 @@
 #Fields and tolerances to track changes
 field_names     =['Vx','Vy','Vz','Vel','Pressure']
-field_tolerances=[6e-07,6e-07,2e-06,1e-06,3e-07]
+field_tolerances=[6e-07,6e-07,2e-06,1e-06,5e-07]
 field_values=[\
 	md.results.StressbalanceSolution.Vx,\
Index: /issm/trunk/test/NightlyRun/test422.m
===================================================================
--- /issm/trunk/test/NightlyRun/test422.m	(revision 20547)
+++ /issm/trunk/test/NightlyRun/test422.m	(revision 20548)
@@ -11,5 +11,5 @@
 %Fields and tolerances to track changes
 field_names     ={'Vx','Vy','Vz','Vel','Pressure'};
-field_tolerances={4e-07,4e-07,2e-06,2e-07,5e-07};
+field_tolerances={4e-07,4e-07,2e-06,4e-07,5e-07};
 field_values={...
 	(md.results.StressbalanceSolution.Vx),...
Index: /issm/trunk/test/NightlyRun/test422.py
===================================================================
--- /issm/trunk/test/NightlyRun/test422.py	(revision 20547)
+++ /issm/trunk/test/NightlyRun/test422.py	(revision 20548)
@@ -21,5 +21,5 @@
 #Fields and tolerances to track changes
 field_names     =['Vx','Vy','Vz','Vel','Pressure']
-field_tolerances=[4e-07,4e-07,2e-06,2e-07,5e-07]
+field_tolerances=[4e-07,4e-07,2e-06,4e-07,5e-07]
 field_values=[\
 	md.results.StressbalanceSolution.Vx,\
