-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ac076aa
commit 2b36874
Showing
1 changed file
with
23 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,38 @@ | ||
#!/usr/bin/env python3 | ||
from __future__ import annotations | ||
|
||
#import packages | ||
import yaml | ||
from standard_script_setup import * | ||
import os | ||
|
||
import yaml | ||
from CIME.case import Case | ||
from standard_script_setup import * # noqa: F401,F403 | ||
|
||
#Create variable for the caseroot environment variable | ||
# Create variable for the caseroot environment variable | ||
caseroot = os.getcwd() | ||
#Open the config.yml file and create a dictionary with safe_load from the yaml package | ||
with open('config_template.yml') as f: | ||
# Open the config.yml file and create a dictionary with safe_load from the yaml package | ||
with open("config_template.yml") as f: | ||
my_dict = yaml.safe_load(f) | ||
|
||
# get environment cesm case variables | ||
with Case(caseroot, read_only=False, record=True) as case: | ||
cime_case = case.get_value('CASE') | ||
#create variable to access cesm_output_dir | ||
outdir = case.get_value('DOUT_S_ROOT') | ||
cime_case = case.get_value("CASE") | ||
# create variable to access cesm_output_dir | ||
outdir = case.get_value("DOUT_S_ROOT") | ||
|
||
my_dict['global_params']['case_name'] = cime_case | ||
my_dict['timeseries']['case_name'] = cime_case | ||
my_dict["global_params"]["case_name"] = cime_case | ||
my_dict["timeseries"]["case_name"] = cime_case | ||
|
||
#create variable user to access the user environment variable | ||
user = os.environ['USER'] | ||
#replace USER with the environment variable | ||
#my_dict['data_sources']['nb_path_root'] = f'/glade/u/home/{user}/CUPiD/examples/nblibrary' | ||
# create variable user to access the user environment variable | ||
user = os.environ["USER"] | ||
# replace USER with the environment variable | ||
# my_dict['data_sources']['nb_path_root'] = f'/glade/u/home/{user}/CUPiD/examples/nblibrary' | ||
|
||
#replace with environment variable | ||
my_dict['global_params']['CESM_output_dir'] = outdir | ||
# replace with environment variable | ||
my_dict["global_params"]["CESM_output_dir"] = outdir | ||
|
||
#create new file, make it writeable | ||
with open('config.yml', "w") as f: | ||
#write a comment | ||
# create new file, make it writeable | ||
with open("config.yml", "w") as f: | ||
# write a comment | ||
f.write("# sample comment\n") | ||
#enter in each element of the dictionary into the new file | ||
yaml.dump(my_dict, f) | ||
# enter in each element of the dictionary into the new file | ||
yaml.dump(my_dict, f) |