Ejemplo n.º 1
0
def main():
    """Main function called when download_input_data is run from the command-line
    """
    setup_logging_pre_config()
    args = _commandline_args()
    process_logging_args(args)

    download_input_data(rundir=args.rundir)
Ejemplo n.º 2
0
def main():
    """
    Calls functions that subset surface, landuse, domain, and/or DATM files for a region or a
    single point.
    """

    # --------------------------------- #
    # add logging flags from ctsm_logging
    setup_logging_pre_config()
    parser = get_parser()
    args = parser.parse_args()

    # --------------------------------- #
    # print help and exit when no option is chosen
    if args.run_type != "point" and args.run_type != "region":
        err_msg = textwrap.dedent('''\
                \n ------------------------------------
                \n Must supply a positional argument: 'point' or 'region'.
                ''')
        raise parser.error(err_msg)

    if not any([
            args.create_surfdata, args.create_domain, args.create_landuse,
            args.create_datm
    ]):
        err_msg = textwrap.dedent('''\
                \n ------------------------------------
                \n Must supply one of:
                \n --create-surface \n --create-landuse \n --create-datm \n --create-domain \n
                ''')
        raise parser.error(err_msg)

    # --------------------------------- #
    # process logging args (i.e. debug and verbose)
    process_logging_args(args)

    # --------------------------------- #
    # parse defaults file
    cesmroot = path_to_ctsm_root()
    defaults = configparser.ConfigParser()
    defaults.read(
        os.path.join(cesmroot, "tools/site_and_regional", DEFAULTS_FILE))

    # --------------------------------- #
    myname = getuser()
    pwd = os.getcwd()
    logger.info("User = %s", myname)
    logger.info("Current directory = %s", pwd)

    # --------------------------------- #
    # create files and folders necessary and return dictionary of file/folder locations
    file_dict = setup_files(args, defaults, cesmroot)

    if args.run_type == "point":
        subset_point(args, file_dict)
    elif args.run_type == "region":
        subset_region(args, file_dict)
Ejemplo n.º 3
0
def main(cime_path):
    """Main function

    Args:
    cime_path (str): path to the cime that we're using (this is passed in explicitly
        rather than relying on calling path_to_cime so that we can be absolutely sure that
        the scripts called here are coming from the same cime as the cime library we're
        using).
    """
    setup_logging_pre_config()
    args = parse_command_line()
    process_logging_args(args)

    buildnml(cime_path=cime_path, rundir=args.rundir)
Ejemplo n.º 4
0
def main(cime_path):
    """Main function called when run_sys_tests is run from the command-line

    Args:
    cime_path (str): path to the cime that we're using (this is passed in explicitly
        rather than relying on calling path_to_cime so that we can be absolutely sure that
        the scripts called here are coming from the same cime as the cime library we're
        using).
    """
    setup_logging_pre_config()
    args = _commandline_args()
    process_logging_args(args)
    logger.info('Running on machine: %s', args.machine_name)
    if args.job_launcher_nobatch:
        job_launcher_type = JOB_LAUNCHER_NOBATCH
    else:
        job_launcher_type = None
    machine = create_machine(
        machine_name=args.machine_name,
        job_launcher_type=job_launcher_type,
        defaults=MACHINE_DEFAULTS,
        account=args.account,
        job_launcher_queue=args.job_launcher_queue,
        job_launcher_walltime=args.job_launcher_walltime,
        job_launcher_nice_level=_NICE_LEVEL,
        job_launcher_extra_args=args.job_launcher_extra_args)
    logger.debug("Machine info: %s", machine)

    run_sys_tests(machine=machine,
                  cime_path=cime_path,
                  skip_testroot_creation=args.skip_testroot_creation,
                  skip_git_status=args.skip_git_status,
                  dry_run=args.dry_run,
                  suite_name=args.suite_name,
                  testfile=args.testfile,
                  testlist=args.testname,
                  suite_compilers=args.suite_compiler,
                  testid_base=args.testid_base,
                  testroot_base=args.testroot_base,
                  rerun_existing_failures=args.rerun_existing_failures,
                  compare_name=args.compare,
                  generate_name=args.generate,
                  baseline_root=args.baseline_root,
                  walltime=args.walltime,
                  queue=args.queue,
                  retry=args.retry,
                  extra_create_test_args=args.extra_create_test_args)
