Skip to content

Commit

Permalink
- Default run command fix: some systems don't allow mpirun from a log…
Browse files Browse the repository at this point in the history
…in node so default MPI command changed to ''. This might be useful for short runs.

- Script reports that it adds 'xterm -e' to MPI command if not already present and debug mode turned on. User might be using a different method for debugging MPI so this info is useful to report
  • Loading branch information
scrasmussen committed Sep 4, 2024
1 parent 8f081a6 commit de0a9ce
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions scm/src/run_scm.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@
# Path to default bin directory (relative to scm_root)
DEFAULT_BIN_DIR = 'scm/bin'

# Default command string to run MPI apps (number of processes should be 1 since SCM is not set up to use more than 1 yet)
DEFAULT_MPI_COMMAND = 'mpirun -np 1'


# Copy executable to run directory if true (otherwise it will be linked)
COPY_EXECUTABLE = False

Expand Down Expand Up @@ -125,7 +121,7 @@
parser.add_argument('--stop_on_error', help='when running multiple SCM runs, stop on first error', required=False, action='store_true')
parser.add_argument('-v', '--verbose', help='set logging level to debug and write log to file', action='count', default=0)
parser.add_argument('-f', '--file', help='name of file where SCM runs are defined')
parser.add_argument('--mpi_command', help='command used to invoke the executable via MPI (including options)', required=False)
parser.add_argument('--mpi_command', help='command used to invoke the executable via MPI (including options)', required=False, default=False)

###############################################################################
# Functions and subroutines #
Expand Down Expand Up @@ -465,7 +461,7 @@ def setup_rundir(self):
raise Exception(message)
else:
case_nml['case_config']['runtime_mult'] = self._runtime_mult

# If the number of levels is specified, set the namelist value
if self._levels:
case_nml['case_config']['n_levels'] = self._levels
Expand Down Expand Up @@ -727,13 +723,16 @@ def setup_rundir(self):

def launch_executable(use_gdb, gdb, mpi_command, ignore_error = False):
"""Configure model run command and pass control to shell/gdb"""

# If mpi_command flag not passed default to '' to allow it to run on login nodes
if not mpi_command:
mpi_command = ''
if use_gdb:
if not mpi_command:
mpi_command = DEFAULT_MPI_COMMAND + ' xterm -e '
if mpi_command != '' and ('xterm' not in mpi_command):
logging.info("run_scm.py debug flag adds 'xterm -e' to MPI command")
mpi_command += ' xterm -e '
cmd = '(cd {scm_run} && {mpi_command} {gdb} {executable})'.format(scm_run=SCM_RUN, mpi_command=mpi_command, gdb=gdb, executable=EXECUTABLE)
else:
if not mpi_command:
mpi_command = DEFAULT_MPI_COMMAND
cmd = '(cd {scm_run} && time {mpi_command} {executable})'.format(scm_run=SCM_RUN, mpi_command=mpi_command, executable=EXECUTABLE)
logging.info('Passing control to "{0}"'.format(cmd))
time.sleep(1)
Expand Down

0 comments on commit de0a9ce

Please sign in to comment.