Skip to content
Open
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion Coupled_Drivers/dr_env_lib/xios_def.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@
'IODEF_FILENAME': {'default_val': 'iodef.xml'},
'ROSE_LAUNCHER_PREOPTS_XIOS': {'default_val': 'unset'},
'XIOS_EXEC': {},
'XIOS_LINK': {'default_val': 'xios.exe'}
'XIOS_LINK': {'default_val': 'xios.exe'},
'XIOS_VERSION': {'default_val': '2'}
}
18 changes: 13 additions & 5 deletions Coupled_Drivers/xios_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ def _copy_iodef_custom(xios_evar):
shutil.copy(xios_evar['IODEF_CUSTOM'], xios_evar['IODEF_FILENAME'])

def _update_iodef(
is_server_mode, is_coupled_mode, oasis_components, iodef_fname):
is_server_mode, is_coupled_mode, oasis_components, iodef_fname,
xios_version):
'''
Update the iodef.xml file for server/attatched mode and couplng mode.
is_server_mode and is_coupled_mode are boolean. (true when each option
Expand All @@ -62,10 +63,17 @@ def _update_iodef(
line = line.replace(text_bool[not is_coupled_mode], \
text_bool[is_coupled_mode])
# Update the list of coupled components
elif '<!' not in line and 'oasis_codes_id' in line:
elif '<!' not in line and ('oasis_codes_id' in line or
'clients_code_id' in line):
if oasis_components.strip():
line = '<variable id="oasis_codes_id" type="string" >' \
+ oasis_components+'</variable>'
if xios_version == '3':
# The appropriate variable is clients_code_id
line = '<variable id="clients_code_id" type="string" >' \
+ oasis_components+'</variable>'
else:
# For XIOS2/2.5 the appropriate variable is oasis_codes_id
line = '<variable id="oasis_codes_id" type="string" >' \
+ oasis_components+'</variable>'
Comment on lines +69 to +76

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you don't need to pad the IDs to get them to line up and you're happy to go with f-strings, you can simplify things a bit:

Suggested change
if xios_version == '3':
# The appropriate variable is clients_code_id
line = '<variable id="clients_code_id" type="string" >' \
+ oasis_components+'</variable>'
else:
# For XIOS2/2.5 the appropriate variable is oasis_codes_id
line = '<variable id="oasis_codes_id" type="string" >' \
+ oasis_components+'</variable>'
# Variable name changes at version 3
vname = "clients_code_id" if xios_version == '3' else "oasis_codes_id"
line = f'<variable id="{vname}" type="string" >{oasis_components}</variable>'

else:
line = '<!-- oasis_codes_id not required -->'

Expand Down Expand Up @@ -129,7 +137,7 @@ def _setup_executable(common_env):
oasis_components, xios_envar = _setup_coupling_components(xios_envar)
# Update the iodef file
_update_iodef(using_server, using_coupler, oasis_components,
xios_envar['IODEF_FILENAME'])
xios_envar['IODEF_FILENAME'], xios_envar['XIOS_VERSION'])

return xios_envar

Expand Down
Loading