CIME.case.case.Case

class CIME.case.case.Case(case_root=None, read_only=True, record=False, non_local=False)[source]

Bases: object

https://github.com/ESMCI/cime/wiki/Developers-Introduction The Case class is the heart of the CIME Case Control system. All interactions with a Case take part through this class. All of the variables used to create and manipulate a case are defined in xml files and for every xml file there is a python class to interact with that file.

XML files which are part of the CIME distribution and are meant to be readonly with respect to a case are typically named config_something.xml and the corresponding python Class is Something and can be found in file CIME.XML.something.py. I’ll refer to these as the CIME config classes.

XML files which are part of a case and thus are read/write to a case are typically named env_whatever.xml and the cooresponding python modules are CIME.XML.env_whatever.py and classes are EnvWhatever. I’ll refer to these as the Case env classes.

The Case Class includes an array of the Case env classes, in the configure function and it’s supporting functions defined below the case object creates and manipulates the Case env classes by reading and interpreting the CIME config classes.

This class extends across multiple files, class members external to this file are listed in the following imports

Methods

__init__

apply_user_mods

User mods can be specified on the create_newcase command line (usually when called from create test) or they can be in the compset definition, or both.

archive_last_restarts

Convenience function for archiving just the last set of restart files to a given directory.

cancel_batch_jobs

case_cmpgen_namelists

case_run

case_setup

case_st_archive

Create archive object and perform short term archiving

case_test

check_DA_settings

check_all_input_data

