예제 #1
0
파일: case_run.py 프로젝트: ziu1986/cime
def case_run(self, skip_pnl=False, set_continue_run=False, submit_resubmits=False):
###############################################################################
    # Set up the run, run the model, do the postrun steps
    prerun_script = self.get_value("PRERUN_SCRIPT")
    postrun_script = self.get_value("POSTRUN_SCRIPT")

    data_assimilation_cycles = self.get_value("DATA_ASSIMILATION_CYCLES")
    data_assimilation_script = self.get_value("DATA_ASSIMILATION_SCRIPT")
    data_assimilation = (data_assimilation_cycles > 0 and
                         len(data_assimilation_script) > 0 and
                         os.path.isfile(data_assimilation_script))
    # set up the LID
    lid = new_lid()

    if prerun_script:
        self.flush()
        _do_external(prerun_script, self.get_value("CASEROOT"), self.get_value("RUNDIR"),
                    lid, prefix="prerun")
        self.read_xml()

    for cycle in range(data_assimilation_cycles):
        # After the first DA cycle, runs are restart runs
        if cycle > 0:
            lid = new_lid()
            self.set_value("CONTINUE_RUN",
                           self.get_value("RESUBMIT_SETS_CONTINUE_RUN"))

        lid = _run_model(self, lid, skip_pnl, da_cycle=cycle)

        if self.get_value("CHECK_TIMING") or self.get_value("SAVE_TIMING"):
            get_timing(self, lid)     # Run the getTiming script

        if data_assimilation:
            self.flush()
            _do_data_assimilation(data_assimilation_script, self.get_value("CASEROOT"), cycle, lid,
                                 self.get_value("RUNDIR"))
            self.read_xml()
        _save_logs(self, lid)
        save_postrun_provenance(self)

    if postrun_script:
        self.flush()
        _do_external(postrun_script, self.get_value("CASEROOT"), self.get_value("RUNDIR"),
                    lid, prefix="postrun")
        self.read_xml()
        _save_logs(self, lid)

    if set_continue_run:
        self.set_value("CONTINUE_RUN",
                       self.get_value("RESUBMIT_SETS_CONTINUE_RUN"))

    logger.warning("check for resubmit")
    if submit_resubmits:
        _resubmit_check(self)

    return True
예제 #2
0
파일: case_run.py 프로젝트: Katetc/cime
def case_run(case, skip_pnl=False):
###############################################################################
    # Set up the run, run the model, do the postrun steps
    prerun_script = case.get_value("PRERUN_SCRIPT")
    postrun_script = case.get_value("POSTRUN_SCRIPT")

    data_assimilation_cycles = case.get_value("DATA_ASSIMILATION_CYCLES")
    data_assimilation_script = case.get_value("DATA_ASSIMILATION_SCRIPT")
    data_assimilation = (data_assimilation_cycles > 0 and
                         len(data_assimilation_script) > 0 and
                         os.path.isfile(data_assimilation_script))
    # set up the LID
    lid = new_lid()

    if prerun_script:
        case.flush()
        do_external(prerun_script, case.get_value("CASEROOT"), case.get_value("RUNDIR"),
                    lid, prefix="prerun")
        case.read_xml()

    for cycle in range(data_assimilation_cycles):
        # After the first DA cycle, runs are restart runs
        if cycle > 0:
            lid = new_lid()
            case.set_value("CONTINUE_RUN",
                           case.get_value("RESUBMIT_SETS_CONTINUE_RUN"))

        lid = run_model(case, lid, skip_pnl, da_cycle=cycle)

        if case.get_value("CHECK_TIMING") or case.get_value("SAVE_TIMING"):
            get_timing(case, lid)     # Run the getTiming script

        if data_assimilation:
            case.flush()
            do_data_assimilation(data_assimilation_script, case.get_value("CASEROOT"), cycle, lid,
                                 case.get_value("RUNDIR"))
            case.read_xml()

        save_logs(case, lid)       # Copy log files back to caseroot

        save_postrun_provenance(case)

    if postrun_script:
        case.flush()
        do_external(postrun_script, case.get_value("CASEROOT"), case.get_value("RUNDIR"),
                    lid, prefix="postrun")
        case.read_xml()

    save_logs(case, lid)       # Copy log files back to caseroot

    logger.warning("check for resubmit")
    resubmit_check(case)

    return True
