From b382fccc3d7e8418fe17a116827f343b2c146c7b Mon Sep 17 00:00:00 2001 From: Peter Teuben Date: Fri, 3 Jan 2025 22:16:19 -0500 Subject: [PATCH] simple runfile creator --- src/scripts/python/mkrunfile.py | 55 +++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100755 src/scripts/python/mkrunfile.py diff --git a/src/scripts/python/mkrunfile.py b/src/scripts/python/mkrunfile.py new file mode 100755 index 000000000..75eec1d0f --- /dev/null +++ b/src/scripts/python/mkrunfile.py @@ -0,0 +1,55 @@ +#! /usr/bin/env python3 +# +# + +import sys +import numpy as np + +# simple usage +if len(sys.argv) < 3: + print("Usage: %s progname p1=v11,v12... p2=..." % sys.argv[0]) + sys.exit(0) + +# parse command line args +progname = sys.argv[1] +pars = sys.argv[2:] + +npar = len(pars) +par = list(range(npar)) +val = list(range(npar)) + +# setting +for i in range(npar): + par[i] = 'par%d' % i + par[i] = pars[i].split('=')[0] + val[i] = pars[i].split('=')[1].split(',') + +# loop over pars and vals and create the cmds for the runfile +# @todo generalize this + +if npar == 1: + for p0 in range(len(val[0])): + cmd = '%s %s=%s' % (progname, par[0], val[0][p0]) + print(cmd) +elif npar == 2: + for p1 in range(len(val[1])): + for p0 in range(len(val[0])): + cmd = '%s %s=%s %s=%s' % (progname, par[0], val[0][p0], par[1], val[1][p1]) + print(cmd) +elif npar == 3: + for p2 in range(len(val[2])): + for p1 in range(len(val[1])): + for p0 in range(len(val[0])): + cmd = '%s %s=%s %s=%s %s=%s' % (progname, par[0], val[0][p0], par[1], val[1][p1], par[2], val[2][p2]) + print(cmd) +elif npar == 4: + for p3 in range(len(val[3])): + for p2 in range(len(val[2])): + for p1 in range(len(val[1])): + for p0 in range(len(val[0])): + cmd = '%s %s=%s %s=%s %s=%s %s=%s' % (progname, par[0], val[0][p0], par[1], val[1][p1], par[2], val[2][p2], par[3], val[3][p3]) + print(cmd) +else: + print("# too many parameters") + +