Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed #152 - control file update through user_ctl_mizuRoute #156

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions cime_config/buildnml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ logger = logging.getLogger(__name__)

# pylint: disable=too-many-arguments,too-many-locals,too-many-branches,too-many-statements
####################################################################################
def _create_control_files(case, confdir, inst_string, infile, nmlgen, ctl, data_list_path):
def _create_control_files(case, caseroot, srcroot, confdir, inst_string, infile, nmlgen, ctl, data_list_path):
####################################################################################
"""Write out the input configuration file for mizuRoute

Expand Down Expand Up @@ -170,6 +170,18 @@ def _create_control_files(case, confdir, inst_string, infile, nmlgen, ctl, data_

ctl.set( "fname_state_in", fname_state_in )

# Read in the user control file for the case and change settings to it
file_src = "user_ctl_mizuRoute"
user_ctl_file = os.path.join(caseroot, file_src + inst_string)
if ( not os.path.exists( user_ctl_file ) ):
shutil.copy( os.path.join( srcroot, "cime_config", file_src), user_ctl_file )
usrctl = mizuRoute_control()
usrctl.read( user_ctl_file, allowEmpty=True )
for element in usrctl.get_elmList():
value = ctl.get( element )
expect( value != "UNSET", "Element in the user_ctl_mizuRoute file is NOT in the control file: "+element )
ctl.set( element, usrctl.get( element ) )

#----------------------------------------------------
# Write output files
#----------------------------------------------------
Expand Down Expand Up @@ -240,24 +252,12 @@ def buildnml(case, caseroot, compname):
create_namelist_infile(case, user_nl_file, infile)
control_infile = [infile]

# Read in the user control file for the case and change settings to it
file_src = "user_ctl_mizuRoute"
user_ctl_file = os.path.join(caseroot, file_src + inst_string)
if ( not os.path.exists( user_ctl_file ) ):
shutil.copy( os.path.join( srcroot, "cime_config", file_src), user_ctl_file )
usrctl = mizuRoute_control()
usrctl.read( user_ctl_file, allowEmpty=True )
for element in usrctl.get_elmList():
value = ctl.get( element )
expect( value != "UNSET", "Element in the user_ctl_mizuRoute file is NOT in the control file: "+element )
ctl.set( element, usrctl.get( element ) )

# Create the namelist generator object - independent of instance
definition_files = [srcroot + "/cime_config/namelist_definition_mizuRoute.xml"]
nmlgen = NamelistGenerator(case, definition_files)

# create control files
_create_control_files(case, confdir, inst_string, control_infile, nmlgen, ctl, data_list_path)
_create_control_files(case, caseroot, srcroot, confdir, inst_string, control_infile, nmlgen, ctl, data_list_path)

# copy control files to rundir
if os.path.isdir(rundir):
Expand Down