Ignore:
Timestamp:
11/16/20 13:22:37 (4 years ago)
Author:
jdquinn
Message:

CHG: Missing changes from merge from Eric’s branch

File:
1 edited

Legend:

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

    r25499 r25758  
    1 import datetime
     1from datetime import datetime
    22import os
    33import shutil
     
    1616    Usage:
    1717        md = solve(md, solutionstring, varargin)
    18         where varargin is a list of paired arguments of string OR enums
     18   
     19    where varargin is a list of paired arguments of string OR enums
    1920
    20         solution types available comprise:
    21             - 'Stressbalance'      or 'sb'
    22             - 'Masstransport'      or 'mt'
    23             - 'Thermal'            or 'th'
    24             - 'Steadystate'        or 'ss'
    25             - 'Transient'          or 'tr'
    26             - 'Balancethickness'   or 'mc'
    27             - 'Balancevelocity'    or 'bv'
    28             - 'BedSlope'           or 'bsl'
    29             - 'SurfaceSlope'       or 'ssl'
    30             - 'Hydrology'          or 'hy'
    31             - 'DamageEvolution'    or 'da'
    32             - 'Gia'                or 'gia'
    33             - 'Esa'                or 'esa'
    34             - 'Sealevelrise'       or 'slr'
    35             - 'Love'               or 'lv'
     21    Solution types available comprise:
     22    - 'Stressbalance'      or 'sb'
     23    - 'Masstransport'      or 'mt'
     24    - 'Thermal'            or 'th'
     25    - 'Steadystate'        or 'ss'
     26    - 'Transient'          or 'tr'
     27    - 'Balancethickness'   or 'mc'
     28    - 'Balancevelocity'    or 'bv'
     29    - 'BedSlope'           or 'bsl'
     30    - 'SurfaceSlope'       or 'ssl'
     31    - 'Hydrology'          or 'hy'
     32    - 'DamageEvolution'    or 'da'
     33    - 'Gia'                or 'gia'
     34    - 'Esa'                or 'esa'
     35    - 'Sealevelrise'       or 'slr'
     36    - 'Love'               or 'lv'
    3637
    37         extra options:
    38             - loadonly          : does not solve. only load results
    39             - checkconsistency  : 'yes' or 'no' (default is 'yes'), ensures
    40                                   checks on consistency of model
    41             - restart           : 'directory name (relative to the execution
    42                                   directory) where the restart file is located
     38    Extra options:
     39    - loadonly         : does not solve. only load results
     40    - runtimename      : true or false (default is true), makes name unique
     41    - checkconsistency : 'yes' or 'no' (default is 'yes'), ensures checks on
     42                         consistency of model
     43    - restart          : directory name (relative to the execution directory)
     44                         where the restart file is located
    4345
    4446    Examples:
     
    4749    """
    4850
    49     #recover and process solve options
     51    # Recover and process solve options
    5052    if solutionstring.lower() == 'sb' or solutionstring.lower() == 'stressbalance':
    5153        solutionstring = 'StressbalanceSolution'
     
    8284    options = pairoptions('solutionstring', solutionstring, *args)
    8385
    84     #recover some fields
     86    # Recover some fields
    8587    md.private.solution = solutionstring
    8688    cluster = md.cluster
     
    9092        batch = 0
    9193
    92     #check model consistency
     94    # Check model consistency
    9395    if options.getfieldvalue('checkconsistency', 'yes') == 'yes':
    9496        if md.verbose.solution:
     
    9698        ismodelselfconsistent(md)
    9799
    98     #First, build a runtime name that is unique
     100    # First, build a runtime name that is unique
    99101    restart = options.getfieldvalue('restart', '')
    100102    if restart == 1:
    101         pass  #do nothing
     103        pass  # do nothing
    102104    else:
    103105        if restart:
     
    105107        else:
    106108            if options.getfieldvalue('runtimename', True):
    107                 c = datetime.datetime.now()
     109                c = datetime.now()
    108110                md.private.runtimename = "%s-%02i-%02i-%04i-%02i-%02i-%02i-%i" % (md.miscellaneous.name, c.month, c.day, c.year, c.hour, c.minute, c.second, os.getpid())
    109111            else:
    110112                md.private.runtimename = md.miscellaneous.name
    111113
    112     #if running qmu analysis, some preprocessing of dakota files using models
    113     #fields needs to be carried out.
     114    # If running QMU analysis, some preprocessing of Dakota files using models
     115    # fields needs to be carried out
    114116    if md.qmu.isdakota:
    115117        md = preqmu(md, options)
    116118
    117     #Do we load results only?
     119    # Do we load results only?
    118120    if options.getfieldvalue('loadonly', False):
    119121        md = loadresultsfromcluster(md)
    120122        return md
    121123
    122     #Write all input files
    123     marshall(md)  # bin file
    124     md.toolkits.ToolkitsFile(md.miscellaneous.name + '.toolkits')  # toolkits file
    125     cluster.BuildQueueScript(md.private.runtimename, md.miscellaneous.name, md.private.solution, md.settings.io_gather, md.debug.valgrind, md.debug.gprof, md.qmu.isdakota, md.transient.isoceancoupling)  # queue file
     124    # Write all input files
     125    marshall(md) # bin file
     126    md.toolkits.ToolkitsFile(md.miscellaneous.name + '.toolkits') # toolkits file
     127    cluster.BuildQueueScript(md.private.runtimename, md.miscellaneous.name, md.private.solution, md.settings.io_gather, md.debug.valgrind, md.debug.gprof, md.qmu.isdakota, md.transient.isoceancoupling) # queue file
    126128
    127     #Stop here if batch mode
     129    # Stop here if batch mode
    128130    if options.getfieldvalue('batch', 'no') == 'yes':
    129131        print('batch mode requested: not launching job interactively')
     
    131133        return md
    132134
    133     #Upload all required files:
     135    # Upload all required files:
    134136    modelname = md.miscellaneous.name
    135137    filelist = [modelname + '.bin ', modelname + '.toolkits ', modelname + '.queue ']
     
    140142        cluster.UploadQueueJob(md.miscellaneous.name, md.private.runtimename, filelist)
    141143
    142     #Launch job
     144    # Launch job
    143145    cluster.LaunchQueueJob(md.miscellaneous.name, md.private.runtimename, filelist, restart, batch)
    144146
    145     #wait on lock
     147    # Wait on lock
    146148    if md.settings.waitonlock > 0:
    147         #we wait for the done file
    148149        islock = waitonlock(md)
    149         if islock == 0:  #no results to be loaded
     150        if islock == 0:  # no results to be loaded
    150151            print('The results must be loaded manually with md = loadresultsfromcluster(md).')
    151         else:  #load results
     152        else:  # load results
    152153            if md.verbose.solution:
    153154                print('loading results from cluster')
    154155            md = loadresultsfromcluster(md)
     156
    155157    return md
Note: See TracChangeset for help on using the changeset viewer.