(!******************************************************* Mosel Example Problems ====================== file runrtpardistr.mos `````````````````````` Running several instances of a model from another Mosel model. - Parallel submodels in distributed architecture - Before running this model, you need to set up the array NODENAMES with machine names/addresses of your local network. All nodes that are used need to have the same version of Xpress installed and suitably licensed, and the server "xprmsrv" must have been started on these machines. All files are local to the root node, no write access is required at remote nodes. (c) 2010 Fair Isaac Corporation author: S. Heipcke, May 2010, rev. Jan. 2013 *******************************************************!) model "Run model rtparams in distributed architecture" uses "mmjobs", "mmsystem" declarations NUMI = 5 A = 1..2*NUMI B = 1..NUMI modPar: array(A) of Model moselInst: array(B) of Mosel NODENAMES: array(B) of string end-declarations !!! Select the (remote) machines to be used: !!! Use names, IP addresses, or empty string !!! for the node running this model forall(i in B) NODENAMES(i):= if(isodd(i), "localhost", "xssh:127.0.0.1") ! NODENAMES:: (1..5)["localhost","","","rcmd:mosel -r","rcmd:mosel -r"] writeln("Node: ", getparam("NODENUMBER")) ! Compile the model file locally on root if compile("rtparams3.mos")<>0 then exit(1); end-if instct:=0 forall(i in A) do if isodd(i) then instct+=1 ! Connect to a remote machine if connect(moselInst(instct), NODENAMES(instct))<>0 then exit(2); end-if end-if writeln("Current node: ", getsysinfo(SYS_NODE), " submodel node: ", getsysinfo(moselInst(instct), SYS_NODE)) ! Load the bim file (located at root node) load(moselInst(instct), modPar(i), "rmt:rtparams3.bim") ! Start remote model execution run(modPar(i), "PARAM1=" + i + ",PARAM2=" + 0,1*i + ",PARAM3='string " + i + "'" + ",PARAM4=" + isodd(i)) end-do forall(i in A) do wait ! Wait for model termination dropnextevent ! Ignore termination event message end-do fdelete("rtparams3.bim") ! Cleaning up end-model