I have a very basic script to run multiple copies of a windows population genetics program (msvar.exe) under Wine. It uses "find" to look through multiple folders for an initiation file (INTFILE) and then starts an instance of msvar.exe in each directory using that initiation file. Different folders will have different paramaters in the initiation file so I can run a series of simulations by adding the "&" parameter. Here it is;
for i in $(find /home/msvartest -name INTFILE -type f)
do (
cd $(dirname $(realpath $i));
# wine explorer /desktop=name msvar.exe;
wineconsole --backend=user msvar.exe;
) &
done
At the moment I run up to 20 copies of msvar.exe at once each under it's own wineconsole (or wine explorer window) on my dual hexacore machine. Each run instance can take 3 or 4 days, but the program only runs on a single core, so I need to run the simulations in parallel. It looks like Gnu parallel would be a better way to run msvar.exe and would allow me to run more simulations over remote computers. I unsuccessfully tried to get Gnu parallel working with wineconsole following the suggestions in Run wine in parallel with gnu-parallel - needs {%} slot substitution to work. Is anybody able to help, or even better knock up a script I could use.
Thanks for your help.
I think your command is going to get horribly long and unwieldy unless you use an exported function like this:
#!/bin/bash
doit() {
...
...
}
export -f doit
parallel -j 10 doit ::: {0..99}
So, for your example that will look something like (untested):
#!/bin/bash
doit() {
echo Processing $1
cd $(dirname $(realpath "$1"));
WINEPREFIX=$HOME/slot{%} wineconsole --backend=user msvar.exe
}
export -f doit
find /home/msvartest -name INTFILE -type f | parallel --dry-run doit
Unfortunately I don't have your environment set up to test this but it should be close and easy to correct if there are minor errors. Try and see what it does, then remove the --dry-run
to let it actually do something.
If you have spaces in your filenames, you should use -print0
with your find
command and also add -0
after parallel
but that just complicates things for the moment.