Changeset 14356


Ignore:
Timestamp:
02/19/13 08:07:18 (12 years ago)
Author:
Mathieu Morlighem
Message:

CHG: we need to wait for the outlog since the lock file might be written before the outlog and errlog

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/m/solve/waitonlock.m

    r14352 r14356  
    22%WAITONLOCK - wait for a file
    33%
    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.
    57%   If the time limit given in input is exceeded, return 0
    68%
     
    1012%Return if waitonlock < 0 (no need to wait)
    1113
    12 %Get filename (lock file) and options
     14%Get lockfilename (lock file) and options
    1315executionpath = md.cluster.executionpath;
    1416timelimit     = md.settings.waitonlock;
    15 filename      = [executionpath '/' md.private.runtimename '/' md.miscellaneous.name '.lock'];
    1617cluster       = md.cluster;
     18lockfilename  = [executionpath '/' md.private.runtimename '/' md.miscellaneous.name '.lock'];
     19logfilename   = [executionpath '/' md.private.runtimename '/' md.miscellaneous.name '.outlog'];
    1720
    1821%If we are using the generic cluster in interactive mode, job is already complete
     
    2427
    2528%initialize time and file presence test flag
    26 time=0; ispresent=0;
    27 disp(['waiting for ' filename ' hold on... (Ctrl+C to exit)'])
     29time=0; ispresent=0; time0=clock;
     30disp(['waiting for ' lockfilename ' hold on... (Ctrl+C to exit)'])
    2831
    2932%prepare command if the job is not running on the local machine
     
    3538        end
    3639        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'];
    3841        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'];
    4043        end
    4144end
     
    4447while (ispresent==0 & time<timelimit)
    4548        if strcmpi(oshostname(),cluster),
    46                 ispresent=exist(filename,'file');
    4749                pause(1);
    48                 time=time+1/60;
     50                ispresent=(exist(lockfilename,'file') & exist(logfilename,'file'));
     51                time=etime(clock,time0)/60;
    4952        else
    5053                pause(10);
     54                time=etime(clock,time0)/60;
    5155                fprintf('\rchecking for job completion (time = %3.2f min)    ',time);
    52                 ispresent=~system(command); if ispresent, fprintf('\n'); end
    53                 time=time+10/60;
     56                ispresent=~system(command);
     57                if ispresent, fprintf('\n'); end
    5458        end
    5559end
Note: See TracChangeset for help on using the changeset viewer.