ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc program mplmanager ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc c c This is a trivial "hello world" program for illustrating the c use of the SP2 c c This manager program spawns copies of the program 'worker'. c ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc implicit none integer maxnworkers c c The following integers are used in the MPL calls... c integer i, j integer nprocs, nworkers integer nodeid, msgid, namelen, noderesult integer nbuf(4), dontcare, allgrp, hostnm_, rc character*7 my_hostname c c c Call mp_environ to return the # of nodes available (nprocs)... c and this node's id: c call MP_ENVIRON(nprocs,nodeid) c c Get manager hostname: c rc = hostnm_(my_hostname) c c Number of workers must be fixed in the case of MPL. c You can vary the number of processors with the environment c variable MP_PROCS c nworkers = nprocs-1 c c Learn value of allgrp and dontcare, for use with broadcast. c call MP_TASK_QUERY(nbuf, 4, 3) dontcare = nbuf(1) allgrp = nbuf(4) c c Open the file for output c open(21,file='mplmanager.results') write(6,100) write(21,100) 100 format('------ MPL program: mplmanager ----- ',/) c c Broadcast the manager hostname to all processors... c call MP_BCAST(my_hostname, 7, 0, allgrp) c c Send each processor an integer value to print out, modify and return. c do 10 i = 1,nworkers call MP_BSEND(i, 4, i, 100, msgid) 10 continue c c Now, the manager receives and prints the results of the workers. c do 20 i = 1, nworkers call MP_BRECV(noderesult, 4, i, 200, msgid) write(6,*) 'Result from task ', i, ': ',noderesult write(21,*) 'Result from task ', i, ': ',noderesult 20 continue c c Close the output file: c close(21) stop end