Changeset 14356
- Timestamp:
- 02/19/13 08:07:18 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/m/solve/waitonlock.m
r14352 r14356 2 2 %WAITONLOCK - wait for a file 3 3 % 4 % This routine will return when a file named 'filename' is written to disk. 4 % This routine will return when a file named 'lockfilename' is written to disk. 5 % Also check for outlog file be cause it might bewritten several seconds 6 % after the lock file. 5 7 % If the time limit given in input is exceeded, return 0 6 8 % … … 10 12 %Return if waitonlock < 0 (no need to wait) 11 13 12 %Get filename (lock file) and options14 %Get lockfilename (lock file) and options 13 15 executionpath = md.cluster.executionpath; 14 16 timelimit = md.settings.waitonlock; 15 filename = [executionpath '/' md.private.runtimename '/' md.miscellaneous.name '.lock'];16 17 cluster = md.cluster; 18 lockfilename = [executionpath '/' md.private.runtimename '/' md.miscellaneous.name '.lock']; 19 logfilename = [executionpath '/' md.private.runtimename '/' md.miscellaneous.name '.outlog']; 17 20 18 21 %If we are using the generic cluster in interactive mode, job is already complete … … 24 27 25 28 %initialize time and file presence test flag 26 time=0; ispresent=0; 27 disp(['waiting for ' filename ' hold on... (Ctrl+C to exit)'])29 time=0; ispresent=0; time0=clock; 30 disp(['waiting for ' lockfilename ' hold on... (Ctrl+C to exit)']) 28 31 29 32 %prepare command if the job is not running on the local machine … … 35 38 end 36 39 if port, 37 command = ['ssh -l ' login ' -p ' num2str(port) ' localhost " [ -f ' filename ']" 2>/dev/null'];40 command = ['ssh -l ' login ' -p ' num2str(port) ' localhost "[ -f ' lockfilename ' ] && [ -f ' logfilename ' ]" 2>/dev/null']; 38 41 else 39 command = ['ssh -l ' login ' ' cluster.name ' " [ -f ' filename ']" 2>/dev/null'];42 command = ['ssh -l ' login ' ' cluster.name ' "[ -f ' lockfilename ' ] && [ -f ' logfilename ' ]" 2>/dev/null']; 40 43 end 41 44 end … … 44 47 while (ispresent==0 & time<timelimit) 45 48 if strcmpi(oshostname(),cluster), 46 ispresent=exist(filename,'file');47 49 pause(1); 48 time=time+1/60; 50 ispresent=(exist(lockfilename,'file') & exist(logfilename,'file')); 51 time=etime(clock,time0)/60; 49 52 else 50 53 pause(10); 54 time=etime(clock,time0)/60; 51 55 fprintf('\rchecking for job completion (time = %3.2f min) ',time); 52 ispresent=~system(command); if ispresent, fprintf('\n'); end53 time=time+10/60;56 ispresent=~system(command); 57 if ispresent, fprintf('\n'); end 54 58 end 55 59 end
Note:
See TracChangeset
for help on using the changeset viewer.