source: issm/trunk/src/m/model/waitonlock.m@ 7984

Last change on this file since 7984 was 7984, checked in by Mathieu Morlighem, 14 years ago

Added interactive runs for larsen and astrid

File size: 1.6 KB
Line 
1function flag=waitonlock(md,executionpath,login,port)
2%WAITONLOCK - wait for a file
3%
4% This routine will return when a file named 'filename' is written to disk.
5% If the time limit given in input is exceeded, return 0
6%
7% Usage:
8% flag=waitonlock(md,executionpath)
9
10%Get filename (lock file) and options
11executionpath=md.cluster.executionpath;
12cluster=md.cluster.name;
13login=md.cluster.login;
14port=md.cluster.port;
15timelimit=md.waitonlock;
16filename=[executionpath '/' md.runtimename '/' md.name '.lock'];
17
18%waitonlock will work if the lock is on the same machine only:
19if ~strcmpi(oshostname(),cluster),
20
21 disp('solution launched on remote cluster. log in to detect job completion.');
22 choice=input('Is the job successfully completed? (y/n)','s');
23 if ~strcmp(choice,'y'),
24 disp('Results not loaded... exiting');
25 flag=0;
26 else
27 flag=1;
28 end
29
30%job is running on the same machine
31else
32
33 if ismember('interactive',properties(md.cluster)) & md.cluster.interactive
34 %We are in interactive mode, no need to check for job completion
35 flag=1;
36 return;
37 end
38 %initialize time and file presence test flag
39 time=0; ispresent=0;
40 disp(['waiting for ' filename ' hold on... (Ctrl+C to exit)'])
41
42 %loop till file .lock exist or time is up
43 while (ispresent==0 & time<timelimit)
44 ispresent=exist(filename,'file');
45 pause(1);
46 time=time+1/60;
47 end
48
49 %build output
50 if (time>timelimit),
51 disp('Time limit exceeded. Increase md.waitonlock');
52 disp('The results must be loaded manually with md=loadresultsfromcluster(md).');
53 error(['waitonlock error message: time limit exceeded']);
54 flag=0;
55 else
56 flag=1;
57 end
58end
Note: See TracBrowser for help on using the repository browser.