source: issm/oecreview/Archive/14312-15392/ISSM-14351-14352.diff@ 15393

Last change on this file since 15393 was 15393, checked in by Mathieu Morlighem, 12 years ago

NEW: adding Archive/14312-15392 for oecreview

File size: 4.6 KB
  • ../trunk-jpl/src/m/solve/solve.m

     
    100100end
    101101
    102102%wait on lock
    103 if md.settings.waitonlock>0,
    104         %we wait for the done file
    105         islock=waitonlock(md);
    106         if islock==0, %no results to be loaded
    107                 disp('The results must be loaded manually with md=loadresultsfromcluster(md).');
    108         else          %load results
    109                 disp('loading results from cluster');
     103if 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
    110110                md=loadresultsfromcluster(md);
    111111        end
     112elseif 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);
     117elseif md.settings.waitonlock==0,
     118         disp('Model results must be loaded manually with md=loadresultsfromcluster(md);');
    112119end
    113120
    114121%post processes qmu results if necessary
  • ../trunk-jpl/src/m/solve/waitonlock.m

     
    1 function flag=waitonlock(md)
     1function ispresent=waitonlock(md)
    22%WAITONLOCK - wait for a file
    33%
    44%   This routine will return when a file named 'filename' is written to disk.
     
    77%   Usage:
    88%      flag=waitonlock(md)
    99
     10%Return if waitonlock < 0 (no need to wait)
     11
    1012%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;
     13executionpath = md.cluster.executionpath;
     14timelimit     = md.settings.waitonlock;
     15filename      = [executionpath '/' md.private.runtimename '/' md.miscellaneous.name '.lock'];
     16cluster       = md.cluster;
     17
     18%If we are using the generic cluster in interactive mode, job is already complete
     19if isa(cluster,'generic') & cluster.interactive
     20        %We are in interactive mode, no need to check for job completion
     21        ispresent=1;
     22        return;
    1623end
    17 timelimit=md.settings.waitonlock;
    18 filename=[executionpath '/' md.private.runtimename '/' md.miscellaneous.name '.lock'];
    1924
    20 %waitonlock will work if the lock is on the same machine only:
     25%initialize time and file presence test flag
     26time=0; ispresent=0;
     27disp(['waiting for ' filename ' hold on... (Ctrl+C to exit)'])
     28
     29%prepare command if the job is not running on the local machine
    2130if ~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'];
    2838        else
    29                 flag=1;
     39                command = ['ssh -l ' login ' ' cluster.name ' " [ -f ' filename '  ]" 2>/dev/null'];
    3040        end
     41end
    3142
    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
     44while (ispresent==0 & time<timelimit)
     45        if strcmpi(oshostname(),cluster),
    4646                ispresent=exist(filename,'file');
    4747                pause(1);
    4848                time=time+1/60;
    49         end
    50 
    51         %build output
    52         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;
    5749        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;
    5954        end
    6055end
     56
     57%build output
     58if (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']);
     62end
Note: See TracBrowser for help on using the repository browser.