Ejemplo n.º 5
0
def main ():
    """
    Description
    -----------
    Calls function that modifies an fsurdat (surface dataset)
    """

    # set up logging allowing user control
    setup_logging_pre_config()

    # read the command line argument to obtain the path to the .cfg file
    parser = argparse.ArgumentParser()
    parser.add_argument('cfg_path',
                        help='/path/name.cfg of input file, eg ./modify.cfg')
    add_logging_args(parser)
    args = parser.parse_args()
    process_logging_args(args)
    fsurdat_modifier(args.cfg_path)
Ejemplo n.º 6
0
def main():
    """
    Main function for gen_mksurf_namelist.
    """
    # -- add logging flags from ctsm_logging
    setup_logging_pre_config()
    parser = get_parser()
    add_logging_args(parser)

    args = parser.parse_args()
    process_logging_args(args)

    res = args.res
    glc_nec = args.glc_nec
    input_path = args.input_path
    ssp_rcp = args.ssp_rcp
    crop_flag = args.crop_flag
    vic_flag = args.vic_flag
    glc_flag = args.glc_flag
    hres_flag = args.hres_flag

    start_year = args.start_year
    end_year = args.end_year

    # -- determine end_year if not given as an argument:
    if not end_year:
        end_year = start_year

    # -- check if the input path exist
    if not os.path.exists(input_path):
        sys.exit("ERROR: \n" +
                 "\t raw_dir does not exist on this machine. \n" +
                 "\t Please point to the correct raw_dir using --raw-dir" +
                 "or --rawdata-dir flags.")

    ctsm_case = CtsmCase(res, glc_nec, ssp_rcp, crop_flag, input_path,
                         vic_flag, glc_flag, start_year, end_year, hres_flag)

    logger.info("--------------------------")
    logger.info(" ctsm case : %s", ctsm_case)
    logger.info("--------------------------")

    ctsm_case.create_namelist_file()
Ejemplo n.º 7
0
def main(cime_path):
    """Main function called when build_ctsm is run from the command-line

    Args:
    cime_path (str): path to the cime that we're using (this is passed in explicitly
        rather than relying on calling path_to_cime so that we can be absolutely sure that
        the scripts called here are coming from the same cime as the cime library we're
        using).
    """
    setup_logging_pre_config()
    args = _commandline_args()
    process_logging_args(args)
    build_dir = os.path.abspath(args.build_dir)

    if args.rebuild:
        rebuild_ctsm(build_dir=build_dir)
    else:
        build_ctsm(cime_path=cime_path,
                   build_dir=build_dir,
                   compiler=args.compiler,
                   no_build=args.no_build,
                   machine=args.machine,
                   os_type=args.os,
                   netcdf_path=args.netcdf_path,
                   esmf_lib_path=args.esmf_lib_path,
                   max_mpitasks_per_node=args.max_mpitasks_per_node,
                   gmake=args.gmake,
                   gmake_j=args.gmake_j,
                   pnetcdf_path=args.pnetcdf_path,
                   pio_filesystem_hints=args.pio_filesystem_hints,
                   gptl_nano_timers=args.gptl_nano_timers,
                   extra_fflags=args.extra_fflags,
                   extra_cflags=args.extra_cflags,
                   no_pnetcdf=args.no_pnetcdf,
                   build_debug=args.build_debug,
                   build_with_openmp=args.build_with_openmp,
                   inputdata_path=args.inputdata_path)