source:
issm/oecreview/Archive/14312-15392/ISSM-14351-14352.diff@
15393
Last change on this file since 15393 was 15393, checked in by , 12 years ago | |
---|---|
File size: 4.6 KB |
-
../trunk-jpl/src/m/solve/solve.m
100 100 end 101 101 102 102 %wait on lock 103 if md.settings.waitonlock>0,104 % we wait for the done file105 islock=waitonlock(md);106 if islock==0, %no results to be loaded107 disp('The results must be loaded manually with md=loadresultsfromcluster(md).');108 else %load results109 disp('loading results from cluster');103 if isnan(md.settings.waitonlock), 104 %load when user enters 'y' 105 disp('solution launched on remote cluster. log in to detect job completion.'); 106 choice=input('Is the job successfully completed? (y/n)','s'); 107 if ~strcmp(choice,'y'), 108 disp('Results not loaded... exiting'); 109 else 110 110 md=loadresultsfromcluster(md); 111 111 end 112 elseif md.settings.waitonlock>0, 113 %we wait for the done file 114 done=waitonlock(md); 115 disp('loading results from cluster'); 116 md=loadresultsfromcluster(md); 117 elseif md.settings.waitonlock==0, 118 disp('Model results must be loaded manually with md=loadresultsfromcluster(md);'); 112 119 end 113 120 114 121 %post processes qmu results if necessary -
../trunk-jpl/src/m/solve/waitonlock.m
1 function flag=waitonlock(md)1 function ispresent=waitonlock(md) 2 2 %WAITONLOCK - wait for a file 3 3 % 4 4 % This routine will return when a file named 'filename' is written to disk. … … 7 7 % Usage: 8 8 % flag=waitonlock(md) 9 9 10 %Return if waitonlock < 0 (no need to wait) 11 10 12 %Get filename (lock file) and options 11 executionpath=md.cluster.executionpath; 12 cluster=md.cluster.name; 13 login=md.cluster.login; 14 if isprop(md.cluster,'port') 15 port=md.cluster.port; 13 executionpath = md.cluster.executionpath; 14 timelimit = md.settings.waitonlock; 15 filename = [executionpath '/' md.private.runtimename '/' md.miscellaneous.name '.lock']; 16 cluster = md.cluster; 17 18 %If we are using the generic cluster in interactive mode, job is already complete 19 if isa(cluster,'generic') & cluster.interactive 20 %We are in interactive mode, no need to check for job completion 21 ispresent=1; 22 return; 16 23 end 17 timelimit=md.settings.waitonlock;18 filename=[executionpath '/' md.private.runtimename '/' md.miscellaneous.name '.lock'];19 24 20 %waitonlock will work if the lock is on the same machine only: 25 %initialize time and file presence test flag 26 time=0; ispresent=0; 27 disp(['waiting for ' filename ' hold on... (Ctrl+C to exit)']) 28 29 %prepare command if the job is not running on the local machine 21 30 if ~strcmpi(oshostname(),cluster), 22 23 disp('solution launched on remote cluster. log in to detect job completion.'); 24 choice=input('Is the job successfully completed? (y/n)','s'); 25 if ~strcmp(choice,'y'), 26 disp('Results not loaded... exiting'); 27 flag=0; 31 login = cluster.login; 32 port = 0; 33 if isprop(cluster,'port') 34 port = cluster.port; 35 end 36 if port, 37 command = ['ssh -l ' login ' -p ' num2str(port) ' localhost " [ -f ' filename ' ]" 2>/dev/null']; 28 38 else 29 flag=1;39 command = ['ssh -l ' login ' ' cluster.name ' " [ -f ' filename ' ]" 2>/dev/null']; 30 40 end 41 end 31 42 32 %job is running on the same machine 33 else 34 35 if ismember('interactive',properties(md.cluster)) & md.cluster.interactive 36 %We are in interactive mode, no need to check for job completion 37 flag=1; 38 return; 39 end 40 %initialize time and file presence test flag 41 time=0; ispresent=0; 42 disp(['waiting for ' filename ' hold on... (Ctrl+C to exit)']) 43 44 %loop till file .lock exist or time is up 45 while (ispresent==0 & time<timelimit) 43 %loop till file .lock exist or time is up 44 while (ispresent==0 & time<timelimit) 45 if strcmpi(oshostname(),cluster), 46 46 ispresent=exist(filename,'file'); 47 47 pause(1); 48 48 time=time+1/60; 49 end50 51 %build output52 if (time>timelimit),53 disp('Time limit exceeded. Increase md.settings.waitonlock');54 disp('The results must be loaded manually with md=loadresultsfromcluster(md).');55 error(['waitonlock error message: time limit exceeded']);56 flag=0;57 49 else 58 flag=1; 50 pause(10); 51 fprintf('\rchecking for job completion (time = %3.2f min) ',time); 52 ispresent=~system(command); if ispresent, fprintf('\n'); end 53 time=time+10/60; 59 54 end 60 55 end 56 57 %build output 58 if (time>timelimit), 59 disp('Time limit exceeded. Increase md.settings.waitonlock'); 60 disp('The results must be loaded manually with md=loadresultsfromcluster(md).'); 61 error(['waitonlock error message: time limit exceeded']); 62 end
Note:
See TracBrowser
for help on using the repository browser.