Skip to content

Commit

Permalink
simple runfile creator
Browse files Browse the repository at this point in the history
  • Loading branch information
teuben committed Jan 4, 2025
1 parent 24a3ec7 commit b382fcc
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions src/scripts/python/mkrunfile.py
Original file line number Diff line number Diff line change
@@ -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")


0 comments on commit b382fcc

Please sign in to comment.