예제 #3
0
파일: case_run.py 프로젝트: mnlevy1981/cime
def case_run(case):
###############################################################################
    # Set up the run, run the model, do the postrun steps
    run_with_submit = case.get_value("RUN_WITH_SUBMIT")
    expect(run_with_submit,
           "You are not calling the run script via the submit script. "
           "As a result, short-term archiving will not be called automatically."
           "Please submit your run using the submit script like so:"
           " ./case.submit")

    data_assimilation = case.get_value("DATA_ASSIMILATION")
    data_assimilation_cycles = case.get_value("DATA_ASSIMILATION_CYCLES")
    data_assimilation_script = case.get_value("DATA_ASSIMILATION_SCRIPT")

    # set up the LID
    lid = new_lid()

    save_prerun_provenance(case)

    for cycle in range(data_assimilation_cycles):
        # After the first DA cycle, runs are restart runs
        if cycle > 0:
            case.set_value("CONTINUE_RUN", "TRUE")
            lid = new_lid()

        pre_run_check(case)
        run_model(case)
        post_run_check(case, lid)
        save_logs(case, lid)       # Copy log files back to caseroot
        if case.get_value("CHECK_TIMING") or case.get_value("SAVE_TIMING"):
            get_timing(case, lid)     # Run the getTiming script

        if data_assimilation:
            do_data_assimilation(data_assimilation_script, cycle, data_assimilation_cycles, lid)

        save_postrun_provenance(case)

    logger.warn("check for resubmit")
    resubmit_check(case)

    return True
예제 #4
0
파일: case_run.py 프로젝트: ekluzek/cime
def case_run(case):
###############################################################################
    # Set up the run, run the model, do the postrun steps
    run_with_submit = case.get_value("RUN_WITH_SUBMIT")
    expect (run_with_submit,
            "You are not calling the run script via the submit script. "
            "As a result, short-term archiving will not be called automatically."
            "Please submit your run using the submit script like so:"
            " ./case.submit")

    data_assimilation = case.get_value("DATA_ASSIMILATION")
    data_assimilation_cycles = case.get_value("DATA_ASSIMILATION_CYCLES")
    data_assimilation_script = case.get_value("DATA_ASSIMILATION_SCRIPT")

    # set up the LID
    lid = time.strftime("%y%m%d-%H%M%S")
    os.environ["LID"] = lid

    save_prerun_provenance(case)

    for _ in range(data_assimilation_cycles):
        pre_run_check(case)
        run_model(case)
        post_run_check(case, lid)
        save_logs(case, lid)       # Copy log files back to caseroot
        if case.get_value("CHECK_TIMING") or case.get_value("SAVE_TIMING"):
            get_timing(case, lid)     # Run the getTiming script

        if data_assimilation:
            do_data_assimilation(data_assimilation_script, lid)

        save_postrun_provenance(case)

    logger.warn("check for resubmit")
    resubmit_check(case)

    return True
