source: issm/oecreview/Archive/14312-15392/ISSM-14871-14872.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: 3.0 KB
  • ../trunk-jpl/src/m/solve/solve.py

     
    1 import datetime
    2 import os
    3 import shutil
    4 from pairoptions import *
    5 from process_solve_options import *
    6 from EnumDefinitions import *
    7 from EnumToString import EnumToString
    8 from ismodelselfconsistent import *
    9 from marshall import *
    10 from ispetsc import *
    11 from waitonlock import *
    12 from loadresultsfromcluster import *
    13 
    14 def solve(md,solutionenum,*args):
    15         """
    16         SOLVE - apply solution sequence for this model
    17  
    18            Usage:
    19               md=solve(md,solutionenum,varargin)
    20               where varargin is a list of paired arguments of string OR enums
    21  
    22            solution types available comprise:
    23               - DiagnosticSolutionEnum
    24               - PrognosticSolutionEnum
    25               - ThermalSolutionEnum
    26               - SteadystateSolutionEnum
    27               - TransientSolutionEnum...
    28               - BalancethicknessSolutionEnum
    29               - BedSlopeSolutionEnum
    30               - SurfaceSlopeSolutionEnum
    31               - HydrologySolutionEnum
    32               - FlaimSolutionEnum
    33  
    34            extra options:
    35               - loadonly : does not solve. only load results
    36  
    37            Examples:
    38               md=solve(md,DiagnosticSolutionEnum);
    39         """
    40 
    41         #recover and process solve options
    42         options=pairoptions('solution_type',solutionenum,*args)
    43         options=process_solve_options(options)
    44 
    45         #recover some fields
    46         md.private.solution=options['solution_type']
    47         cluster=md.cluster
    48 
    49         #check model consistency
    50         print "checking model consistency"
    51         if solutionenum == FlaimSolutionEnum():
    52                 md.private.isconsistent=True
    53                 md.mesh.checkconsistency(md,solutionenum)
    54                 md.flaim.checkconsistency(md,solutionenum)
    55                 if not md.private.isconsistent:
    56                         raise RuntimeError("Model not consistent, see messages above.")
    57         else:
    58                 ismodelselfconsistent(md)
    59 
    60         #First, build a runtime name that is unique
    61         c=datetime.datetime.now()
    62         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())
    63 
    64         #if running qmu analysis, some preprocessing of dakota files using models
    65         #fields needs to be carried out.
    66         if md.qmu.isdakota:
    67                 md=preqmu(md,options)
    68 
    69         #flaim analysis
    701        if options['solution_type'] == FlaimSolutionEnum():
    712                md=flaim_sol(md,options)
    723                [md.private.solution]=EnumToString(options['solution_type'])
     
    8213        md.toolkits.ToolkitsFile(md.miscellaneous.name+'.toolkits')    # toolkits file
    8314        cluster.BuildQueueScript(md.private.runtimename,md.miscellaneous.name,md.private.solution,md.settings.io_gather,md.debug.valgrind,md.debug.gprof)    # queue file
    8415
    85         #we need to make sure we have PETSC support, otherwise, we run with only one cpu:
    86         if not ispetsc():
    87                 print "PETSC support not included, running on 1 cpu only!"
    88                 cluster.np=1
    89 
    9016        #Stop here if batch mode
    9117        if strcmpi(options['batch'],'yes'):
    9218                print 'batch mode requested: not launching job interactively'
Note: See TracBrowser for help on using the repository browser.