{"action":"created","comment":{"url":"https://api.github.com/repos/ESMCI/cime/pulls/comments/61960590","id":61960590,"diff_hunk":"@@ -1,416 +1,327 @@\n-#! /usr/bin/env perl\n-#------------------------------------------------------------------------------\n-# Batch system directives\n-#------------------------------------------------------------------------------\n+#!/usr/bin/env python2\n+\n+\"\"\"\n+template to create a case run script\n+\"\"\"\n+\n+import sys, os, calendar, shutil, time\n+\n+workdir = os.environ.get(\"PBS_O_WORKDIR\")\n+if workdir is not None:\n+    os.chdir(workdir)\n+\n+_CIMEROOT = os.environ.get(\"CIMEROOT\")\n+if _CIMEROOT is None:\n+    raise exc_type(\"ERROR: must set CIMEROOT environment variable\")\n+\n+_LIBDIR = os.path.join(_CIMEROOT, \"scripts\", \"Tools\")\n+sys.path.append(_LIBDIR)\n+\n+from standard_script_setup          import *\n+from CIME.XML.standard_module_setup import *\n+from CIME.XML.files                 import Files\n+from CIME.XML.component             import Component\n+from CIME.case                      import Case\n+from CIME.utils                     import expect, get_model, run_cmd\n+from CIME.env_module                import EnvModule\n+from CIME.utils                     import expect, get_utc_timestamp\n+from CIME.check_lockedfiles         import check_lockedfiles\n+from CIME.preview_namelists         import preview_namelists\n+\n+logger = logging.getLogger(__name__)\n+\n+# Batch system directives \n {{ batchdirectives }}\n-use strict;\n-use warnings;\n-use POSIX qw(strftime);\n-use File::Path;\n-use File::Copy;\n-use File::Spec;\n-use File::Basename;\n-use XML::LibXML;\n-use Data::Dumper;\n-use Cwd;\n-use Getopt::Long;\n-my $scriptname = $0;\n-\n-if(! -e \"./xmlquery\" and defined $ENV{'PBS_O_WORKDIR'})\n-{\n-\tchdir $ENV{'PBS_O_WORKDIR'};\n-}\n-\n-my $caseroot = `./xmlquery -value CASEROOT`;\n-my $cimeroot = `./xmlquery -value CIMEROOT`;\n-my %opts=(loglevel=>\"INFO\");\n-chdir $caseroot;\n-my $toolsdir = \"$caseroot/Tools\";\n-push(@INC, $toolsdir);\n-my $perl5lib = \"$cimeroot/utils/perl5lib\";\n-push(@INC, $perl5lib, \"$perl5lib/Config\");\n-\n-require SetupTools;\n-require Run::RunChecks;\n-require Depends::Checks;\n-require Module::ModuleLoader;\n-require Batch::BatchUtils;\n-require Log::Log4perl;\n-my $logger;\n-\n-\n-#------------------------------------------------------------------------------\n+\n # PE Layout Documentation:\n-#------------------------------------------------------------------------------\n {{ pedocumentation }}\n-# -------------------------------------------------------------------------\n-# global data needed by the script, stuff like the max number of threads,\n-# -------------------------------------------------------------------------\n-my $banner = \"*\" x 65;\n-my %config;\n-my $case;\n-my $compiler;\n-my $machine;\n-my $machroot;\n-my $mpilib;\n-my $scriptsroot;\n-my $maxthreads = 2;\n-my $LID;\n-# -------------------------------------------------------------------------\n-# Set up the run, run the model, do the postrun steps\n-# -------------------------------------------------------------------------\n-sub main\n-{\n-    getOptions();\n-    for(my $cycle=0;$cycle<$config{DATA_ASSIMILATION_CYCLES};$cycle++){\n-\tdoPreRunChecks();\n-\trunModel();\n-\tpostRun();\n-\tDoDataAssimilation($config{RUNDIR},$config{CASEROOT},$config{DATA_ASSIMILATION},\n-\t    $config{DATA_ASSIMILATION_SCRIPT},$LID,$config{LOGDIR});\n-    }\n-\n-    resubmitCheck();\n-    exit(0);\n-}\n-main(@ARGV) unless caller();\n-\n-# -------------------------------------------------------------------------\n-# Get options\n-# -------------------------------------------------------------------------\n-sub getOptions()\n-{\n-    GetOptions(\n-\t\"loglevel\" => \\$opts{'loglevel'},\n-\t);\n-\n-\n-    my $level = Log::Log4perl::Level::to_priority($opts{loglevel});\n-    Log::Log4perl->easy_init({level=>$level,\n-\t\t\t  layout=>'%m%n'});\n-\n-    $logger = Log::Log4perl::get_logger();\n-\n-\n-    # First, get the configuration from xml .\n-    %config = SetupTools::getAllResolved();\n-    $case        = $config{'CASE'};\n-    $caseroot    = $config{'CASEROOT'};\n-    $compiler    = $config{'COMPILER'};\n-    $machine     = $config{'MACH'};\n-    $machroot    = $config{'MACHDIR'};\n-    $mpilib      = $config{'MPILIB'};\n-    if($config{'RUN_WITH_SUBMIT'} eq 'FALSE' )\n-    {\n-            my $out = \"You are not calling the run script via the submit script. \";\n-\t    $out.= \"As a result, short-term archiving will not be called automatically.\";\n-            $logger->info($out);\n-    }\n-    else\n-    {\n-        `./xmlchange --noecho RUN_WITH_SUBMIT=TRUE`;\n-\t$config{RUN_WITH_SUBMIT}='TRUE';\n-    }\n-\n-}\n-\n-# -------------------------------------------------------------------------\n-# Pre run initialization code..\n-# -------------------------------------------------------------------------\n-sub doPreRunChecks()\n-{\n-    # Change to the case root\n-    chdir($config{'CASEROOT'});\n-\n-    # Update the configuration from xml .\n-    %config = SetupTools::getAllResolved();\n-    $case        = $config{'CASE'};\n-    $caseroot    = $config{'CASEROOT'};\n-    $compiler    = $config{'COMPILER'};\n-    $machine     = $config{'MACH'};\n-    $machroot    = $config{'MACHDIR'};\n-    $mpilib      = $config{'MPILIB'};\n-\n-    # Now, check for locked files.\n-    Run::RunChecks->checkLockedFiles();\n-\n-    # Now, load the module environment...\n-    # ModuleLoader for module-based systems.\n-\n-    my $moduleloader = new Module::ModuleLoader(machine  => $config{'MACH'},\n-\t\t\t\t\t\tcompiler => $config{'COMPILER'},\n-\t\t\t\t\t\tmpilib   => $config{'MPILIB'},\n-\t\t\t\t\t\tdebug    => $config{'DEBUG'},\n-\t\t\t\t\t\tcaseroot => $config{'CASEROOT'},\n-\t\t\t\t\t\tcimeroot => $config{'CIMEROOT'},\n-\t                                        model    => $config{'MODEL'});\n-\n-    $moduleloader->moduleInit();\n-    $moduleloader->findModulesForCase();\n-    $moduleloader->loadModules();\n-\n-    my $mpilib = `./xmlquery -value MPILIB`;\n-    if($mpilib =~ /mpi-serial/)\n-    {\n-        delete $ENV{'MP_MPILIB'};\n-    }\n-    else\n-    {\n-        $ENV{'MP_MPILIB'} = $mpilib;\n-    }\n-    $config{'MPILIB'} = $mpilib;\n-\n-    $logger->debug( \"build complete? $config{'BUILD_COMPLETE'}\");\n-    if($config{'BUILD_COMPLETE'} ne 'TRUE')\n-    {\n-\t$logger->logdie(\"BUILD_COMPLETE is not true\\nPlease rebuild the model interactively\");\n-    }\n-\n-    $ENV{'LBQUERY'} = \"TRUE\";\n-    if( ! defined $config{'BATCHSUBMIT'} || length $config{'BATCHSUBMIT'} == 0)\n-    {\n-\t$ENV{'LBQUERY'} = \"FALSE\";\n-\t$ENV{'BATCHQUERY'} = \"undefined\";\n-    }\n-\n-    elsif ( $config{'BATCHSUBMIT'} eq 'UNSET')\n-    {\n-\t$ENV{'LBSUBMIT'} = \"FALSE\";\n-\t$ENV{'BATCHSUBMIT'} = \"undefined\";\n-    }\n-\n-    ## Create the timing directories, optionally cleaning them if needed.\n-    if(! -d $config{'RUNDIR'})\n-    {\n-\tmkpath($config{'RUNDIR'}) or die \"could not crate $config{'RUNDIR'}, exiting\\n\";\n-    }\n-    if(-d \"$config{'RUNDIR'}/timing\")\n-    {\n-\trmtree(\"$config{'RUNDIR'}/timing\");\n-    }\n-    # Now make the timing and timing/checkpoints directories..\n-    mkpath(\"$config{'RUNDIR'}/timing/checkpoints\");\n-\n-    # Now set up the LID and sdate? strings\n-    $LID = strftime(\"%y%m%d-%H%M%S\", localtime);\n-    my $sdate = strftime(\"%Y-%m-%d %H:%M:%S\", localtime);\n-    $ENV{'LID'} = $LID;\n-    $ENV{'sdate'} = $sdate;\n-\n-    open my $CS, \">>\", \"./CaseStatus\" or die \"Could not open CaseStatus file for writing!\";\n-    print $CS \"run started $sdate\\n\";\n-    close $CS;\n-\n-    $logger->info( \"-------------------------------------------------------------------------\");\n-    $logger->info(\" BUILDNML SCRIPT STARTING\");\n-    $logger->info(\" - To prestage restarts, untar a restart.tar file into $config{'RUNDIR'}\");\n-\n-    # Run preview namelists.. should turn this into a module at some point..\n-    system(\"./preview_namelists\");\n-\n-    if($?)\n-    {\n-\t$logger->logdie(\"ERROR from preview namelist - EXITING\");\n-    }\n-\n-    $logger->info( \" BUILDNML SCRIPT HAS FINISHED SUCCESSFULLY\");\n-    $logger->info( \"-------------------------------------------------------------------------\");\n-    $logger->info( \" PRESTAGE SCRIPT STARTING\");\n-    $logger->info(\" - Case input data directory, DIN_LOC_ROOT, is $config{'DIN_LOC_ROOT'}\");\n-    $logger->info( \" - Checking the existence of input datasets in DIN_LOC_ROOT\");\n-\n-}\n-\n-# -------------------------------------------------------------------------\n-# Run the model system\n-# -------------------------------------------------------------------------\n-sub runModel()\n-{\n-    system(\"sleep 10\");\n-    my $localtime = localtime;\n-    # Set OMP_NUM_THREADS\n-    $ENV{'OMP_NUM_THREADS'} = {{ thread_count }};\n-\n-    $logger->info(\"$localtime MODEL EXECUTION BEGINS HERE\");\n-    # Run the model\n-    my $cmd = \"{{ mpirun }}\";\n-    $cmd = SetupTools::expand_xml_var($cmd, \\%config);\n \n-    chdir $config{'RUNDIR'};\n-    $logger->info(\"Running '$cmd'\\n\");\n-    system($cmd);\n+###############################################################################\n+def parse_command_line(args):\n+###############################################################################\n+\n+    CIME.utils.get_model()\n+\n+    parser = argparse.ArgumentParser()\n+\n+    CIME.utils.setup_standard_logging_options(parser)\n+\n+    args = parser.parse_args()\n+\n+    CIME.utils.handle_standard_logging_options(args)\n+\n+###############################################################################\n+def preRunCheck(case):\n+###############################################################################\n+\n+    # Pre run initialization code..\n+    model          = CIME.utils.get_model()\n+    caseroot       = case.get_value(\"CASEROOT\")\n+    cimeroot       = case.get_value(\"CIMEROOT\")\n+    din_loc_root   = case.get_value(\"DIN_LOC_ROOT\")\n+    compiler       = case.get_value(\"COMPILER\")\n+    debug          = case.get_value(\"DEBUG\")\n+    mach           = case.get_value(\"MACH\")\n+    lbquery        = case.get_value(\"LBUQERY\")\n+    batchsubmit    = case.get_value(\"BATCHSUBMIT\")\n+    mpilib         = case.get_value(\"MPILIB\")\n+    rundir         = case.get_value(\"RUNDIR\")\n+    build_complete = case.get_value(\"BUILD_COMPLETE\")\n+\n+    # check for locked files.\n+    check_lockedfiles()\n+    logger.debug(\"check_lockedfiles OK\")\n+\n+    # check that build is done\n+    expect (build_complete,\n+            \"BUILD_COMPLETE is not true\\nPlease rebuild the model interactively\")\n+    logger.debug(\"build complete is %s \" %build_complete)\n+\n+    # load the module environment...\n+    env_module = EnvModule(mach, compiler, cimeroot, caseroot, mpilib, debug)\n+    env_module.load_env_for_case()\n+\n+    # set environment variables\n+    # currently need to set mpilib as an environment variable- otherwise\n+    # the model dies at runtime \n+    # FIXME: is there a way to remove this requirement?\n+    if mpilib == \"mpi-serial\":\n+        del os.environ[\"MP_MPILIB\"]\n+    else:\n+        os.environ[\"MPILIB\"] = mpilib\n+    if batchsubmit is None or len(batchsubmit) == 0:\n+        os.environ[\"LBQUERY\"] = \"FALSE\"\n+        os.environ[\"BATCHQUERY\"] = \"undefined\"\n+    elif batchsubmit == 'UNSET':\n+        os.environ[\"LBQUERY\"] = \"FALSE\"\n+        os.environ[\"BATCHQUERY\"] = \"undefined\"\n+    else:\n+        os.environ[\"LBQUERY\"] = \"TRUE\"\n     \n-    $localtime = localtime;\n-    $logger->info( \"$localtime MODEL EXECUTION HAS FINISHED\");\n-}\n-\n-sub disposeLog\n-{\n-    my($rundir,$caseroot,$component,$lid,$logdir) = @_;\n-\n-    my $logfile = \"$component.log.$lid\";\n-\n-    my $dir = getcwd;\n-    chdir $rundir unless($dir eq $rundir);\n-\n-    if(-e $logfile){\n-\tqx(gzip $logfile);\n-\t$logfile .= \".gz\";\n-\tif(-e $logfile){\n-            copy($logfile, $logdir );\n-\t}\n-    }\n-\n-}\n-\n-\n-\n-\n-\n-# -------------------------------------------------------------------------\n-# Post-processing\n-# -------------------------------------------------------------------------\n-sub postRun()\n-{\n-    # Go back to the caseroot, pull in the configuration in case a user changed\n-    # of the variables\n-    chdir $config{'CASEROOT'};\n-    %config = SetupTools::getAllResolved();\n-    my $rundir = $config{RUNDIR};\n-    my $sdate = strftime(\"%Y-%m-%d %H:%M:%S\", localtime);\n-\n-    my $workingdir = getcwd;\n-\n-    # find the last $model.log and cpl.log\n-    my $logfile = \"$rundir/acme.log.$LID\";\n-    my $cpllogfile = \"$rundir/cpl.log.$LID\";\n-\n-    if( -z $logfile)\n-    {\n-        $logger->error( \"Model did not complete, no acme.log file present\");\n-    }\n-\n-    if(! -e $cpllogfile)\n-    {\n-        my $msg = \"Model did not complete 1 - no cpl.log file, $cpllogfile,  corresponding to most recent model log: $logfile\";\n-\n-        appendCaseStatus($msg);\n-        $logger->logdie($msg);\n-    }\n-\n-    if(-z $cpllogfile)\n-    {\n-        open (my $CS, \">>\", \"$config{'CASEROOT'}/CaseStatus\") or warn \"cannot open $config{'CASEROOT'}/CaseStatus, error was $!\";\n-        print $CS \"Run FAILED $sdate\\n\";\n-        $logger->logdie( \"Model did not complete, see $logfile\");\n-\n-    }\n-    elsif( -e  $cpllogfile)\n-    {\n-        open my $CPLLOG, \"<\", \"$cpllogfile\" or warn \"could not open $cpllogfile, $!\";\n-        my @cpllines = <$CPLLOG>;\n-        close $CPLLOG;\n-        if(@cpllines)\n-        {\n-            my @success = grep(/SUCCESSFUL TERMINATION/, @cpllines);\n-            if(@success)\n-            {\n-                appendCaseStatus(\"run SUCCESSFUL $sdate\");\n-            }\n-            else\n-            {\n-                appendCaseStatus(\"Model did not complete - see $logfile\");\n-                exit(-1);\n-            }\n-\n-        }\n-        else\n-        {\n-            appendCaseStatus(\"Model did not complete 2 - no cpl.log file, $cpllogfile,  corresponding to most recent model log: $logfile\");\n-            exit(-1);\n-        }\n-    }\n-\n-    chdir($rundir) or $logger->logdie (\"could not cd to $rundir\");\n-\n-    if(defined $config{'LOGDIR'} && (length($config{'LOGDIR'}) > 0))\n-    {\n-        if(! -e $config{'LOGDIR'})\n-        {\n-            mkpath($config{'LOGDIR'}) or $logger->warn (\"Cannot make log directory $config{'LOGDIR'}, $!\");\n-        }\n-\n-        $logger->debug(\"lid: $LID\");\n-\tforeach my $comp (qw(atm cpl ocn wav glc ice rof lnd acme)){\n-\t    disposeLog($config{RUNDIR},$config{CASEROOT}, $comp ,$LID,$config{LOGDIR});\n-\t}\n-    }\n-\n-    # Run the getTiming script if desired\n-    my $owd = getcwd();\n-    chdir $config{'CASEROOT'};\n-    if($config{'CHECK_TIMING'} eq 'TRUE')\n-    {\n-        my $timingDir = $config{'CASEROOT'} . \"/timing\";\n-        mkpath $timingDir if(! -e $timingDir);\n-        $logger->info( \"running timing script..\");\n-        system(\" $config{'CASETOOLS'}/getTiming -lid $LID \");\n-        $logger->info( \"gzipping timing stats..\");\n-        qx( gzip timing/acme_timing_stats.$LID );\n-    }\n-    chdir $owd;\n-\n-    # Save the timing files if desired\n-    if($config{'SAVE_TIMING'} eq 'TRUE')\n-    {\n-        move( \"$config{'RUNDIR'}/timing\",  \"$config{'RUNDIR'}/timing.$LID\");\n-    }\n-}\n-\n-sub appendCaseStatus\n-{\n-    my $msg = shift;\n-    open (my $CS, \">>\", \"$config{'CASEROOT'}/CaseStatus\") or warn \"cannot open $config{'CASEROOT'}/CaseStatus, $!\";\n-    print $CS \"$msg\\n\";\n-    close $CS;\n-}\n-\n-# check to see if we need to do resubmission from this particular job,\n-sub resubmitCheck()\n-{\n-#\n-# Mira requires special logic\n-#\n-    if(($config{DOUT_S} eq 'FALSE' && $config{RESUBMIT} > 0) || ($config{MACH} eq \"mira\" && $config{DOUT_S} eq \"TRUE\")) {\n-\tmy $submitscript = \"$config{'CASEROOT'}/case.submit\";\n-\tmy $cwd = getcwd;\n-\tchdir $config{'CASEROOT'};\n-\tmy $resubmitcommand = \"$submitscript -resubmit -scriptname case.\";\n-\n-\tif(defined $config{TESTCASE} && $config{TESTCASE} eq \"ERR\"){\n-\t    $resubmitcommand .= \"test\";\n-\t}else{\n-\t    $resubmitcommand .= \"run\";\n-\t}\n-\t$logger->debug( \"running resubmit check $resubmitcommand\");\n-\tsystem($resubmitcommand);\n-        if($?){ $logger->warn (\"could not run ACME submit script, $! $?\");}\n-\tchdir $cwd;\n-    }\n-}\n-\n-sub DoDataAssimilation\n-{\n-    my ($rundir, $caseroot, $da, $da_script, $lid, $logdir) = @_;\n-\n-    return unless($da eq \"TRUE\");\n-\n-    system(\" $da_script 1> da.log.$lid 2>&1\");\n-    sleep(1);\n-    $logger->logdie (\"$da_script failed\") unless ($? == 0);\n-    chdir $rundir;\n-    disposeLog($rundir,$caseroot, 'da' ,$lid,$logdir);\n-    chdir $caseroot;\n-}\n+    # create the timing directories, optionally cleaning them if needed.\n+    try:\n+        os.stat(rundir)\n+    except:\n+        os.mkdir(rundir)       \n+    if os.path.isdir(rundir + '/timing'):\n+        shutil.rmtree(rundir + '/timing')\n+    os.makedirs(rundir + '/timing/checkpoints')\n+\n+    # run preview namelists\n+    preview_namelists()\n+\n+    # document process\n+    appendCaseStatus(caseroot, \"%s Run started \\n\" %(time.strftime(\"%Y-%m-%d %H:%M:%S\")))\n+\n+    logger.info( \"-------------------------------------------------------------------------\")\n+    logger.info( \" - To prestage required restarts, untar a restart.tar file into %s\" %(rundir))\n+    logger.info( \" - Case input data directory (DIN_LOC_ROOT) is %s \" %(din_loc_root))\n+    logger.info( \" - Checking for required input datasets in DIN_LOC_ROOT\")\n+    logger.info( \"-------------------------------------------------------------------------\")\n+\n+###############################################################################\n+def runModel(case):\n+###############################################################################\n \n+    # Set OMP_NUM_THREADS\n+    num_threads = {{ thread_count }}\n+    os.environ[\"OMP_NUM_THREADS\"] = str(num_threads)\n \n+    # Run the model\n+    cmd = (\"sleep 10\")\n+    run_cmd(cmd)\n+\n+    logger.info(\"%s MODEL EXECUTION BEGINS HERE\" %(time.strftime(\"%Y-%m-%d %H:M:S\")))\n+\n+    # {{mpirun}} set the unresolved cmd string\n+    {{ mpirun }}\n+    cmd = case.get_resolved_value(cmd)\n+\n+    logger.debug(\"run command is %s \" %cmd)\n+    rundir = case.get_value(\"RUNDIR\")\n+    run_cmd(cmd, from_dir=rundir) \n+    logger.info( \"%s MODEL EXECUTION HAS FINISHED\" %(time.strftime(\"%Y-%m-%d %H:M:S\")))\n+\n+###############################################################################\n+def postRunCheck(case, lid):\n+###############################################################################\n+\n+    caseroot = case.get_value(\"CASEROOT\")\n+    rundir   = case.get_value(\"RUNDIR\")\n+    model    = case.get_value(\"MODEL\")\n+\n+    # find the last model.log and cpl.log\n+    model_logfile = os.path.join(rundir,model + \".log.\" + lid)\n+    cpl_logfile   = os.path.join(rundir,\"cpl\" + \".log.\" + lid)\n+\n+    if not os.path.isfile(model_logfile):\n+        msg = \"%s Model did not complete, no %s log file %s \\n\" %(time.strftime(\"%Y-%m-%d %H:%M:%S\"), model, model_logfile)\n+        appendCaseStatus(caseroot,msg)\n+        expect(False, msg) \n+    elif not os.path.isfile(cpl_logfile):\n+        msg = \"%s Model did not complete, no cpl log file %s \\n\" %(time.strftime(\"%Y-%m-%d %H:%M:%S\"), cpl_logfile) \n+        appendCaseStatus(caseroot, msg)\n+        expect(False, msg) \n+    elif os.stat(model_logfile).st_size == 0:\n+        msg = \" %s Run FAILED \" %time.strftime(\"%Y-%m-%d %H:%M:%S\")\n+        appendCaseStatus(caseroot, msg)\n+        expect (False, msg)\n+    else:\n+        if 'SUCCESSFUL TERMINATION' in open(cpl_logfile).read():\n+            msg = \"%s run SUCCESSFUL\" %time.strftime(\"%Y-%m-%d %H:%M:%S\")\n+            appendCaseStatus(caseroot, msg )\n+        else:\n+            msg = \"%s Model did not complete - see %s \\n \" %(time.strftime(\"%Y-%m-%d %H:%M:%S\"), cpl_logfile)\n+            appendCaseStatus(caseroot, msg)\n+            expect (False, msg)\n+\n+###############################################################################\n+def getTimings(case, lid):\n+###############################################################################\n+\n+    check_timing = case.get_value(\"CHECK_TIMING\")\n+    if check_timing:\n+        save_timing  = case.get_value(\"SAVE_TIMING\")\n+        rundir       = case.get_value(\"RUNDIR\")\n+        caseroot     = case.get_value(\"CASEROOT\")\n+        model        = case.get_value(\"MODEL\")\n+        \n+        timingDir = os.path.join(caseroot, \"timing\")\n+        if not os.path.isdir(timingDir):\n+            os.makedirs(timingDir)\n+\n+        logger.info(\"Running timing script %s \" %(os.path.join(caseroot, \"Tools/getTiming\")))\n+        cmd = \"%s -lid %s \" %(os.path.join(caseroot,\"Tools/getTiming\"), lid)\n+        run_cmd(cmd) \n+\n+        # ave the timing files if desired\n+        if save_timing:\n+            shutil.move(os.path.join(rundir,\"timing\"), \n+                        os.path.join(rundir,\"timing.\"+lid))\n+\n+        # compress relevant timing files\n+        logger.info( \"gzipping timing stats..\" )\n+        timingfile = model + \"_timing_stats.\" + lid\n+        cmd = \"gzip \" + (os.path.join(caseroot, \"timing\", timingfile))\n+        print \"DEBUG: command is \",cmd\n+        run_cmd(cmd) \n+\n+###############################################################################\n+def saveLogs(case, lid):\n+###############################################################################\n+\n+    logdir   = case.get_value(\"LOGDIR\")\n+    if logdir is not None and len(logdir) > 0:\n+        caseroot = case.get_value(\"CASEROOT\")\n+        rundir   = case.get_value(\"RUNDIR\")\n+\n+        if not os.path.isdir(logdir):\n+            os.makedirs(logdir)\n+\n+        # get components\n+        files = Files()\n+        config_file = files.get_value(\"CONFIG_DRV_FILE\")\n+        component = Component(config_file)\n+        comps = [x.lower() for x in component.get_valid_model_components()]\n+        comps = [x.replace('drv', 'cpl') for x in comps]\n+        model = [case.get_value(\"MODEL\")]\n+        comps = comps + model\n+\n+        for comp in comps:\n+            logfile = os.path.join(comp + '.log.' + lid)","path":"cime_config/acme/machines/template.case.run","position":640,"original_position":640,"commit_id":"3cf04f5bbab2be35f8c4e1bc9dfa607252ec1756","original_commit_id":"3cf04f5bbab2be35f8c4e1bc9dfa607252ec1756","user":{"login":"mvertens","id":7958803,"avatar_url":"https://avatars.githubusercontent.com/u/7958803?v=3","gravatar_id":"","url":"https://api.github.com/users/mvertens","html_url":"https://github.com/mvertens","followers_url":"https://api.github.com/users/mvertens/followers","following_url":"https://api.github.com/users/mvertens/following{/other_user}","gists_url":"https://api.github.com/users/mvertens/gists{/gist_id}","starred_url":"https://api.github.com/users/mvertens/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mvertens/subscriptions","organizations_url":"https://api.github.com/users/mvertens/orgs","repos_url":"https://api.github.com/users/mvertens/repos","events_url":"https://api.github.com/users/mvertens/events{/privacy}","received_events_url":"https://api.github.com/users/mvertens/received_events","type":"User","site_admin":false},"body":"Fixed.","created_at":"2016-05-03T21:36:52Z","updated_at":"2016-05-03T21:36:52Z","html_url":"https://github.com/ESMCI/cime/pull/152#discussion_r61960590","pull_request_url":"https://api.github.com/repos/ESMCI/cime/pulls/152","_links":{"self":{"href":"https://api.github.com/repos/ESMCI/cime/pulls/comments/61960590"},"html":{"href":"https://github.com/ESMCI/cime/pull/152#discussion_r61960590"},"pull_request":{"href":"https://api.github.com/repos/ESMCI/cime/pulls/152"}}},"pull_request":{"url":"https://api.github.com/repos/ESMCI/cime/pulls/152","id":68448672,"html_url":"https://github.com/ESMCI/cime/pull/152","diff_url":"https://github.com/ESMCI/cime/pull/152.diff","patch_url":"https://github.com/ESMCI/cime/pull/152.patch","issue_url":"https://api.github.com/repos/ESMCI/cime/issues/152","number":152,"state":"open","locked":false,"title":"Mvertens/caserun","user":{"login":"mvertens","id":7958803,"avatar_url":"https://avatars.githubusercontent.com/u/7958803?v=3","gravatar_id":"","url":"https://api.github.com/users/mvertens","html_url":"https://github.com/mvertens","followers_url":"https://api.github.com/users/mvertens/followers","following_url":"https://api.github.com/users/mvertens/following{/other_user}","gists_url":"https://api.github.com/users/mvertens/gists{/gist_id}","starred_url":"https://api.github.com/users/mvertens/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mvertens/subscriptions","organizations_url":"https://api.github.com/users/mvertens/orgs","repos_url":"https://api.github.com/users/mvertens/repos","events_url":"https://api.github.com/users/mvertens/events{/privacy}","received_events_url":"https://api.github.com/users/mvertens/received_events","type":"User","site_admin":false},"body":"pythonized machines/[template.case.run, template.st_archive and template.lt_archive] for both cesm and acme - ran regressions tests for cesm successfully - did not yet do so for acme\r\n\r\npart of #149 ","created_at":"2016-04-29T23:48:02Z","updated_at":"2016-05-03T21:36:52Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f496335b590c88c622ab363661dceac7a8e2c9a9","assignee":{"login":"jgfouca","id":7292036,"avatar_url":"https://avatars.githubusercontent.com/u/7292036?v=3","gravatar_id":"","url":"https://api.github.com/users/jgfouca","html_url":"https://github.com/jgfouca","followers_url":"https://api.github.com/users/jgfouca/followers","following_url":"https://api.github.com/users/jgfouca/following{/other_user}","gists_url":"https://api.github.com/users/jgfouca/gists{/gist_id}","starred_url":"https://api.github.com/users/jgfouca/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jgfouca/subscriptions","organizations_url":"https://api.github.com/users/jgfouca/orgs","repos_url":"https://api.github.com/users/jgfouca/repos","events_url":"https://api.github.com/users/jgfouca/events{/privacy}","received_events_url":"https://api.github.com/users/jgfouca/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/ESMCI/cime/pulls/152/commits","review_comments_url":"https://api.github.com/repos/ESMCI/cime/pulls/152/comments","review_comment_url":"https://api.github.com/repos/ESMCI/cime/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ESMCI/cime/issues/152/comments","statuses_url":"https://api.github.com/repos/ESMCI/cime/statuses/3cf04f5bbab2be35f8c4e1bc9dfa607252ec1756","head":{"label":"mvertens:mvertens/caserun","ref":"mvertens/caserun","sha":"3cf04f5bbab2be35f8c4e1bc9dfa607252ec1756","user":{"login":"mvertens","id":7958803,"avatar_url":"https://avatars.githubusercontent.com/u/7958803?v=3","gravatar_id":"","url":"https://api.github.com/users/mvertens","html_url":"https://github.com/mvertens","followers_url":"https://api.github.com/users/mvertens/followers","following_url":"https://api.github.com/users/mvertens/following{/other_user}","gists_url":"https://api.github.com/users/mvertens/gists{/gist_id}","starred_url":"https://api.github.com/users/mvertens/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mvertens/subscriptions","organizations_url":"https://api.github.com/users/mvertens/orgs","repos_url":"https://api.github.com/users/mvertens/repos","events_url":"https://api.github.com/users/mvertens/events{/privacy}","received_events_url":"https://api.github.com/users/mvertens/received_events","type":"User","site_admin":false},"repo":{"id":38934329,"name":"cime","full_name":"mvertens/cime","owner":{"login":"mvertens","id":7958803,"avatar_url":"https://avatars.githubusercontent.com/u/7958803?v=3","gravatar_id":"","url":"https://api.github.com/users/mvertens","html_url":"https://github.com/mvertens","followers_url":"https://api.github.com/users/mvertens/followers","following_url":"https://api.github.com/users/mvertens/following{/other_user}","gists_url":"https://api.github.com/users/mvertens/gists{/gist_id}","starred_url":"https://api.github.com/users/mvertens/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mvertens/subscriptions","organizations_url":"https://api.github.com/users/mvertens/orgs","repos_url":"https://api.github.com/users/mvertens/repos","events_url":"https://api.github.com/users/mvertens/events{/privacy}","received_events_url":"https://api.github.com/users/mvertens/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mvertens/cime","description":"Common Infrastructure for Modeling the Environment","fork":true,"url":"https://api.github.com/repos/mvertens/cime","forks_url":"https://api.github.com/repos/mvertens/cime/forks","keys_url":"https://api.github.com/repos/mvertens/cime/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mvertens/cime/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mvertens/cime/teams","hooks_url":"https://api.github.com/repos/mvertens/cime/hooks","issue_events_url":"https://api.github.com/repos/mvertens/cime/issues/events{/number}","events_url":"https://api.github.com/repos/mvertens/cime/events","assignees_url":"https://api.github.com/repos/mvertens/cime/assignees{/user}","branches_url":"https://api.github.com/repos/mvertens/cime/branches{/branch}","tags_url":"https://api.github.com/repos/mvertens/cime/tags","blobs_url":"https://api.github.com/repos/mvertens/cime/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mvertens/cime/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mvertens/cime/git/refs{/sha}","trees_url":"https://api.github.com/repos/mvertens/cime/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mvertens/cime/statuses/{sha}","languages_url":"https://api.github.com/repos/mvertens/cime/languages","stargazers_url":"https://api.github.com/repos/mvertens/cime/stargazers","contributors_url":"https://api.github.com/repos/mvertens/cime/contributors","subscribers_url":"https://api.github.com/repos/mvertens/cime/subscribers","subscription_url":"https://api.github.com/repos/mvertens/cime/subscription","commits_url":"https://api.github.com/repos/mvertens/cime/commits{/sha}","git_commits_url":"https://api.github.com/repos/mvertens/cime/git/commits{/sha}","comments_url":"https://api.github.com/repos/mvertens/cime/comments{/number}","issue_comment_url":"https://api.github.com/repos/mvertens/cime/issues/comments{/number}","contents_url":"https://api.github.com/repos/mvertens/cime/contents/{+path}","compare_url":"https://api.github.com/repos/mvertens/cime/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mvertens/cime/merges","archive_url":"https://api.github.com/repos/mvertens/cime/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mvertens/cime/downloads","issues_url":"https://api.github.com/repos/mvertens/cime/issues{/number}","pulls_url":"https://api.github.com/repos/mvertens/cime/pulls{/number}","milestones_url":"https://api.github.com/repos/mvertens/cime/milestones{/number}","notifications_url":"https://api.github.com/repos/mvertens/cime/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mvertens/cime/labels{/name}","releases_url":"https://api.github.com/repos/mvertens/cime/releases{/id}","deployments_url":"https://api.github.com/repos/mvertens/cime/deployments","created_at":"2015-07-11T17:27:10Z","updated_at":"2016-01-27T18:43:31Z","pushed_at":"2016-04-29T23:45:32Z","git_url":"git://github.com/mvertens/cime.git","ssh_url":"git@github.com:mvertens/cime.git","clone_url":"https://github.com/mvertens/cime.git","svn_url":"https://github.com/mvertens/cime","homepage":null,"size":19586,"stargazers_count":0,"watchers_count":0,"language":"FORTRAN","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":0,"forks":1,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"ESMCI:master","ref":"master","sha":"f0c30bc5c894d32874a2ab3c52c70947469fc6cd","user":{"login":"ESMCI","id":10676238,"avatar_url":"https://avatars.githubusercontent.com/u/10676238?v=3","gravatar_id":"","url":"https://api.github.com/users/ESMCI","html_url":"https://github.com/ESMCI","followers_url":"https://api.github.com/users/ESMCI/followers","following_url":"https://api.github.com/users/ESMCI/following{/other_user}","gists_url":"https://api.github.com/users/ESMCI/gists{/gist_id}","starred_url":"https://api.github.com/users/ESMCI/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ESMCI/subscriptions","organizations_url":"https://api.github.com/users/ESMCI/orgs","repos_url":"https://api.github.com/users/ESMCI/repos","events_url":"https://api.github.com/users/ESMCI/events{/privacy}","received_events_url":"https://api.github.com/users/ESMCI/received_events","type":"Organization","site_admin":false},"repo":{"id":31605662,"name":"cime","full_name":"ESMCI/cime","owner":{"login":"ESMCI","id":10676238,"avatar_url":"https://avatars.githubusercontent.com/u/10676238?v=3","gravatar_id":"","url":"https://api.github.com/users/ESMCI","html_url":"https://github.com/ESMCI","followers_url":"https://api.github.com/users/ESMCI/followers","following_url":"https://api.github.com/users/ESMCI/following{/other_user}","gists_url":"https://api.github.com/users/ESMCI/gists{/gist_id}","starred_url":"https://api.github.com/users/ESMCI/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ESMCI/subscriptions","organizations_url":"https://api.github.com/users/ESMCI/orgs","repos_url":"https://api.github.com/users/ESMCI/repos","events_url":"https://api.github.com/users/ESMCI/events{/privacy}","received_events_url":"https://api.github.com/users/ESMCI/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ESMCI/cime","description":"Common Infrastructure for Modeling the Earth","fork":false,"url":"https://api.github.com/repos/ESMCI/cime","forks_url":"https://api.github.com/repos/ESMCI/cime/forks","keys_url":"https://api.github.com/repos/ESMCI/cime/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ESMCI/cime/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ESMCI/cime/teams","hooks_url":"https://api.github.com/repos/ESMCI/cime/hooks","issue_events_url":"https://api.github.com/repos/ESMCI/cime/issues/events{/number}","events_url":"https://api.github.com/repos/ESMCI/cime/events","assignees_url":"https://api.github.com/repos/ESMCI/cime/assignees{/user}","branches_url":"https://api.github.com/repos/ESMCI/cime/branches{/branch}","tags_url":"https://api.github.com/repos/ESMCI/cime/tags","blobs_url":"https://api.github.com/repos/ESMCI/cime/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ESMCI/cime/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ESMCI/cime/git/refs{/sha}","trees_url":"https://api.github.com/repos/ESMCI/cime/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ESMCI/cime/statuses/{sha}","languages_url":"https://api.github.com/repos/ESMCI/cime/languages","stargazers_url":"https://api.github.com/repos/ESMCI/cime/stargazers","contributors_url":"https://api.github.com/repos/ESMCI/cime/contributors","subscribers_url":"https://api.github.com/repos/ESMCI/cime/subscribers","subscription_url":"https://api.github.com/repos/ESMCI/cime/subscription","commits_url":"https://api.github.com/repos/ESMCI/cime/commits{/sha}","git_commits_url":"https://api.github.com/repos/ESMCI/cime/git/commits{/sha}","comments_url":"https://api.github.com/repos/ESMCI/cime/comments{/number}","issue_comment_url":"https://api.github.com/repos/ESMCI/cime/issues/comments{/number}","contents_url":"https://api.github.com/repos/ESMCI/cime/contents/{+path}","compare_url":"https://api.github.com/repos/ESMCI/cime/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ESMCI/cime/merges","archive_url":"https://api.github.com/repos/ESMCI/cime/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ESMCI/cime/downloads","issues_url":"https://api.github.com/repos/ESMCI/cime/issues{/number}","pulls_url":"https://api.github.com/repos/ESMCI/cime/pulls{/number}","milestones_url":"https://api.github.com/repos/ESMCI/cime/milestones{/number}","notifications_url":"https://api.github.com/repos/ESMCI/cime/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ESMCI/cime/labels{/name}","releases_url":"https://api.github.com/repos/ESMCI/cime/releases{/id}","deployments_url":"https://api.github.com/repos/ESMCI/cime/deployments","created_at":"2015-03-03T15:33:00Z","updated_at":"2016-02-21T17:54:50Z","pushed_at":"2016-05-03T21:32:28Z","git_url":"git://github.com/ESMCI/cime.git","ssh_url":"git@github.com:ESMCI/cime.git","clone_url":"https://github.com/ESMCI/cime.git","svn_url":"https://github.com/ESMCI/cime","homepage":"","size":17562,"stargazers_count":2,"watchers_count":2,"language":"FORTRAN","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":31,"mirror_url":null,"open_issues_count":36,"forks":31,"open_issues":36,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ESMCI/cime/pulls/152"},"html":{"href":"https://github.com/ESMCI/cime/pull/152"},"issue":{"href":"https://api.github.com/repos/ESMCI/cime/issues/152"},"comments":{"href":"https://api.github.com/repos/ESMCI/cime/issues/152/comments"},"review_comments":{"href":"https://api.github.com/repos/ESMCI/cime/pulls/152/comments"},"review_comment":{"href":"https://api.github.com/repos/ESMCI/cime/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ESMCI/cime/pulls/152/commits"},"statuses":{"href":"https://api.github.com/repos/ESMCI/cime/statuses/3cf04f5bbab2be35f8c4e1bc9dfa607252ec1756"}}}}