Read through all files of the form *.input_data_list in the data_list_dir directory. These files contain a list of input and boundary files needed by each model component. For each file in the list confirm that it is available in input_data_root and if not (optionally download it from a server at address using protocol. Perform a chksum of the downloaded file.

check_case

check_if_comp_var

check_input_data

For a given case check for the relevant input data as specified in data_list_dir/*.input_data_list in the directory input_data_root, if not found optionally download it using the servers specified in config_inputdata.xml. If a chksum file is available compute the chksum and compare it to that in the file. Return True if no files missing.

check_timestamps

clean_up_lookups

configure

copy

create

create_caseroot

create_clone

Create a case clone

create_dirs

Make necessary directories for case

create_namelists

Create component namelists

fix_sys_argv_quotes

Fixes removed quotes from argument list.

flush

get_baseline_dir

get_batch_jobs

get_build_threaded

Returns True if current settings require a threaded build/run.

get_case_root

Returns the root directory for this case.

get_compset_components

get_compset_var_settings

get_env

get_first_job

get_job_id

get_job_info

Get information on batch jobs associated with this case

get_latest_cpl_log

find and return the latest cpl log file in the coupler_log_path directory

get_mpirun_cmd

get_primary_component

get_primary_job

get_record_fields

get_record_fields gets individual requested field from an entry_id file this routine is used only by xmlquery

get_resolved_value

get_type_info

get_value

get_values

initialize_derived_attributes

These are derived variables which can be used in the config_* files for variable substitution using the {{ var }} syntax

is_save_timing_dir_project

Check whether the project is permitted to archive performance data in the location specified for the current machine

load_env

new_hash

Creates a hash

preview_run

read_xml

record_cmd

report_job_status

restore_from_archive

Take archived restart files and load them into current case.

set_comp_classes

set_file

force the case object to consider only xmlfile

set_initial_test_values

set_lookup_value

set_model_version

set_valid_values

Update or create a valid_values entry for item and populate it

set_value

If a file has been defined, and the variable is in the file, then that value will be set in the file object and the resovled value is returned unless return_file is True, in which case (resolved_value, filename) is returned where filename is the name of the modified file.

stage_refcase

Get a REFCASE for a hybrid or branch run This is the only case in which we are downloading an entire directory instead of a single file at a time.

submit

submit_jobs

test_env_archive

test_st_archive

update_env

Replace a case env object file

valid_compset

Add stub models missing in <compset_name>, return full compset name.

apply_user_mods(user_mods_dirs=None)[source]

User mods can be specified on the create_newcase command line (usually when called from create test) or they can be in the compset definition, or both.

If user_mods_dirs is specified, it should be a list of paths giving the user mods specified on the create_newcase command line.

archive_last_restarts(archive_restdir, rundir, last_date=None, link_to_restart_files=False)[source]

Convenience function for archiving just the last set of restart files to a given directory. This also saves files attached to the restart set, such as rpointer files and necessary history files. However, it does not save other files that are typically archived (e.g., history files, log files).

Files are copied to the directory given by archive_restdir.

If link_to_restart_files is True, then symlinks rather than copies are done for the restart files. (This has no effect on the history files that are associated with these restart files.)

case_st_archive(last_date_str=None, archive_incomplete_logs=True, copy_only=False, resubmit=True)[source]

Create archive object and perform short term archiving

check_all_input_data(protocol=None, address=None, input_data_root=None, data_list_dir='Buildconf', download=True, chksum=False)[source]

Read through all files of the form *.input_data_list in the data_list_dir directory. These files contain a list of input and boundary files needed by each model component. For each file in the list confirm that it is available in input_data_root and if not (optionally download it from a server at address using protocol. Perform a chksum of the downloaded file.

check_input_data(protocol='svn', address=None, input_data_root=None, data_list_dir='Buildconf', download=False, user=None, passwd=None, chksum=False, ic_filepath=None)[source]

For a given case check for the relevant input data as specified in data_list_dir/*.input_data_list in the directory input_data_root, if not found optionally download it using the servers specified in config_inputdata.xml. If a chksum file is available compute the chksum and compare it to that in the file. Return True if no files missing

create_clone(newcaseroot, keepexe=False, mach_dir=None, project=None, cime_output_root=None, exeroot=None, rundir=None, user_mods_dirs=None)[source]

Create a case clone

If exeroot or rundir are provided (not None), sets these directories to the given paths; if not provided, uses default values for these directories. It is an error to provide exeroot if keepexe is True.

create_dirs()[source]

Make necessary directories for case

create_namelists(component=None)[source]

Create component namelists

fix_sys_argv_quotes(cmd)[source]

Fixes removed quotes from argument list.

Restores quotes to –val and KEY=VALUE from sys.argv.

get_build_threaded()[source]

Returns True if current settings require a threaded build/run.

get_case_root()[source]

Returns the root directory for this case.

get_job_info()[source]

Get information on batch jobs associated with this case

get_latest_cpl_log(coupler_log_path=None, cplname='cpl')[source]

find and return the latest cpl log file in the coupler_log_path directory

get_record_fields(variable, field)[source]

get_record_fields gets individual requested field from an entry_id file this routine is used only by xmlquery

initialize_derived_attributes()[source]

These are derived variables which can be used in the config_* files for variable substitution using the {{ var }} syntax

is_save_timing_dir_project(project)[source]

Check whether the project is permitted to archive performance data in the location specified for the current machine

new_hash()[source]

Creates a hash

restore_from_archive(rest_dir=None, dout_s_root=None, rundir=None, test=False)[source]

Take archived restart files and load them into current case. Use rest_dir if provided otherwise use most recent restore_from_archive is a member of Class Case

set_file(xmlfile)[source]

force the case object to consider only xmlfile

set_valid_values(item, valid_values)[source]

Update or create a valid_values entry for item and populate it

set_value(item, value, subgroup=None, ignore_type=False, allow_undefined=False, return_file=False)[source]

If a file has been defined, and the variable is in the file, then that value will be set in the file object and the resovled value is returned unless return_file is True, in which case (resolved_value, filename) is returned where filename is the name of the modified file.

stage_refcase(input_data_root=None, data_list_dir=None)[source]

Get a REFCASE for a hybrid or branch run This is the only case in which we are downloading an entire directory instead of a single file at a time.

update_env(new_object, env_file, blow_away=False)[source]

Replace a case env object file

valid_compset(compset_name, compset_alias, files)[source]

Add stub models missing in <compset_name>, return full compset name. <files> is used to collect set of all supported components.