Skip to content

Commit

Permalink
launch_run: builds rundir and launches run
Browse files Browse the repository at this point in the history
e.g., python launch_run.py -o -d ~/foo bar
where foo is the target location for the run directory
and bar is the input file with run details like
start and end date. Currently bar is not used as the format
is TBD after consultation with CCMC as it will use whatever
is returned by the RoR web interface.
  • Loading branch information
drsteve committed Mar 24, 2023
1 parent 911b551 commit 6577e36
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions launch_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def setup_parser():
# Create argument parser & set up arguments:
parser = ArgumentParser(description=__doc__,
formatter_class=RawDescriptionHelpFormatter)
parser.add_argument("-d", "--destdir", default=None,
parser.add_argument("-d", "--destdir", default=None, required=True,
help="Destination path for run directory")
parser.add_argument("configfile", nargs='+', help="Run config")
parser.add_argument("-o", "--overwrite", action="store_true",
Expand Down Expand Up @@ -57,6 +57,8 @@ def parse_config(config_file):
end_date = dt.datetime(2015, 3, 18) # get from config file
lastramind = get_ramindices_end()
if end_date >= lastramind:
# if run ends after the last date in the Ramindices file,
# update it
with cd("Scripts"):
subprocess.run(['python', 'updateRamIndices.py'])

Expand All @@ -68,10 +70,27 @@ def setup_rundir(args):
parse_config(args.configfile)
# Now copy in everything we need
# and move rundir to final location
compl = subprocess.run(['make', 'rundir'], check=True, capture_output=True)
shutil.move('rundir', args.destdir)
compl = subprocess.run(['make', 'rundir', 'RUNDIR=run_ram_ror'],
check=True, capture_output=True)
if args.overwrite:
shutil.rmtree(args.destdir)
shutil.move('run_ram_ror', args.destdir)


def run_model(args):
'''Launch RAM-SCB as a detached process so it keeps running
and the launch script exits
'''
with cd(args.destdir):
print(os.getcwd())
if not os.path.isfile('ram_scb.exe'):
raise RuntimeError(' '.join(['RAM-SCB not found in specified',
'directory, or directory not',
'created properly']))
subprocess.Popen(['./ram_scb.exe'], close_fds=True)


if __name__ == '__main__':
args = setup_parser()
setup_rundir(args)
run_model(args)

0 comments on commit 6577e36

Please sign in to comment.