CALL FMSPAR (NUMPAR, SNAME, P1, P2, ...)
CALL FMSRUN
CALL FMSYNC
| Parameter | Description |
|---|---|
| MAXCPU | Number of processors to use. |
| MYNODE | Your process number. |
For example, we will assume subroutine USERSUB has 3 arguments, A1, A2 and A3. You use the FMS parallel processing utilities to call USERSUB in parallel as follows:
EXTERNAL USERSUB
...
CALL FMSIGT ('MAXCPU', MAXCPU)
DO MYCPU = 2,MAXCPU
CALL FMSPAR (3, USERSUB, A1, A2, A3)
ENDDO
IF(MAXCPU .GT. 1) CALL FMSRUN
CALL USERSUB (A1, A2, A3)
IF(MAXCPU .GT. 1) CALL FMSYNC
The EXTERNAL statement lets the compiler know that USERSUB is a subroutine name (global symbol) and not a local variable. You must declare all subroutines passed to FMSPAR as
EXTERNAL.
You may call FMSIGT to obtain MAXCPU, the number of processors actually running.
You then call FMSPAR to place the work for the children in a queue. After all of the work has been queued, you call FMSRUN to start the children running.
After the children are running, USERSUB is called by the parent to do it's share of the work. The parent then calls FMSYNC to wait for the completion of the children.
Note that if there is only one process (MAXCPU=1), FMSPAR , FMSRUN and FMSYNC are not called.
In subroutine USERSUB you may include the statement
CALL FMSIGT('MYNODE',MYNODE)
to obtain the process number of the subroutine. You may then use the value of MYNODE to determine your piece of work.