예제 #5
0
def case_run(self,
             skip_pnl=False,
             set_continue_run=False,
             submit_resubmits=False):
    ###############################################################################
    model_log(
        "e3sm", logger,
        "{} CASE.RUN BEGINS HERE".format(time.strftime("%Y-%m-%d %H:%M:%S")))
    # Set up the run, run the model, do the postrun steps

    # set up the LID
    lid = new_lid()

    prerun_script = self.get_value("PRERUN_SCRIPT")
    if prerun_script:
        model_log(
            "e3sm", logger, "{} PRERUN_SCRIPT BEGINS HERE".format(
                time.strftime("%Y-%m-%d %H:%M:%S")))
        self.flush()
        _do_external(prerun_script,
                     self.get_value("CASEROOT"),
                     self.get_value("RUNDIR"),
                     lid,
                     prefix="prerun")
        self.read_xml()
        model_log(
            "e3sm", logger, "{} PRERUN_SCRIPT HAS FINISHED".format(
                time.strftime("%Y-%m-%d %H:%M:%S")))

    # We might need to tweak these if we want to allow the user to change them
    data_assimilation_cycles = self.get_value("DATA_ASSIMILATION_CYCLES")
    data_assimilation_script = self.get_value("DATA_ASSIMILATION_SCRIPT")
    data_assimilation = (data_assimilation_cycles > 0
                         and len(data_assimilation_script) > 0
                         and os.path.isfile(data_assimilation_script))

    for cycle in range(data_assimilation_cycles):
        # After the first DA cycle, runs are restart runs
        if cycle > 0:
            lid = new_lid()
            self.set_value("CONTINUE_RUN",
                           self.get_value("RESUBMIT_SETS_CONTINUE_RUN"))

        # WARNING: All case variables are reloaded during run_model to get
        # new values of any variables that may have been changed by
        # the user during model execution. Thus, any local variables
        # set from case variables before this point may be
        # inconsistent with their latest values in the xml files, so
        # should generally be reloaded (via case.get_value(XXX)) if they are still needed.
        model_log(
            "e3sm", logger, "{} RUN_MODEL BEGINS HERE".format(
                time.strftime("%Y-%m-%d %H:%M:%S")))
        lid = _run_model(self, lid, skip_pnl, da_cycle=cycle)
        model_log(
            "e3sm", logger, "{} RUN_MODEL HAS FINISHED".format(
                time.strftime("%Y-%m-%d %H:%M:%S")))

        if self.get_value("CHECK_TIMING") or self.get_value("SAVE_TIMING"):
            model_log(
                "e3sm", logger, "{} GET_TIMING BEGINS HERE".format(
                    time.strftime("%Y-%m-%d %H:%M:%S")))
            get_timing(self, lid)  # Run the getTiming script
            model_log(
                "e3sm", logger, "{} GET_TIMING HAS FINISHED".format(
                    time.strftime("%Y-%m-%d %H:%M:%S")))

        if data_assimilation:
            model_log(
                "e3sm", logger, "{} DO_DATA_ASSIMILATION BEGINS HERE".format(
                    time.strftime("%Y-%m-%d %H:%M:%S")))
            self.flush()
            _do_data_assimilation(data_assimilation_script,
                                  self.get_value("CASEROOT"), cycle, lid,
                                  self.get_value("RUNDIR"))
            self.read_xml()
            model_log(
                "e3sm", logger, "{} DO_DATA_ASSIMILATION HAS FINISHED".format(
                    time.strftime("%Y-%m-%d %H:%M:%S")))

        _save_logs(self, lid)  # Copy log files back to caseroot

        model_log(
            "e3sm", logger, "{} SAVE_POSTRUN_PROVENANCE BEGINS HERE".format(
                time.strftime("%Y-%m-%d %H:%M:%S")))
        save_postrun_provenance(self)
        model_log(
            "e3sm", logger, "{} SAVE_POSTRUN_PROVENANCE HAS FINISHED".format(
                time.strftime("%Y-%m-%d %H:%M:%S")))

    postrun_script = self.get_value("POSTRUN_SCRIPT")
    if postrun_script:
        model_log(
            "e3sm", logger, "{} POSTRUN_SCRIPT BEGINS HERE".format(
                time.strftime("%Y-%m-%d %H:%M:%S")))
        self.flush()
        _do_external(postrun_script,
                     self.get_value("CASEROOT"),
                     self.get_value("RUNDIR"),
                     lid,
                     prefix="postrun")
        self.read_xml()
        _save_logs(self, lid)
        model_log(
            "e3sm", logger, "{} POSTRUN_SCRIPT HAS FINISHED".format(
                time.strftime("%Y-%m-%d %H:%M:%S")))

    if set_continue_run:
        self.set_value("CONTINUE_RUN",
                       self.get_value("RESUBMIT_SETS_CONTINUE_RUN"))

    external_workflow = self.get_value("EXTERNAL_WORKFLOW")
    if not external_workflow:
        logger.warning("check for resubmit")

        logger.debug("submit_resubmits is {}".format(submit_resubmits))
        if submit_resubmits:
            _resubmit_check(self)

    model_log(
        "e3sm", logger,
        "{} CASE.RUN HAS FINISHED".format(time.strftime("%Y-%m-%d %H:%M:%S")))
    return True
