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

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

cluster pfe is by default empty. User dependent settings are to be found in pfe_settings of the user contrib directory that has been added to the matlab path (startup).
Also, waitonlock waits for y/n to load results automatically from cluster. Use waitonlck=0 to disable this functionnality.

File size: 1.4 KB
RevLine 
[3175]1function flag=waitonlock(md,executionpath,login,port)
[1]2%WAITONLOCK - wait for a file
3%
4% This routine will return when a file named 'filename' is written to disk.
[2226]5% If the time limit given in input is exceeded, return 0
[1]6%
7% Usage:
[2555]8% flag=waitonlock(md,executionpath)
[1]9
[2555]10%Get filename (lock file) and options
[5954]11executionpath=md.cluster.executionpath;
12cluster=md.cluster.name;
13login=md.cluster.login;
14port=md.cluster.port;
15timelimit=md.waitonlock;
[5546]16filename=[executionpath '/' md.runtimename '/' md.name '.lock'];
[2226]17
[2555]18%waitonlock will work if the lock is on the same machine only:
19if ~strcmpi(oshostname(),cluster),
[3175]20
[6378]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;
[2555]26 else
[6378]27 flag=1;
[2555]28 end
[2226]29
[2555]30%job is running on the same machine
[2226]31else
[2555]32
33 %initialize time and file presence test flag
34 time=0; ispresent=0;
35 disp(['waiting for ' filename ' hold on... (Ctrl+C to exit)'])
36
37 %loop till file .lock exist or time is up
38 while (ispresent==0 & time<timelimit)
39 ispresent=exist(filename,'file');
40 pause(1);
41 time=time+1/60;
42 end
43
44 %build output
45 if (time>timelimit),
[2656]46 disp('Time limit exceeded. Increase md.waitonlock');
47 disp('The results must be loaded manually with md=loadresultsfromcluster(md).');
48 error(['waitonlock error message: time limit exceeded']);
[2555]49 flag=0;
50 else
51 flag=1;
52 end
[2226]53end
Note: See TracBrowser for help on using the repository browser.