The OOMMF Host Server: launchhost

Under normal circumstances, the OOMMF host server (also known as the host service directory) is automatically launched in the background as needed by client applications. However, it can be useful, primarily in batch compute environments, to launch the host server explicitly in order to control the host server port address.

Launching
The launchhost command line is:

tclsh oommf.tcl launchhost [standard options] port
where
port
Requested port number for host server to listen on. For non-privileged users, this usually has to be larger than 1024, or the special value 0 which signals the host server to open on a random, unused port. On success, launchhost writes the host port number actually used to stdout.
As described in the OOMMF architecture documentation, the host server (host service directory) plays a vital role in allowing various OOMMF applications to communicate with one another. To work, the host server port number must be known to all OOMMF applications. Typically this port number is determined by the Net_Host port setting in the file oommf/config/options.tcl, although this setting may be overridden by the environment variable OOMMF_HOSTPORT.

In batch-mode settings, however, it can occur that one wants to run multiple concurrent but independent OOMMF sessions on a single machine. One way to accomplish this is to set the environment variable OOMMF_HOSTPORT to distinct values in each session. A difficulty here is the bookkeeping necessary to ensure that each session really gets a distinct value. Using launchhost with port set to zero provides a straightforward solution to this problem. For example, consider the Bourne shell script:

   #!/bin/sh
   OOMMF_HOSTPORT=`tclsh oommf.tcl launchhost 0`
   export OOMMF_HOSTPORT
   tclsh oommf.tcl mmArchive
   tclsh oommf.tcl boxsi sample.mif
   tclsh oommf.tcl killoommf all

The second line (OOMMF_HOSTPORT=...) launches the host server on a random available port; the port selected is printed to stdout by launchhost and is then used to set the environment variable OOMMF_HOSTPORT. Note in particular the backticks around the launchhost command, which invoke command execution. For modern Bourne compatible shells such as bash, dash, ksh, and zsh, an alternative to backticks is

   OOMMF_HOSTPORT=$(tclsh oommf.tcl launchhost 0)
which is rather more readable. For csh and derivatives, replace the two OOMMF_HOSTPORT lines with the single line

   setenv OOMMF_HOSTPORT `tclsh oommf.tcl launchhost 0`

The subsequent commands launch an instance of mmArchive in the background and run Boxsi on the problem described by sample.mif. (By default, Boxsi runs in the foreground.) When Boxsi returns, the killoommf command is used to terminate all OOMMF processes in this session. (Alternatively, the Boxsi command option -kill may be used to the same effect as killoommf.)

If problems occur, a useful diagnostic is to insert the line

   echo OOMMF_HOSTPORT: $OOMMF_HOSTPORT
immediately before the “tclsh oommf.tcl mmArchive” line.


OOMMF Documentation Team
September 30, 2025