예제 #6
0
def case_run(self, skip_pnl=False, set_continue_run=False, submit_resubmits=False):
###############################################################################
    model_log("e3sm", logger, "{} CASE.RUN BEGINS HERE".format(time.strftime("%Y-%m-%d %H:%M:%S")))
    # Set up the run, run the model, do the postrun steps
    prerun_script = self.get_value("PRERUN_SCRIPT")
    postrun_script = self.get_value("POSTRUN_SCRIPT")

    data_assimilation_cycles = self.get_value("DATA_ASSIMILATION_CYCLES")
    data_assimilation_script = self.get_value("DATA_ASSIMILATION_SCRIPT")
    data_assimilation = (data_assimilation_cycles > 0 and
                         len(data_assimilation_script) > 0 and
                         os.path.isfile(data_assimilation_script))


    # set up the LID
    lid = new_lid()

    if prerun_script:
        model_log("e3sm", logger, "{} PRERUN_SCRIPT BEGINS HERE".format(time.strftime("%Y-%m-%d %H:%M:%S")))
        self.flush()
        _do_external(prerun_script, self.get_value("CASEROOT"), self.get_value("RUNDIR"),
                    lid, prefix="prerun")
        self.read_xml()
        model_log("e3sm", logger, "{} PRERUN_SCRIPT HAS FINISHED".format(time.strftime("%Y-%m-%d %H:%M:%S")))

    for cycle in range(data_assimilation_cycles):
        # After the first DA cycle, runs are restart runs
        if cycle > 0:
            lid = new_lid()
            self.set_value("CONTINUE_RUN",
                           self.get_value("RESUBMIT_SETS_CONTINUE_RUN"))

        model_log("e3sm", logger, "{} RUN_MODEL BEGINS HERE".format(time.strftime("%Y-%m-%d %H:%M:%S")))
        lid = _run_model(self, lid, skip_pnl, da_cycle=cycle)
        model_log("e3sm", logger, "{} RUN_MODEL HAS FINISHED".format(time.strftime("%Y-%m-%d %H:%M:%S")))
        if self.get_value("CHECK_TIMING") or self.get_value("SAVE_TIMING"):
            model_log("e3sm", logger, "{} GET_TIMING BEGINS HERE".format(time.strftime("%Y-%m-%d %H:%M:%S")))
            get_timing(self, lid)     # Run the getTiming script
            model_log("e3sm", logger, "{} GET_TIMING HAS FINISHED".format(time.strftime("%Y-%m-%d %H:%M:%S")))


        if data_assimilation:
            model_log("e3sm", logger, "{} DO_DATA_ASSIMILATION BEGINS HERE".format(time.strftime("%Y-%m-%d %H:%M:%S")))
            self.flush()
            _do_data_assimilation(data_assimilation_script, self.get_value("CASEROOT"), cycle, lid,
                                 self.get_value("RUNDIR"))
            self.read_xml()
            model_log("e3sm", logger, "{} DO_DATA_ASSIMILATION HAS FINISHED".format(time.strftime("%Y-%m-%d %H:%M:%S")))

        _save_logs(self, lid)       # Copy log files back to caseroot

        model_log("e3sm", logger, "{} SAVE_POSTRUN_PROVENANCE BEGINS HERE".format(time.strftime("%Y-%m-%d %H:%M:%S")))
        save_postrun_provenance(self)
        model_log("e3sm", logger, "{} SAVE_POSTRUN_PROVENANCE HAS FINISHED".format(time.strftime("%Y-%m-%d %H:%M:%S")))

    if postrun_script:
        model_log("e3sm", logger, "{} POSTRUN_SCRIPT BEGINS HERE".format(time.strftime("%Y-%m-%d %H:%M:%S")))
        self.flush()
        _do_external(postrun_script, self.get_value("CASEROOT"), self.get_value("RUNDIR"),
                    lid, prefix="postrun")
        self.read_xml()
        _save_logs(self, lid)
        model_log("e3sm", logger, "{} POSTRUN_SCRIPT HAS FINISHED".format(time.strftime("%Y-%m-%d %H:%M:%S")))

    if set_continue_run:
        self.set_value("CONTINUE_RUN",
                       self.get_value("RESUBMIT_SETS_CONTINUE_RUN"))

    logger.warning("check for resubmit")
    if submit_resubmits:
        _resubmit_check(self)

    model_log("e3sm", logger, "{} CASE.RUN HAS FINISHED".format(time.strftime("%Y-%m-%d %H:%M:%S")))

    return True
