1 |
jmc |
1.2 |
C $Header: $ |
2 |
|
|
C $Name: $ |
3 |
|
|
|
4 |
jmc |
1.1 |
!======================================================================= |
5 |
|
|
subroutine mitcplr_init2a( myTypeStr ) |
6 |
|
|
implicit none |
7 |
|
|
! Arguments |
8 |
|
|
character*(*) myTypeStr |
9 |
|
|
! Predefined constants/arrays |
10 |
|
|
#include "CPLR_SIG.h" |
11 |
|
|
! MPI variables |
12 |
|
|
#include "mpif.h" |
13 |
|
|
integer myid, numprocs, ierr |
14 |
|
|
! Local |
15 |
|
|
integer n,j,lenbuf |
16 |
|
|
! ------------------------------------------------------------------ |
17 |
|
|
|
18 |
|
|
! Find-out my position (rank) in the "global" communicator |
19 |
|
|
call MPI_COMM_RANK( MPI_COMM_myglobal, myid, ierr ) |
20 |
|
|
if (ierr.ne.0) write(LogUnit,*) 'MITCPLR_init2a: ', |
21 |
|
|
& ' Rank = ',myid,' MPI_COMM_RANK ierr=',ierr |
22 |
|
|
! How big is the "global" comminicator? |
23 |
|
|
call MPI_COMM_SIZE( MPI_COMM_myglobal, numprocs, ierr ) |
24 |
|
|
if (ierr.ne.0) write(LogUnit,*) 'MITCPLR_init2a: ', |
25 |
|
|
& ' Size = ',numprocs,' MPI_COMM_RANK ierr=',ierr |
26 |
|
|
if (VERB) write(LogUnit,*) 'MITCPLR_init2a: ', |
27 |
|
|
& ' Rank/Size = ',myid,' /',numprocs |
28 |
|
|
|
29 |
jmc |
1.2 |
! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
30 |
jmc |
1.1 |
|
31 |
|
|
! Assume nothing again |
32 |
|
|
num_coupler_procs=0 |
33 |
|
|
|
34 |
|
|
! Receive a message from each of the other processes in "myglobal" |
35 |
|
|
do n=0,numprocs-1 |
36 |
|
|
ibuf( 1)=myid |
37 |
|
|
ibuf( 2)=0 |
38 |
|
|
ibuf( 3)=0 |
39 |
|
|
ibuf( 4)=0 |
40 |
|
|
ibuf( 5)=0 |
41 |
|
|
ibuf( 6)=0 |
42 |
|
|
ibuf( 7)=0 |
43 |
|
|
ibuf( 8)=0 |
44 |
|
|
ibuf( 9)=0 |
45 |
|
|
ibuf(10)=0 |
46 |
|
|
ibuf(11)=0 |
47 |
|
|
ibuf(12)=0 |
48 |
|
|
lenbuf=12 |
49 |
|
|
call MPI_Bcast( |
50 |
|
|
& ibuf, lenbuf, MPI_INTEGER, |
51 |
jmc |
1.2 |
& n, |
52 |
jmc |
1.1 |
& MPI_COMM_myglobal, ierr ) |
53 |
|
|
if (ierr.ne.0) write(LogUnit,*) 'MITCPLR_init2a: ', |
54 |
|
|
& ' MPI_Bcast from ',ibuf(1),ibuf(2),' ierr=',ierr |
55 |
|
|
|
56 |
|
|
if ( ibuf(2).eq.MITCPLR_COUPLER ) then |
57 |
|
|
! If the broadcaster is the "coupler" |
58 |
|
|
num_coupler_procs=num_coupler_procs + 1 |
59 |
|
|
num_procs_in_global=num_procs_in_global+1 |
60 |
|
|
rank_coupler_procs(num_coupler_procs) = ibuf(1) |
61 |
|
|
else |
62 |
|
|
! If the broadcaster is a "component" |
63 |
|
|
num_procs_in_local=num_procs_in_local+1 |
64 |
|
|
num_procs_in_global=num_procs_in_global+1 |
65 |
|
|
endif |
66 |
|
|
|
67 |
|
|
enddo |
68 |
|
|
|
69 |
|
|
if (num_coupler_procs .ne. 1) then |
70 |
|
|
stop 'MITCPLR_init2a: I can only handle one coupling process' |
71 |
|
|
endif |
72 |
|
|
|
73 |
jmc |
1.2 |
! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
74 |
jmc |
1.1 |
|
75 |
|
|
! Find-out my position (rank) in the "world" communicator |
76 |
|
|
call MPI_COMM_RANK( MPI_COMM_World, n, ierr ) |
77 |
|
|
if (ierr.ne.0) write(LogUnit,*) 'MITCPLR_init2a: ', |
78 |
|
|
& ' Rank = ',myid,' MPI_COMM_RANK ierr=',ierr |
79 |
|
|
! Find-out my position (rank) in the "local" communicator |
80 |
|
|
call MPI_COMM_RANK( MPI_COMM_myglobal, j, ierr ) |
81 |
|
|
if (ierr.ne.0) write(LogUnit,*) 'MITCPLR_init2a: ', |
82 |
|
|
& ' Rank = ',myid,' MPI_COMM_RANK ierr=',ierr |
83 |
|
|
|
84 |
|
|
! Store the information |
85 |
|
|
my_coupler_rank=rank_coupler_procs(1) |
86 |
|
|
my_rank_in_world=n |
87 |
|
|
my_rank_in_global=myid |
88 |
|
|
my_rank_in_local=j |
89 |
|
|
|
90 |
|
|
if (VERB) write(LogUnit,*) 'MITCPLR_init2a: ', |
91 |
|
|
& ' rank (W,G,L) =', |
92 |
|
|
& my_rank_in_world,my_rank_in_global,my_rank_in_local, |
93 |
|
|
& ' my_coupler_rank =',my_coupler_rank,' /',numprocs |
94 |
|
|
|
95 |
|
|
! ------------------------------------------------------------------ |
96 |
|
|
call flush(LogUnit) |
97 |
|
|
return |
98 |
|
|
end |
99 |
|
|
!======================================================================= |