Skip to content
Closed
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
2 changes: 1 addition & 1 deletion compass/landice/ismip7/ice_sheet_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
},
'ais': {
'atm_version': 'v1',
'ocean_version': 'v1',
'ocean_version': 'v2',
'atm_model': 'RACMO2.3p2-ERA',
'ocean_model': None,
# AIS OCX ocean files have no model token and live in per-choice
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,13 +210,33 @@ def _link_atmosphere_outputs(self, output_base_path, atm_forcing_group,

dst_dir = os.path.join(output_base_path, choice_forcing_group,
"atmosphere")

# Guard against destination directory resolving to source directory
# (e.g., if choice_forcing_group is a symlink to atm_forcing_group)
if os.path.realpath(dst_dir) == os.path.realpath(src_dir):
logger.warning(
f"Skipping atmosphere mirror for {choice_forcing_group}: "
f"destination directory {dst_dir} resolves to source "
f"directory {src_dir}. Relinking would overwrite the "
f"original files.")
return

os.makedirs(dst_dir, exist_ok=True)

for fname in os.listdir(src_dir):
src = os.path.join(src_dir, fname)
if not os.path.isfile(src):
if os.path.islink(src) or not os.path.isfile(src):
continue
dst = os.path.join(dst_dir, fname)

# Guard against destination file resolving to source file
if os.path.realpath(dst) == os.path.realpath(src):
logger.warning(
f"Skipping {fname}: destination {dst} resolves to "
f"source {src}. Relinking would overwrite the "
f"original.")
continue

if os.path.lexists(dst):
os.remove(dst)
os.symlink(src, dst)
Expand Down
Loading