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

Default to add '-wdir' arguments #351

Merged
merged 4 commits into from
Aug 2, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ MANIFEST
/docs/_build
.coverage
.ipynb_checkpoints
.vscode
9 changes: 3 additions & 6 deletions payu/envmod.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,12 @@ def lib_update(bin_path, lib_name):
slibs = ldd_output.split('\n')

for lib_entry in slibs:
if lib_name in lib_entry:
if lib_name in lib_entry and 'spack' not in lib_entry:
# Only load enviroment modules available - assuming spack built libs includes 'spack' in full path of library
lib_path = lib_entry.split()[2]

# pylint: disable=unbalanced-tuple-unpacking
mod_name, mod_version = fsops.splitpath(lib_path)[2:4]

module('unload', mod_name)
module('load', os.path.join(mod_name, mod_version))
return '{0}/{1}'.format(mod_name, mod_version)

# If there are no libraries, return an empty string
return ''
aidanheerdegen marked this conversation as resolved.
Show resolved Hide resolved
module('load', os.path.join(mod_name, mod_version))
22 changes: 5 additions & 17 deletions payu/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -514,19 +514,18 @@ def run(self, *user_flags):
# Update MPI library module (if not explicitly set)
# TODO: Check for MPI library mismatch across multiple binaries
if mpi_module is None:
mpi_module = envmod.lib_update(
envmod.lib_update(
model.exec_path_local,
'libmpi.so'
)

model_prog = []

if mpi_module.startswith('openmpi'):
# Our MPICH wrapper does not support a working directory flag
model_prog.append('-wdir {0}'.format(model.work_path))
elif self.config.get('scheduler') == 'slurm':
wdir_arg = '-wdir'
if self.config.get('scheduler') == 'slurm':
# Slurm's launcher controls the working directory
jo-basevi marked this conversation as resolved.
Show resolved Hide resolved
model_prog.append('--chdir {0}'.format(model.work_path))
wdir_arg = '--chdir'
model_prog.append(f'{wdir_arg} {model.work_path}')

# Append any model-specific MPI flags
model_flags = model.config.get('mpiflags', [])
Expand Down Expand Up @@ -590,13 +589,6 @@ def run(self, *user_flags):
if self.config.get('coredump', False):
enable_core_dump()

# Our MVAPICH wrapper does not support working directories
if mpi_module.startswith('mvapich'):
curdir = os.getcwd()
os.chdir(self.work_path)
else:
curdir = None

Comment on lines -593 to -599
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just wanted to leave a comment to say deleting this relates directly to #350.

This just can't work with submodels and there is no attempt to test for that, nor do we want to support something that is so limited, so it is being removed.

# Dump out environment
with open(self.env_fname, 'w') as file:
file.write(yaml.dump(dict(os.environ), default_flow_style=False))
Expand All @@ -617,10 +609,6 @@ def run(self, *user_flags):
else:
rc = sp.call(shlex.split(cmd), stdout=f_out, stderr=f_err)

# Return to control directory
if curdir:
os.chdir(curdir)

f_out.close()
f_err.close()

Expand Down
Loading