Index: /issm/trunk/src/m/classes/@model/setdefaultparameters.m
===================================================================
--- /issm/trunk/src/m/classes/@model/setdefaultparameters.m	(revision 2225)
+++ /issm/trunk/src/m/classes/@model/setdefaultparameters.m	(revision 2226)
@@ -213,8 +213,9 @@
 md.cluster='none';
 
-%this option can be activated (1) to load automatically the results
+%this option can be activated to load automatically the results
 %onto the model after a parallel run by waiting for the lock file
-%that is generated once the solution has converged
-md.waitonlock=1;
+%N minutes that is generated once the solution has converged
+%0 to desactivate
+md.waitonlock=Inf;
 
 %number of processors to be used (if parallel)
Index: /issm/trunk/src/m/classes/public/display/displayparallel.m
===================================================================
--- /issm/trunk/src/m/classes/public/display/displayparallel.m	(revision 2225)
+++ /issm/trunk/src/m/classes/public/display/displayparallel.m	(revision 2226)
@@ -17,5 +17,5 @@
 fielddisplay(md,'time','amount of time requested on cluster');
 fielddisplay(md,'alloc_cleanup','allocation cleanup before starting a job, default 1');
-fielddisplay(md,'waitonlock','wait for batch results 1, or return 0. default is to return');
+fielddisplay(md,'waitonlock','maximum number of minutes to wait for batch results, or return 0');
 fielddisplay(md,'queue','special queue name on cluster? default is '''' ');
 
Index: /issm/trunk/src/m/classes/public/solveparallel.m
===================================================================
--- /issm/trunk/src/m/classes/public/solveparallel.m	(revision 2225)
+++ /issm/trunk/src/m/classes/public/solveparallel.m	(revision 2226)
@@ -26,9 +26,15 @@
 
 %Do we return, or just wait for results?
-if md.waitonlock,
+if md.waitonlock~=0,
 	%we wait for the done file
-	waitonlock([executionpath '/' md.name '.lock']);
-	%load results
-	displaystring(md.debug,'loading results from cluster');
-	md=loadresultsfromcluster(md);
+	islock=waitonlock([executionpath '/' md.name '.lock'],md.waitonlock);
+	if islock==0,
+		%no results to be loaded
+		disp('The results must be loaded manually with loadmodelfromcluster.');
+		error(['solveparallel info message: time limit exceeded'])
+	else
+		%load results
+		displaystring(md.debug,'loading results from cluster');
+		md=loadresultsfromcluster(md);
+	end
 end
Index: /issm/trunk/src/m/classes/public/waitonlock.m
===================================================================
--- /issm/trunk/src/m/classes/public/waitonlock.m	(revision 2225)
+++ /issm/trunk/src/m/classes/public/waitonlock.m	(revision 2226)
@@ -1,14 +1,27 @@
-function waitonlock(filename)
+function flag=waitonlock(filename,timelimit)
 %WAITONLOCK - wait for a file
 %
 %   This routine will return when a file named 'filename' is written to disk.
+%   If the time limit given in input is exceeded, return 0
 %
 %   Usage:
-%      waitonlock(filename)
+%      flag=waitonlock(filename,timelimit)
 
-test=0;
+%initialize time and file presence test flag
+time=0;
+ispresent=0;
 disp(['waiting for ' filename ' hold on... (Ctrl+C to exit)'])
-while test==0
-	test=exist(filename,'file');
-	pause(1)
+
+%loop till file .lock exist or time is up
+while (ispresent==0 & time<timelimit)
+	ispresent=exist(filename,'file');
+	pause(1);
+	time=time+1/60;
 end
+
+%build output
+if (time>timelimit),
+	flag=0;
+else
+	flag=1;
+end