예제 #7
0
파일: case_run.py 프로젝트: srinathv/cime
def case_run(self, skip_pnl=False, set_continue_run=False, submit_resubmits=False):
###############################################################################
    logger.debug("{} CASE.RUN BEGINS HERE".format(time.strftime("%Y-%m-%d %H:%M:%S")))
    # Set up the run, run the model, do the postrun steps
    prerun_script = self.get_value("PRERUN_SCRIPT")
    postrun_script = self.get_value("POSTRUN_SCRIPT")
    driver = self.get_value("COMP_INTERFACE")

    data_assimilation_cycles = self.get_value("DATA_ASSIMILATION_CYCLES")
    data_assimilation_script = self.get_value("DATA_ASSIMILATION_SCRIPT")
    data_assimilation = (data_assimilation_cycles > 0 and
                         len(data_assimilation_script) > 0 and
                         os.path.isfile(data_assimilation_script))

    driver = self.get_value("COMP_INTERFACE")

    # set up the LID
    lid = new_lid()

    if prerun_script:
        logger.debug("{} PRERUN_SCRIPT BEGINS HERE".format(time.strftime("%Y-%m-%d %H:%M:%S")))
        self.flush()
        _do_external(prerun_script, self.get_value("CASEROOT"), self.get_value("RUNDIR"),
                    lid, prefix="prerun")
        self.read_xml()
        logger.debug("{} PRERUN_SCRIPT HAS FINISHED".format(time.strftime("%Y-%m-%d %H:%M:%S")))

    for cycle in range(data_assimilation_cycles):
        # After the first DA cycle, runs are restart runs
        if cycle > 0:
            lid = new_lid()
            self.set_value("CONTINUE_RUN",
                           self.get_value("RESUBMIT_SETS_CONTINUE_RUN"))

        logger.debug("{} RUN_MODEL BEGINS HERE".format(time.strftime("%Y-%m-%d %H:%M:%S")))
        lid = _run_model(self, lid, skip_pnl, da_cycle=cycle)
        logger.debug("{} RUN_MODEL HAS FINISHED".format(time.strftime("%Y-%m-%d %H:%M:%S")))

        # TODO mvertens: remove the hard-wiring for nuopc below
        if driver != 'nuopc':
            if self.get_value("CHECK_TIMING") or self.get_value("SAVE_TIMING"):
                logger.debug("{} GET_TIMING BEGINS HERE".format(time.strftime("%Y-%m-%d %H:%M:%S")))
                get_timing(self, lid)     # Run the getTiming script
                logger.debug("{} GET_TIMING HAS FINISHED".format(time.strftime("%Y-%m-%d %H:%M:%S")))
        else:
            self.set_value("CHECK_TIMING",False)

        if data_assimilation:
            logger.debug("{} DO_DATA_ASSIMILATION BEGINS HERE".format(time.strftime("%Y-%m-%d %H:%M:%S")))
            self.flush()
            _do_data_assimilation(data_assimilation_script, self.get_value("CASEROOT"), cycle, lid,
                                 self.get_value("RUNDIR"))
            self.read_xml()
            logger.debug("{} DO_DATA_ASSIMILATION HAS FINISHED".format(time.strftime("%Y-%m-%d %H:%M:%S")))

        _save_logs(self, lid)       # Copy log files back to caseroot

        logger.debug("{} SAVE_POSTRUN_PROVENANCE BEGINS HERE".format(time.strftime("%Y-%m-%d %H:%M:%S")))
        save_postrun_provenance(self)
        logger.debug("{} SAVE_POSTRUN_PROVENANCE HAS FINISHED".format(time.strftime("%Y-%m-%d %H:%M:%S")))

    if postrun_script:
        logger.debug("{} POSTRUN_SCRIPT BEGINS HERE".format(time.strftime("%Y-%m-%d %H:%M:%S")))
        self.flush()
        _do_external(postrun_script, self.get_value("CASEROOT"), self.get_value("RUNDIR"),
                    lid, prefix="postrun")
        self.read_xml()
        _save_logs(self, lid)
        logger.debug("{} POSTRUN_SCRIPT HAS FINISHED".format(time.strftime("%Y-%m-%d %H:%M:%S")))

    if set_continue_run:
        self.set_value("CONTINUE_RUN",
                       self.get_value("RESUBMIT_SETS_CONTINUE_RUN"))

    logger.warning("check for resubmit")
    if submit_resubmits:
        _resubmit_check(self)

    logger.debug("{} CASE.RUN HAS FINISHED".format(time.strftime("%Y-%m-%d %H:%M:%S")))

    return True
