On Sat, 7 Jan 2017, Sven Schreiber wrote:
Am 07.01.2017 um 15:52 schrieb Allin Cottrell:
> It sounds as if MPI can do what you want here. Something like the
> following:
> <shell>
> mpiexec -n 2 gretlmpi parallel.inp
> </shell>
I was aware of MPI in principle and thought about it, but I considered only
an mpi...end mpi block. Maybe this gretlmpi thing might be an alternative,
yes, thanks for pointing it out.
Actually MPI may be overkill here (if you don't need any interaction
between the parallel gretl processes); you can just use the shell
for parallelism.
<hansl>
set echo off
set messages off
scalar p = scriptopt
scalar T = 100
scalar k = 3
matrix X
# conditionality here
if p == 1
X = mnormal(T, k)
elif p == 2
X = muniform(T, k)
endif
matrix XXi = inv(X'X)
string outname = sprintf("output%d.txt", p)
outfile @outname --write
print XXi
outfile --close
</hansl>
<bash>
gretlcli --scriptopt=1 -b parallel.inp &
gretlcli --scriptopt=2 -b parallel.inp &
wait
echo All done
</bash>
or
<cmd.exe>
start gretlcli --scriptopt=1 -b parallel.inp
start gretlcli --scriptopt=2 -b parallel.inp
</cmd.exe>
Allin