Hey everyone,(adsbygoogle = window.adsbygoogle || []).push({});

I'm currently running a program which accepts an input file. The input file has various parameters, 3 of which I need to change, run again, etc.

The range of those 3 parameters are 15 values for one, 12 values for another and 10 for another, so I have 15*12*10 (=1800) possible input files I need to make for the program. The output filename will need to match the parameters for that run as well. Obviously creating 3375 input files by hand would be impractical, not only because it would be time consuming but the risk of human error would be great. I need help with the following:

1. Varying the parameters of my input file. I know this can be done with AWK, or perhaps using shell script. The input file is plain text (ascii)

2. recursively running the script each time a parameter is changed. Suppose my input file looks like:

#input file mockup

#Value for A

1

#Value for B

2

#Value for C

4

#Value for D

12

Suppose the three parameters I want to change are A, B and D. Suppose each value of A is spaced 5 units apart, and I want to run over 3 values. My possible values of A would then be {1, 6, 11}

My possible values for B are spaced 3 units apart and there are 4 values {2, 5, 8, 11}

and my Values for D are spaced 1 apart and there are two of them {12, 13}

Allowing for repeated values, the sets I would want process are:

{1, 2, 12}

{1, 5, 12}

{1, 8, 12}

{1, 11, 12}

{1, 2, 13}

{1, 5, 13}

{1, 8, 13}

{1, 11, 13}

{6, 2, 12}

{6, 5, 12}

{6, 8, 12}

{6, 11, 12}

{6, 2, 13}

{6, 5, 13}

{6, 8, 13}

{6, 11, 13}

{11, 2, 12}

{11, 5, 12}

{11, 8, 12}

{11, 11, 12}

{11, 2, 13}

{11, 5, 13}

{11, 8, 13}

{11, 11, 13}

where each place in the brackets corresponds to the values for {A, B, D}

So my two problems are essentially:

1 Make a wrapper to run the program recursively with the changed input file

2 Change the three variables so I get every combination and pass the corresponding input file to the program.

here's what I think it should look like in pseudo-code (I know this is wrong need some help):

A = 1

B = 2

D = 12

for B<11,

for A<11,

for D<13,

B+3, A+5, D++, program input file

#input file mockup

#Value for A

Some Expression for {A}

#Value for B

Some Expression for {B}

#Value for C

4

#Value for D

Some Expression for {D}

outputdirectory: mkdir Run$A$$B$$D$

or something like this....

NOTE: I've posted this question on a different site to see if anyone else could answer it there. I am not trolling or crowd-sourcing; looking for genuine help.

Also, if anyone's interested, I'm running a co-seismic displacement model for which I need to vary the depth, length and displacement each run through. I'm assuming linear slip and uniform viscosity throughout the medium. The program is fine and ready to go I just need to figure out a way to alter my input file with variable parameters.

**Physics Forums | Science Articles, Homework Help, Discussion**

Dismiss Notice

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Shell Scripting or AWK?

**Physics Forums | Science Articles, Homework Help, Discussion**