예제 #8
0
파일: case_run.py 프로젝트: apcraig/cime
def case_run(case, skip_pnl=False):
###############################################################################
    # Set up the run, run the model, do the postrun steps
    run_with_submit = case.get_value("RUN_WITH_SUBMIT")
    expect(run_with_submit,
           "You are not calling the run script via the submit script. "
           "As a result, short-term archiving will not be called automatically."
           "Please submit your run using the submit script like so:"
           " ./case.submit Time: {}".format(get_timestamp()))

    # Forces user to use case.submit if they re-submit
    if case.get_value("TESTCASE") is None:
        case.set_value("RUN_WITH_SUBMIT", False)

    prerun_script = case.get_value("PRERUN_SCRIPT")
    postrun_script = case.get_value("POSTRUN_SCRIPT")

    data_assimilation = case.get_value("DATA_ASSIMILATION")
    data_assimilation_cycles = case.get_value("DATA_ASSIMILATION_CYCLES")
    data_assimilation_script = case.get_value("DATA_ASSIMILATION_SCRIPT")

    # set up the LID
    lid = new_lid()

    save_prerun_provenance(case)

    for cycle in range(data_assimilation_cycles):
        # After the first DA cycle, runs are restart runs
        if cycle > 0:
            case.set_value("CONTINUE_RUN", "TRUE")
            lid = new_lid()

        if prerun_script:
            case.flush()
            do_external(prerun_script, case.get_value("CASEROOT"), case.get_value("RUNDIR"),
                        lid, prefix="prerun")
            case.read_xml()

        lid = run_model(case, lid, skip_pnl, da_cycle=cycle)
        save_logs(case, lid)       # Copy log files back to caseroot
        if case.get_value("CHECK_TIMING") or case.get_value("SAVE_TIMING"):
            get_timing(case, lid)     # Run the getTiming script

        if data_assimilation:
            case.flush()
            do_data_assimilation(data_assimilation_script, case.get_value("CASEROOT"), cycle, lid,
                                 case.get_value("RUNDIR"))
            case.read_xml()

        if postrun_script:
            case.flush()
            do_external(postrun_script, case.get_value("CASEROOT"), case.get_value("RUNDIR"),
                        lid, prefix="postrun")
            case.read_xml()

        save_postrun_provenance(case)

    logger.warning("check for resubmit")
    resubmit_check(case)

    return True