Changeset 26344


Ignore:
Timestamp:
07/09/21 13:28:16 (4 years ago)
Author:
jdquinn
Message:

CHG: Revised pleiades.oy download dialog; various pending minor fixes; cleanup

Location:
issm/trunk-jpl/src
Files:
1 added
13 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/m/classes/clusters/cloud.m

    r26332 r26344  
    2020
    2121                        %initialize cluster using user settings if provided
    22                         if (exist('cloud_settings')==2), 
    23                                 eval('cloud_settings');
     22                        if (exist('cloud_settings')==2),
     23                                cloud_settings;
    2424                        end
    2525
     
    2929                %}}}
    3030                function disp(cluster) % {{{
    31                         %  display the object
     31                        %display the object
    3232                        disp(sprintf('class ''%s'' object ''%s'' = ',class(cluster),inputname(1)));
    3333                        disp(sprintf('    name: %s',cluster.name));
     
    5353                        fid=fopen([modelname '.queue'],'w');
    5454                        fprintf(fid,'#!/bin/bash\n');
    55                         if cluster.interactive
    56                                 fprintf(fid,'source %s%s\n',cluster.codepath,'/../etc/environment.sh');
    57                                 fprintf(fid,'cd %s\n',[cluster.executionpath '/' dirname]);
    58                                 fprintf(fid,'mpiexec -np %i -f /home/mpich2.hosts %s/issm.exe %s %s %s 2> %s.errlog > /dev/stdout | tee %s.outlog ',cluster.np,cluster.codepath,solution,[cluster.executionpath '/' dirname],modelname,modelname,modelname);
    59                         else
    60                                 fprintf(fid,'source %s%s\n',cluster.codepath,'/../etc/environment.sh');
    61                                 fprintf(fid,'cd %s\n',[cluster.executionpath '/' dirname]);
    62                                 fprintf(fid,'mpiexec -np %i -f /home/mpich2.hosts %s/issm.exe %s %s %s 2> %s.errlog > /dev/stdout | tee %s.outlog ',cluster.np,cluster.codepath,solution,[cluster.executionpath '/' dirname],modelname,modelname,modelname);
    63                         end
     55                        fprintf(fid,'source %s%s\n',cluster.codepath,'/../etc/environment.sh');
     56                        fprintf(fid,'cd %s\n',[cluster.executionpath '/' dirname]);
     57                        fprintf(fid,'mpiexec -np %i -f /home/mpich2.hosts %s/issm.exe %s %s/%s %s 2> %s.errlog > /dev/stdout | tee %s.outlog',cluster.np,cluster.codepath,solution,cluster.executionpath,dirname,modelname,modelname,modelname);
    6458                end
    6559                %}}}
     
    8882                                else
    8983                                        launchcommand=['cd ' cluster.executionpath ' && rm -rf ./' dirname ' && mkdir ' dirname ...
    90                                                 ' && cd ' dirname ' && mv ../' dirname '.tar.gz ./ && tar -zxf ' dirname '.tar.gz '];
     84                                                ' && cd ' dirname ' && mv ../' dirname '.tar.gz ./ && tar -zxf ' dirname '.tar.gz'];
    9185                                end
    9286                        else
    9387                                disp('launching solution sequence on remote cluster');
    9488                                if ~isempty(restart)
    95                                         launchcommand=['cd ' cluster.executionpath ' && cd ' dirname ' && qsub  ' modelname '.queue '];
     89                                        launchcommand=['cd ' cluster.executionpath ' && cd ' dirname ' && qsub ' modelname '.queue'];
    9690                                else
    9791                                        launchcommand=['cd ' cluster.executionpath ' && rm -rf ./' dirname ' && mkdir ' dirname ...
    98                                                 ' && cd ' dirname ' && mv ../' dirname '.tar.gz ./ && tar -zxf ' dirname '.tar.gz  && qsub  ' modelname '.queue '];
     92                                                ' && cd ' dirname ' && mv ../' dirname '.tar.gz ./ && tar -zxf ' dirname '.tar.gz && qsub ' modelname '.queue'];
    9993                                end
    10094                        end
  • issm/trunk-jpl/src/m/classes/clusters/cyclone.py

    r26332 r26344  
    11import subprocess
    2 from fielddisplay import fielddisplay
    3 from pairoptions import pairoptions
    4 from issmssh import issmssh
    5 from issmscpin import issmscpin
    6 from issmscpout import issmscpout
     2
    73try:
    84    from cyclone_settings import cyclone_settings
    95except ImportError:
    106    print('You need cyclone_settings.py to proceed, check presence and sys.path')
     7from fielddisplay import fielddisplay
     8from helpers import *
     9from pairoptions import pairoptions
     10from issmscpin import issmscpin
     11from issmscpout import issmscpout
     12from issmssh import issmssh
    1113
    1214
     
    9698    def LaunchQueueJob(self, modelname, dirname, filelist, restart, batch):  # {{{
    9799        print('launching solution sequence on remote cluster')
    98         if restart:
     100        if not isempty(restart):
    99101            launchcommand = 'cd %s && cd %s && qsub %s.queue' % (self.executionpath, dirname, modelname)
    100102        else:
  • issm/trunk-jpl/src/m/classes/clusters/discover.py

    r26340 r26344  
    66    print('You need discover_settings.py to proceed, check presence and sys.path')
    77from fielddisplay import fielddisplay
     8from helpers import *
    89from IssmConfig import IssmConfig
    910from issmscpin import issmscpin
     
    1112from issmssh import issmssh
    1213from MatlabFuncs import *
    13 import math
    14 import numpy as np
    1514from pairoptions import pairoptions
    1615from QueueRequirements import QueueRequirements
     
    6059    def __repr__(self):  # {{{
    6160        # Display the object
    62         s = 'class pfe object\n'
     61        s = 'class discover object\n'
    6362        s += '    name: {}\n'.format(self.name)
    6463        s += '    login: {}\n'.format(self.login)
     
    8786
    8887    def checkconsistency(self, md, solution, analyses):  # {{{
    89         queuedict = {'long': [24*60*60, 560],
    90                      'allnccs': [12*60*60, 6000],
    91                      'debug': [1*60*60, 532]}
     88        queuedict = {'long': [24 * 60 * 60, 560],
     89                     'allnccs': [12 * 60 * 60, 6000],
     90                     'debug': [1 * 60 * 60, 532]}
    9291        QueueRequirements(queuedict, self.queue, self.nprocs(), self.time)
    9392
     
    136135        fid.write('#SBATCH -n {} \n'.format(self.nprocs()))
    137136        fid.write('#SBATCH -N {} \n'.format(self.numnodes))
    138         fid.write('#SBATCH -t {:02d}:{:02d}:00 \n'.format(int(math.floor(self.time / 3600)), int(math.floor(self.time % 3600) / 60)))
     137        fid.write('#SBATCH -t {:02d}:{:02d}:00 \n'.format(floor(self.time / 3600), floor(self.time % 3600) / 60))
    139138        fid.write('#SBATCH -A {} \n\n'.format(self.grouplist))
    140139        if (self.email.find('@')>-1):
     
    196195    def LaunchQueueJob(self, modelname, dirname, filelist, restart, batch):  # {{{
    197196        if self.interactive:
    198             if restart:
     197            if not isempty(restart):
    199198                launchcommand = 'cd {}/Interactive{}'.format(self.executionpath, self.interactive)
    200199            else:
    201200                launchcommand = 'cd {}/Interactive{} && tar -zxf {}.tar.gz'.format(self.executionpath, self.interactive, dirname)
    202201        else:
    203             if restart:
     202            if not isempty(restart):
    204203                launchcommand = 'cd {} && cd {} && sbatch {}.queue'.format(self.executionpath, dirname, modelname)
    205204            else:
  • issm/trunk-jpl/src/m/classes/clusters/fram.py

    r26332 r26344  
    11import subprocess
     2
    23import numpy as np
     4
    35from fielddisplay import fielddisplay
    4 from pairoptions import pairoptions
    5 from issmssh import issmssh
    6 from issmscpin import issmscpin
    7 from issmscpout import issmscpout
    8 from QueueRequirements import QueueRequirements
    9 from IssmConfig import IssmConfig
    106try:
    117    from fram_settings import fram_settings
    128except ImportError:
    139    print('You need fram_settings.py to proceed, check presence and sys.path')
     10from helpers import *
     11from pairoptions import pairoptions
     12from IssmConfig import IssmConfig
     13from issmscpin import issmscpin
     14from issmscpout import issmscpout
     15from issmssh import issmssh
     16from QueueRequirements import QueueRequirements
    1417
    1518
     
    147150    def LaunchQueueJob(self, modelname, dirname, filelist, restart, batch):  # {{{
    148151        print('launching solution sequence on remote cluster')
    149         if restart:
     152        if not isempty(restart):
    150153            launchcommand = 'cd %s && cd %s && sbatch %s.queue' % (self.executionpath, dirname, modelname)
    151154        else:
  • issm/trunk-jpl/src/m/classes/clusters/pfe.m

    r26332 r26344  
    138138                        if isempty(cluster.executionpath), md = checkmessage(md,'executionpath empty'); end
    139139                        if isempty(cluster.grouplist), md = checkmessage(md,'grouplist empty'); end
    140                         if ~isempty(cluster.interactive), md = checkmessage(md,'interactive mode not implemented'); end
    141140
    142141                end
     
    163162                        fprintf(fid,'#PBS -l select=%i:ncpus=%i:model=%s\n',cluster.numnodes,cluster.cpuspernode,cluster.processor);
    164163                        fprintf(fid,'#PBS -l walltime=%i\n',cluster.time*60); %walltime is in seconds.
    165                         fprintf(fid,'#PBS -q %s \n',cluster.queue);
     164                        fprintf(fid,'#PBS -q %s\n',cluster.queue);
    166165                        fprintf(fid,'#PBS -W group_list=%s\n',cluster.grouplist);
    167166                        fprintf(fid,'#PBS -m e\n');
     
    431430                                else
    432431                                        launchcommand=['cd ' cluster.executionpath ' && rm -rf ./' dirname ' && mkdir ' dirname ...
    433                                                 ' && cd ' dirname ' && mv ../' dirname '.tar.gz ./ && tar -zxf ' dirname '.tar.gz  && qsub ' modelname '.queue '];
     432                                                ' && cd ' dirname ' && mv ../' dirname '.tar.gz ./ && tar -zxf ' dirname '.tar.gz && qsub ' modelname '.queue '];
    434433                                end
    435434                        end
  • issm/trunk-jpl/src/m/classes/clusters/pfe.py

    r26333 r26344  
    22
    33from fielddisplay import fielddisplay
     4from helpers import *
    45from IssmConfig import IssmConfig
    56from issmscpin import issmscpin
     
    140141        if not self.grouplist:
    141142            md = md.checkmessage('grouplist empty')
    142         if self.interactive == 1:
    143             md = md.checkmessage('interactive mode not implemented')
    144143
    145144        return self
     
    182181
    183182        fid.close()
    184 
    185183    # }}}
    186184
     
    200198        # Launch command, to be executed via ssh
    201199        if self.interactive:
    202             if restart:
     200            if not isempty(restart):
    203201                launchcommand = 'cd {} /Interactive{}'.format(self.executionpath, self.interactive)
    204202            else:
     
    208206                    launchcommand = 'cd {} /Interactive{} && tar -zxf {}.tar.gz'.format(self.executionpath, self.interactive, dirname)
    209207        else:
    210             if restart:
     208            if not isempty(restart):
    211209                launchcommand = 'cd {} && cd {} && qsub {}.queue'.format(self.executionpath, dirname, modelname)
    212210            else:
  • issm/trunk-jpl/src/m/classes/clusters/saga.py

    r26332 r26344  
     1import datetime
    12import subprocess
     3
    24from fielddisplay import fielddisplay
    3 from pairoptions import pairoptions
    4 from issmssh import issmssh
     5from helpers import *
     6from IssmConfig import IssmConfig
    57from issmscpin import issmscpin
    68from issmscpout import issmscpout
     9from issmssh import issmssh
     10from pairoptions import pairoptions
    711from QueueRequirements import QueueRequirements
    8 from IssmConfig import IssmConfig
    9 import datetime
    1012try:
    1113    from saga_settings import saga_settings
     
    157159    def LaunchQueueJob(self, modelname, dirname, filelist, restart, batch):  # {{{
    158160        print('launching solution sequence on remote cluster')
    159         if restart:
     161        if not isempty(restart):
    160162            launchcommand = 'cd %s && cd %s && sbatch %s.queue' % (self.executionpath, dirname, modelname)
    161163        else:
  • issm/trunk-jpl/src/m/mesh/planet/gmsh/gmshplanet.py

    r26184 r26344  
    99
    1010def gmshplanet(*args):
    11     '''
    12     GMSHPLANET - mesh generation for a sphere. Very specific code for gmsh from $ISSM_DIR/src/demos/simple_geo/sphere.geo
     11    """GMSHPLANET - mesh generation for a sphere. Very specific code for gmsh from $ISSM_DIR/src/demos/simple_geo/sphere.geo
    1312
    1413    Available options (for more details see ISSM website http://issm.jpl.nasa.gov/):
     
    1817    - refinemetric:       mesh quantity to specify resolution
    1918
    20         Returns 'mesh3dsurface' type mesh
     19    Returns 'mesh3dsurface' type mesh
    2120
    22         Examples:
    23             md.mesh = gmshplanet('radius', 6000, 'resolution', 100);
    24             md.mesh = gmshplanet('radius', 6000, 'resolution', 100);
    25     '''
     21    Examples:
     22        md.mesh = gmshplanet('radius', 6000, 'resolution', 100);
     23        md.mesh = gmshplanet('radius', 6000, 'resolution', 100);
     24    """
    2625
    2726    # Get Gmsh version
     
    3534        raise RuntimeError("gmshplanet: Gmsh major version {} not supported!".format(gmshmajorversion))
    3635
    37     #process options
     36    # Process options
    3837    options = pairoptions(*args)
    3938    #options = deleteduplicates(options, 1)
    4039
    41     #recover parameters:
     40    # Recover parameters
    4241    radius = options.getfieldvalue('radius') * 1000
    4342    resolution = options.getfieldvalue('resolution') * 1000
    4443
    45     #initialize mesh:
     44    # Initialize mesh
    4645    mesh = mesh3dsurface()
    47     #create .geo file:  {{{
     46    # Create .geo file:  {{{
    4847    fid = open('sphere.geo', 'w')
    4948
     
    108107        metric = options.getfieldvalue('refinemetric')
    109108
    110     #create .pos file with existing mesh and refining metric:  {{{
     109        # Create .pos file with existing mesh and refining metric:  {{{
    111110        fid = open('sphere.pos', 'w')
    112111
     
    120119        fid.write('];\n')
    121120        fid.close()
    122     # }}}
     121        #}}}
    123122
    124123    # Call gmsh
     
    133132        subprocess.call('gmsh -tol 1e-8 -2 -format msh2 sphere.geo', shell=True)
    134133
    135     #import mesh:  {{{
     134    # Import mesh  {{{
    136135    fid = open('sphere.msh', 'r')
    137136
    138     #Get Mesh format
     137    # Get mesh format
    139138    A = fid.readline().strip()
    140139    if A != '$MeshFormat':
     
    146145        raise RuntimeError(['Expecting $EndMeshFormat (', A, ')'])
    147146
    148     #Nodes
     147    # Nodes
    149148    A = fid.readline().strip()
    150149    if A != '$Nodes':
     
    165164        raise RuntimeError(['Expecting $EndNodes (', A, ')'])
    166165
    167     #Elements
     166    # Elements
    168167    A = fid.readline().strip()
    169168    if A != '$Elements':
     
    186185    mesh.long = np.arctan2(mesh.y, mesh.x) / np.pi * 180
    187186
    188     #erase files:
     187    # Erase files
    189188    subprocess.call('rm -rf sphere.geo sphere.msh sphere.pos', shell=True)
    190189
    191     #return mesh:
     190    # Return mesh
    192191    return mesh
  • issm/trunk-jpl/src/m/miscellaneous/MatlabFuncs.py

    r26332 r26344  
    88"""
    99
    10 def acosd(X): #{{{
     10def acosd(X):  #{{{
    1111    """ function acosd - Inverse cosine in degrees
    1212
     
    1919#}}}
    2020
    21 def asind(X): #{{{
     21def asind(X):  #{{{
    2222    """ function asind - Inverse sine in degrees
    2323
     
    3030#}}}
    3131
    32 def atand(X): #{{{
     32def atand(X):  #{{{
    3333    """ function atand - Inverse tangent in degrees
    3434
     
    4242
    4343
    44 def atan2d(Y, X): #{{{
    45     """ function atan2d - Four-quadrant inverse tangent in degrees
     44def atan2d(Y, X):  #{{{
     45    """function atan2d - Four-quadrant inverse tangent in degrees
    4646
    4747    Usage:
     
    5353#}}}
    5454
    55 def det(a): #{{{
     55def det(a):  #{{{
    5656    if a.shape == (1, ):
    5757        return a[0]
     
    6464#}}}
    6565
    66 def find(*args): #{{{
     66def error(msg):  #{{{
     67    raise Exception(msg)
     68#}}}
     69
     70def etime(t2, t1):  #{{{
     71    return t2 - t1
     72#}}}
     73
     74def find(*args):  #{{{
    6775    nargs = len(args)
    6876    if nargs >= 1 or nargs <= 2:
     
    8088#}}}
    8189
    82 def heaviside(x): #{{{
     90def floor(X):  #{{{
     91    import math
     92
     93    return int(math.floor(X))
     94#}}}
     95
     96def heaviside(x):  #{{{
    8397    import numpy as np
    8498
     
    90104#}}}
    91105
    92 def ismac(): #{{{
     106def isfile(fileName):  #{{{
     107    import os
     108
     109    return os.path.exists(fileName)
     110#}}}
     111
     112def ismac():  #{{{
    93113    import platform
    94114
     
    99119#}}}
    100120
    101 def ismember(a, s): #{{{
     121def ismember(a, s):  #{{{
    102122    import numpy as np
    103123
     
    121141#}}}
    122142
    123 def ispc(): #{{{
     143def isnan(A):  #{{{
     144    import numpy as np
     145
     146    return np.isnan(A)
     147#}}}
     148
     149def ispc():  #{{{
    124150    import platform
    125151
     
    130156#}}}
    131157
    132 def mod(a, m): #{{{
     158def isprop(obj, PropertyName):  #{{{
     159    return hasattr(obj, PropertyName)
     160#}}}
     161
     162def mod(a, m):  #{{{
    133163    return a % m
    134164#}}}
    135165
    136 def oshostname(): #{{{
     166def pause(n):  #{{{
     167    import time
     168
     169    time.sleep(n)
     170#}}}
     171
     172def pwd():  #{{{
     173    import os
     174
     175    return os.getcwd()
     176#}}}
     177
     178def oshostname():  #{{{
    137179    import socket
    138180
     
    140182#}}}
    141183
    142 def sparse(ivec, jvec, svec, m=0, n=0, nzmax=0): #{{{
     184def rem(a, b):  #{{{
     185    return a % b
     186#}}}
     187
     188def sparse(ivec, jvec, svec, m=0, n=0, nzmax=0):  #{{{
    143189    import numpy as np
    144190
     
    156202#}}}
    157203
    158 def strcmp(s1, s2): #{{{
     204def strcmp(s1, s2):  #{{{
    159205    if s1 == s2:
    160206        return True
     
    163209#}}}
    164210
    165 def strcmpi(s1, s2): #{{{
     211def strcmpi(s1, s2):  #{{{
    166212    if s1.lower() == s2.lower():
    167213        return True
     
    170216#}}}
    171217
    172 def strjoin(*args): #{{{
     218def strjoin(*args):  #{{{
    173219    nargs = len(args)
    174220    if nargs >= 1 or nargs <= 2:
     
    181227#}}}
    182228
    183 def strncmp(s1, s2, n): #{{{
     229def strncmp(s1, s2, n):  #{{{
    184230    if s1[0:n] == s2[0:n]:
    185231        return True
     
    188234#}}}
    189235
    190 def strncmpi(s1, s2, n): #{{{
     236def strncmpi(s1, s2, n):  #{{{
    191237    if s1.lower()[0:n] == s2.lower()[0:n]:
    192238        return True
  • issm/trunk-jpl/src/m/solve/solve.py

    r26307 r26344  
    106106        pass  # do nothing
    107107    else:
    108         if restart:
     108        if not isempty(restart):
    109109            md.private.runtimename = restart
    110110        else:
  • issm/trunk-jpl/src/m/solve/waitonlock.m

    r26039 r26344  
    3737
    3838%initialize time and file presence test flag
    39 time=0; ispresent=0; time0=clock;
     39elapsedtime=0; ispresent=0; starttime=clock;
    4040disp(['waiting for ' lockfilename ' hold on... (Ctrl+C to exit)'])
    4141
     
    5858
    5959%loop till file .lock exist or time is up
    60 while (ispresent==0 & time<timelimit)
     60while (ispresent==0 & elapsedtime<timelimit)
    6161        if strcmpi(oshostname(),cluster.name),
    6262                pause(1);
    6363                ispresent=(exist(lockfilename,'file') & exist(logfilename,'file'));
    64                 time=etime(clock,time0)/60;
     64                elapsedtime=etime(clock,starttime)/60;
    6565        else
    6666                pause(5);
    67                 time=etime(clock,time0);
    68                 fprintf('\rchecking for job completion (time: %i min %i sec)      ',floor(time/60),floor(rem(time,60)));
    69                 time=time/60; %converts time from sec to min
     67                elapsedtime=etime(clock,starttime);
     68                fprintf('\rchecking for job completion (time: %i min %i sec)      ',floor(elapsedtime/60),floor(rem(elapsedtime,60)));
     69                elapsedtime=elapsedtime/60; %converts time from sec to min
    7070                ispresent=~system(command);
    7171                if ispresent, fprintf('\n'); end
     
    7474
    7575%build output
    76 if (time>timelimit),
     76if (elapsedtime>timelimit),
    7777        disp('Time limit exceeded. Increase md.settings.waitonlock');
    7878        disp('The results must be loaded manually with md=loadresultsfromcluster(md).');
  • issm/trunk-jpl/src/m/solve/waitonlock.py

    r26332 r26344  
    1 import os
     1import subprocess
     2import sys
    23import time
    34from MatlabFuncs import *
     
    67    """WAITONLOCK - wait for a file
    78
    8     This routine will return when a file named 'filename' is written to disk.
    9     If the time limit given in input is exceeded, return 0
     9    This routine will return when a file named 'lockfilename' is written to
     10    disk. Also check for outlog file because it might be written several
     11    seconds after the lock file.
     12
     13    If the time limit given in input is exceeded, return 0.
    1014
    1115    Usage:
     
    1317    """
    1418
    15     #Get filename (lock file) and options
     19    # Get lockfilename (lock file) and options
    1620    executionpath = md.cluster.executionpath
    17     cluster = md.cluster.name
    1821    timelimit = md.settings.waitonlock
    19     filename = os.path.join(executionpath, md.private.runtimename, md.miscellaneous.name + '.lock')
     22    cluster = md.cluster
    2023
    21     #waitonlock will work if the lock is on the same machine only:
    22     if not strcmpi(oshostname(), cluster):
     24    """
     25    NOTE: We check cluster.name against string as cluster classes are not
     26          defined globally and we do not have to import them all
     27    """
     28    if cluster.name == 'pfe' and cluster.interactive > 1:
     29        lockfilename = '{}/Interactive{}/{}.lock'.format(executionpath, cluster.interactive, md.miscellaneous.name)
     30        logfilename = '{}/Interactive{}/{}.outlog'.format(executionpath, cluster.interactive, md.miscellaneous.name)
     31    elif cluster.name == 'localpfe':
     32        lockfilename = '{}/{}.lock'.format(executionpath, md.miscellaneous.name)
     33        logfilename = '{}/{}.outlog'.format(executionpath, md.miscellaneous.name)
     34    else:
     35        lockfilename = '{}/{}/{}.lock'.format(executionpath, md.private.runtimename, md.miscellaneous.name)
     36        logfilename = '{}/{}/{}.outlog'.format(executionpath, md.private.runtimename, md.miscellaneous.name)
    2337
    24         print('solution launched on remote cluster. log in to detect job completion.')
    25         choice = eval(input('Is the job successfully completed? (y / n) '))
    26         if not strcmp(choice, 'y'):
    27             print('Results not loaded... exiting')
    28             flag = 0
     38    # If we are using the generic cluster in interactive mode, job is already complete
     39    if (cluster.name == 'generic' and cluster.interactive) or (cluster.name == 'generic_static'):
     40        # We are in interactive mode, no need to check for job completion
     41        return 1
     42
     43    # Initialize time and file presence test flag
     44    elapsedtime = 0
     45    ispresent = 0
     46    starttime = time.time()
     47    print('waiting for {} hold on... (Ctrl+C to exit)'.format(lockfilename))
     48
     49    # Prepare command if the job is not running on the local machine
     50    if not strcmpi(oshostname(), cluster.name):
     51        login = cluster.login
     52        port = 0
     53        if isprop(cluster, 'port'):
     54            port = cluster.port
     55        if port:
     56            command = 'ssh -l {} -p {} localhost "[ -f {} ] && [ -f {} ]" 2>/dev/null'.format(login, port, lockfilename, logfilename)
     57        elif cluster.name == 'cloud':
     58            command = '[ -f {} ] && [ -f {} ] 2>/dev/null'.format(lockfilename, logfilename)
     59            command = '{} sshmaster {} --user {} \'{}\''.format(starcluster(), cluster.name, cluster.login, command)
    2960        else:
    30             flag = 1
     61            command = 'ssh -l {} {} "[ -f {} ] && [ -f {} ]" 2>/dev/null'.format(login, cluster.name, lockfilename, logfilename)
    3162
    32     #job is running on the same machine
    33     else:
    34         if 'interactive' in vars(md.cluster) and md.cluster.interactive:
    35             #We are in interactive mode, no need to check for job completion
    36             flag = 1
    37             return flag
    38         #initialize time and file presence test flag
    39         etime = 0
    40         ispresent = 0
    41         print(("waiting for '%s' hold on... (Ctrl + C to exit)" % filename))
     63    while not ispresent and elapsedtime < timelimit:
     64        if strcmpi(oshostname(), cluster.name):
     65            pause(1)
     66            ispresent = (isfile(lockfilename) and isfile(logfilename))
     67            elapsedtime = etime(time.time(), starttime) / 60
     68        else:
     69            pause(5)
     70            elapsedtime = etime(time.time(), starttime)
     71            sys.stdout.write('\rchecking for job completion (time: {} min {} sec)      '.format(floor(elapsedtime / 60), floor(rem(elapsedtime, 60)))) # TODO: After Python 2 is deprecated, we can change this call to print([...], end='')
     72            elapsedtime = elapsedtime / 60 # Converts time from sec to min
     73            subproc = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
     74            outs, errs = subproc.communicate() # NOTE: Need to consume output before checking return code
     75            if errs != '':
     76                raise Exception("waitonlock: check for existence of files failed: {}".format(errs))
     77            ispresent = not subproc.returncode
     78            if ispresent:
     79                print('')
    4280
    43         #loop till file .lock exist or time is up
    44         while ispresent == 0 and etime < timelimit:
    45             ispresent = os.path.exists(filename)
    46             time.sleep(1)
    47             etime += 1 / 60
     81    # Build output
     82    if elapsedtime > timelimit:
     83        print('Time limit exceeded. Increase md.settings.waitonlock')
     84        print('The results must be loaded manually with md = loadresultsfromcluster(md).')
     85        raise RuntimeError('waitonlock error message: time limit exceeded.')
    4886
    49         #build output
    50         if etime > timelimit:
    51             print('Time limit exceeded. Increase md.settings.waitonlock')
    52             print('The results must be loaded manually with md = loadresultsfromcluster(md).')
    53             raise RuntimeError('waitonlock error message: time limit exceeded.')
    54             flag = 0
    55         else:
    56             flag = 1
    57 
    58     return flag
     87    return ispresent
  • issm/trunk-jpl/src/wrappers/javascript/Makefile.am

    r26343 r26344  
    88
    99js_scripts = ${ISSM_DIR}/src/wrappers/BamgMesher/BamgMesher.js \
    10              ${ISSM_DIR}/src/wrappers/Triangle/Triangle.js \
     10                         ${ISSM_DIR}/src/wrappers/Triangle/Triangle.js \
    1111                         ${ISSM_DIR}/src/wrappers/NodeConnectivity/NodeConnectivity.js\
    1212                         ${ISSM_DIR}/src/wrappers/ContourToMesh/ContourToMesh.js\
Note: See TracChangeset for help on using the changeset viewer.