At the NSCL, the MPITcl shell is located in /usr/opt/miptcl/bin/mpitcl. It is normally run under the mpirun command. Usually it is run within a batch job submission script that specifies the resources the application needs and provides stdin redirection to a script that contains the application.
For example, the following command runs 4 processes in the MPItcl application and specifies the application script myapp.tcl
Let's look at a toy application. In MPISpecTcl - Massively parallel SpecTcl. We'll look at MPI batch SpecTcl, a more interesting application that runs under MPITcl. Remember that the script executes in rank 0. It therefore must tell all other ranks what to do.
Example 3-2. Toy MPITcl application
puts "There are [mpi::mpi size] proceses in the application."mpi::mpi execute others {puts "Hello from worker [mpi::mpi rank]"}
# Note that the notifier starts out running so this can work: mpi::mpi execute others { proc ReturnData {rank data} { mpi::mpi send 0 $data }
mpi::mpi handle ReturnData } proc receiveData {rank data} { puts "Received data from $rank: $data" incr ::expecting -1 } mpi::mpi handle receiveData
set expecting [mpi::mpi size]
incr expecting -1 mpi::mpi send others [list 1 2 3 4]
while {$expecting > 0} { vwait expecting } mpi::mpi stopnotifier
mpi::mpi execute all exit
Remember that this script runs in rank 0
expecting
global variable is decremented after each call.
If this variable is vwaited on,
the vwait will conclude when the
handler is called.
Hopefully this toy application gives you an idea about how the typical patterns used in an MPITcl application.