V3FIT
myfork.f90
1  SUBROUTINE myfork(i, maxprocess, wrapper, fcn)
2  USE system_mod
3  IMPLICIT NONE
4 !-----------------------------------------------
5 ! D u m m y A r g u m e n t s
6 !-----------------------------------------------
7  INTEGER i, maxprocess
8 !-----------------------------------------------
9 ! E x t e r n a l F u n c t i o n s
10 !-----------------------------------------------
11  EXTERNAL wrapper, fcn
12 #if !defined(MPI_OPT)
13 !-----------------------------------------------
14 ! L o c a l V a r i a b l e s
15 !-----------------------------------------------
16  INTEGER :: pid, status, iretpid, ierror, werror
17  INTEGER, SAVE :: nprocess = 0
18 !-----------------------------------------------
19 
20  IF (i .eq. 1) nprocess = 0
21  ierror = -1
22 
23 ! Child process: limit number to max_process to avoid potential system hang-up
24 
25  DO WHILE(ierror .ne. 0)
26 
27  IF (nprocess .lt. maxprocess) CALL pxffork (pid, ierror)
28 
29  IF (ierror .ne. 0) THEN
30 ! wait for next available processor
31  CALL pxfwait (status, iretpid, werror)
32 ! IF (status.gt.0 .and. nprocess.ge.1) THEN
33  IF (nprocess .ge. 1) nprocess = nprocess - 1
34 ! ELSE
35 ! nprocess = 0
36 ! END IF
37  END IF
38  END DO
39 
40  IF (pid .eq. 0) THEN
41  CALL wrapper (i, fcn)
42 #if defined(CRAY)
43  CALL exit(1)
44 #else
45  stop
46 #endif
47  END IF
48 
49  nprocess = nprocess + 1
50 #endif
51  END SUBROUTINE myfork
system_mod::pxffork
Definition: system_mod.f:29
system_mod::pxfwait
Definition: system_mod.f:41