ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc program manager 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 c c Note: full path is given in INCL compilation flag in makefile: c include 'fpvm3.h' integer maxnprocs parameter (maxnprocs = 32) integer tids(maxnprocs) c c The tids array is used by PVM to hold the identifiers for the c spawned worker programs. The values are used to direct messages to c the workers in the pvmfsend command. c c The following integers are used in the PVM calls... integer info, i integer nprocs integer hostid, fromid integer rc, bufid, hostnm_ character*7 my_hostname c c The following integer is used to store the message returned by the workers... integer noderesult c c Enroll the manager program in PVM and return an id for this process... c read input to determine number of processes to create... c call pvmfmytid(hostid) c c Get manager hostname: c rc = hostnm_(my_hostname) c c Read from standard input the number of processes to create... c write(6,*)'Enter the number of PVM processes to create:' write(6,*)'NOTE: for PVMe, must be < number of nodes in pool!' read(5,*)nprocs c c Open the file for output c open(21,file='manager.results') write(6,100) write(21,100) 100 format('------ PVM program: manager ----- ',/) c c Spawn nprocs worker programs. Their task ids will be placed in the c tids array for later use in message passing. c call pvmfspawn('worker', PVMDEFAULT, '*', nprocs, tids, info) if (info .ne. nprocs) then write(6,*) 'Error in spawning; Return code is ', info call pvmfexit(rc) stop endif c c multi-cast (broadcast) the manager hostname to all processors... c call pvmfinitsend(0,bufid) call pvmfpack(STRING, my_hostname, 7, 1, rc) call pvmfmcast(nprocs, tids, 100, rc) c c Send each processor an integer value to print out, modify and return. c do 10 i = 1,nprocs call pvmfinitsend(0, bufid) call pvmfpack(INTEGER4, i, 1, 1, rc) call pvmfsend(tids(i), 200, rc) 10 continue c c Now, the manager receives and prints the results of the workers. c do 20 i = 1, nprocs call pvmfrecv(-1, 300, bufid) call pvmfunpack(INTEGER4, fromid, 1, 1, rc) call pvmfunpack(INTEGER4, noderesult, 1, 1, rc) write(6,200) fromid, noderesult write(21,200) fromid, noderesult 20 continue 200 format('Result from task ',I10,': ',I4) c c Close the output file: c close(21) c c Call pvmfexit to terminate the PVM program gracefully... c call pvmfexit(rc) stop end