/[MITgcm]/MITgcm/pkg/compon_communic/mitcplr_init1.F
ViewVC logotype

Contents of /MITgcm/pkg/compon_communic/mitcplr_init1.F

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.3 - (show annotations) (download)
Wed Nov 27 21:48:30 2013 UTC (10 years, 5 months ago) by jmc
Branch: MAIN
CVS Tags: checkpoint64y, checkpoint64x, checkpoint64z, checkpoint64s, checkpoint64r, checkpoint64u, checkpoint64t, checkpoint64w, checkpoint64v, checkpoint65, checkpoint66g, checkpoint66f, checkpoint66e, checkpoint66d, checkpoint66c, checkpoint66b, checkpoint66a, checkpoint66o, checkpoint66n, checkpoint66m, checkpoint66l, checkpoint66k, checkpoint66j, checkpoint66i, checkpoint66h, checkpoint65z, checkpoint65x, checkpoint65y, checkpoint65r, checkpoint65s, checkpoint65p, checkpoint65q, checkpoint65v, checkpoint65w, checkpoint65t, checkpoint65u, checkpoint65j, checkpoint65k, checkpoint65h, checkpoint65i, checkpoint65n, checkpoint65o, checkpoint65l, checkpoint65m, checkpoint65b, checkpoint65c, checkpoint65a, checkpoint65f, checkpoint65g, checkpoint65d, checkpoint65e, HEAD
Changes since 1.2: +9 -9 lines
- move declaration of local array "ibuf" out of header file "CPLR_SIG.h"
  to each S/R that needs it; remove un-used variables.

1 C $Header: /u/gcmpack/MITgcm/pkg/compon_communic/mitcplr_init1.F,v 1.2 2007/10/08 23:58:21 jmc Exp $
2 C $Name: $
3
4 !=======================================================================
5 subroutine MITCPLR_init1( myTypeStr, couplerFlag )
6 implicit none
7
8 ! MPI variables
9 #include "mpif.h"
10
11 ! Predefined constants/arrays
12 #include "CPLR_SIG.h"
13
14 ! Arguments
15 character*(*) myTypeStr
16 logical couplerFlag
17
18 ! Functions
19 integer mitcplr_match_comp
20 external mitcplr_match_comp
21
22 ! Local
23 integer myid, numprocs, ierr
24 integer n,j
25 integer MPI_GROUP_World
26 integer MPI_GROUP_Tmp
27 integer lenbuf
28 integer compind
29 integer ibuf(MAX_IBUF)
30 character*(MAXLEN_COMP_NAME) cbuf
31
32 ! ------------------------------------------------------------------
33
34 ! Find-out my position (rank) in the "world" communicator
35 call MPI_COMM_RANK( MPI_COMM_WORLD, myid, ierr )
36 if (ierr.ne.0) write(0,*) 'MITCPLR_init1: ',myid,' ',myTypeStr,
37 & ' Rank = ',myid,' MPI_COMM_RANK ierr=',ierr
38 ! How big is the "world"?
39 call MPI_COMM_SIZE( MPI_COMM_WORLD, numprocs, ierr )
40 if (ierr.ne.0) write(0,*) 'MITCPLR_init1: ',myid,' ',myTypeStr,
41 & ' Size = ',numprocs,' MPI_COMM_RANK ierr=',ierr
42 if (DEBUG) write(0,*) 'MITCPLR_init1: ',myid,' ',myTypeStr,
43 & ' Rank/Size = ',myid,' /',numprocs
44
45 ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
46
47 ! Registration: collect/bcast lists of who is who
48
49 ! Assume nothing
50 num_components = 0
51 num_coupler_procs = 0
52
53 ! Receive a message from each of the other processes
54 do n=0,numprocs-1
55 ibuf(1)=myid
56 ibuf(2)=0
57 if ( couplerFlag ) ibuf(2)=MITCPLR_COUPLER
58 ibuf(3)=0
59 ibuf(4)=0
60 ibuf(5)=0
61 ibuf(6)=0
62 ibuf(7)=0
63 call mitcplr_char2int( myTypeStr, ibuf(8) )
64 lenbuf=8+MAXLEN_COMP_NAME
65 call MPI_Bcast(
66 & ibuf, lenbuf, MPI_INTEGER,
67 & n,
68 & MPI_COMM_WORLD, ierr )
69 if (DEBUG) write(0,*) 'MITCPLR_init1: ',myid,' ',myTypeStr,
70 & ' MPI_Bcast from ',ibuf(1),ibuf(2),' ierr=',ierr
71 call mitcplr_int2char( ibuf(8), cbuf )
72 if (DEBUG) write(0,*) 'MITCPLR_init1: ',myid,' ',myTypeStr,
73 & ' Bcast cbuf=',cbuf,'x'
74
75 if ( ibuf(2).eq.MITCPLR_COUPLER ) then
76 ! If the broadcaster is the "coupler"
77 num_coupler_procs=num_coupler_procs + 1
78 rank_coupler_procs(num_coupler_procs) = ibuf(1)
79 coupler_Name=cbuf
80 else
81 ! If the broadcaster is a "component"
82 compind=mitcplr_match_comp( cbuf )
83 if (DEBUG) write(0,*) 'MITCPLR_init1: ',myid,' ',myTypeStr,
84 & ' compind=',compind
85 num_component_procs(compind)=num_component_procs(compind) + 1
86 j=num_component_procs(compind)
87 rank_component_procs(j,compind)=ibuf(1)
88 endif
89
90 enddo
91
92 if ( num_coupler_procs .ne. 1 ) then
93 STOP 'MITCPLR_init1: I can only handle one coupler process'
94 endif
95
96 do compind=1,num_components
97 num_compcplr_procs(compind)=num_component_procs(compind) + 1
98 do j=1,num_compcplr_procs(compind)
99 rank_compcplr_procs(j,compind)=rank_component_procs(j,compind)
100 enddo
101 j=num_compcplr_procs(compind)
102 rank_compcplr_procs(j,compind)=rank_coupler_procs(1)
103 call mitcplr_sortranks( j, rank_compcplr_procs(1,compind) )
104 enddo
105
106 if (DEBUG) write(0,*) 'MITCPLR_init1: ',myid,' ',myTypeStr,
107 & ' coupler=',coupler_Name,
108 & ( rank_coupler_procs(j),j=1,num_coupler_procs )
109 do n=1,num_components
110 if (DEBUG) write(0,*) 'MITCPLR_init1: ',myid,' ',myTypeStr,
111 & ' component=',component_Name(n),
112 & ( rank_component_procs(j,n),j=1,num_component_procs(n) )
113 if (DEBUG) write(0,*) 'MITCPLR_init1: ',myid,' ',myTypeStr,
114 & ' comp+cplr=',component_Name(n),
115 & ( rank_compcplr_procs(j,n),j=1,num_compcplr_procs(n) )
116 enddo
117
118 ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
119
120 ! Create new groups and communicators
121
122 ! Establish MPI_GROUP_World associated with MPI_COMM_WORLD
123 call MPI_Comm_group( MPI_COMM_WORLD, MPI_GROUP_World, ierr )
124 if (DEBUG) write(0,*) 'MITCPLR_init1: ',myid,' ',myTypeStr,
125 & ' MPI_Comm_group MPI_GROUP_World=',MPI_GROUP_World,
126 & ' ierr=',ierr
127
128 do n=1,num_components
129
130 ! Create group MPI_GROUP_Tmp
131 call MPI_Group_incl(
132 & MPI_GROUP_World,
133 & num_component_procs(n),
134 & rank_component_procs(1,n),
135 & MPI_GROUP_Tmp,
136 & ierr )
137 if (DEBUG) write(0,*) 'MITCPLR_init1: ',myid,' ',myTypeStr,
138 & ' MPI_Group_incl MPI_GROUP_Tmp=',
139 & MPI_GROUP_Tmp,' ierr=',ierr
140
141 ! Create communicator MPI_COMM_component
142 call MPI_Comm_create(
143 & MPI_COMM_WORLD,
144 & MPI_GROUP_Tmp,
145 & MPI_COMM_component(n),
146 & ierr )
147 if (DEBUG) write(0,*) 'MITCPLR_init1: ',myid,' ',myTypeStr,
148 & ' MPI_Comm_create MPI_COMM_component=',MPI_COMM_component(n),
149 & ' ierr=',ierr
150
151 ! Create group MPI_GROUP_Tmp
152 call MPI_Group_incl(
153 & MPI_GROUP_World,
154 & num_compcplr_procs(n),
155 & rank_compcplr_procs(1,n),
156 & MPI_GROUP_Tmp,
157 & ierr )
158 if (DEBUG) write(0,*) 'MITCPLR_init1: ',myid,' ',myTypeStr,
159 & ' MPI_Group_incl MPI_GROUP_Tmp=',
160 & MPI_GROUP_Tmp,' ierr=',ierr
161
162 ! Create communicator MPI_COMM_compcplr
163 call MPI_Comm_create(
164 & MPI_COMM_WORLD,
165 & MPI_GROUP_Tmp,
166 & MPI_COMM_compcplr(n),
167 & ierr )
168 if (DEBUG) write(0,*) 'MITCPLR_init1: ',myid,' ',myTypeStr,
169 & ' MPI_Comm_create MPI_COMM_compcplr=',MPI_COMM_compcplr(n),
170 & ' ierr=',ierr
171
172 enddo
173
174 ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
175
176 if ( couplerFlag ) then
177 my_component_ind=-1
178 MPI_COMM_mylocal=MPI_COMM_World
179 MPI_COMM_myglobal=MPI_COMM_World
180 my_component_name=coupler_Name
181 else
182 compind=mitcplr_match_comp( myTypeStr )
183 my_component_ind=compind
184 MPI_COMM_mylocal=MPI_COMM_component( compind )
185 MPI_COMM_myglobal=MPI_COMM_compcplr( compind )
186 my_component_name=component_Name( compind )
187 endif
188
189 if (DEBUG) write(0,*) 'MITCPLR_init1: ',myid,' ',myTypeStr,
190 & ' component num=',compind,
191 & ' MPI_COMM=',MPI_COMM_mylocal,MPI_COMM_myglobal
192
193 if ( couplerFlag ) then
194 do n=1,num_components
195 ! Find-out my position (rank) in the "global" communicator
196 call MPI_COMM_RANK( MPI_COMM_compcplr(n), j, ierr )
197 if (ierr.ne.0) write(0,*) 'MITCPLR_init1: ',myid,' ',myTypeStr,
198 & ' Rank = ',j,' MPI_COMM_RANK ierr=',ierr
199 ! How big is the "global" communicator?
200 call MPI_COMM_SIZE( MPI_COMM_compcplr(n), numprocs, ierr )
201 if (ierr.ne.0) write(0,*) 'MITCPLR_init1: ',myid,' ',myTypeStr,
202 & ' Size = ',numprocs,' MPI_COMM_SIZE ierr=',ierr
203 if (DEBUG) write(0,*) 'MITCPLR_init1: ',myid,' ',myTypeStr,
204 & ' Rank/Size = ',j,' /',numprocs,
205 & ' in Component =',n
206 enddo
207 else
208 ! Find-out my position (rank) in the "global" communicator
209 call MPI_COMM_RANK( MPI_COMM_myglobal, j, ierr )
210 if (ierr.ne.0) write(0,*) 'MITCPLR_init1: ',myid,' ',myTypeStr,
211 & ' Rank = ',j,' MPI_COMM_RANK ierr=',ierr
212 ! How big is the "global" communicator?
213 call MPI_COMM_SIZE( MPI_COMM_myglobal, numprocs, ierr )
214 if (ierr.ne.0) write(0,*) 'MITCPLR_init1: ',myid,' ',myTypeStr,
215 & ' Size = ',numprocs,' MPI_COMM_SIZE ierr=',ierr
216 if (DEBUG) write(0,*) 'MITCPLR_init1: ',myid,' ',myTypeStr,
217 & ' Rank/Size = ',j,' /',numprocs
218 endif
219
220 ! Open log file
221 if ( couplerFlag ) j=myid
222 write(cbuf(1:MAXLEN_COMP_NAME),'(2a,i4.4,a)')
223 & myTypeStr,'.',j,'.clog'
224 open(LogUnit,file=cbuf,status='unknown',form='formatted')
225 write(LogUnit,'(2a)') '========================================',
226 & '========================================'
227 write(LogUnit,*) 'This is "',myTypeStr,'"'
228 write(LogUnit,*) 'myid in MPI_COMM_World = ',myid
229 if (.not.couplerFlag)
230 & write(LogUnit,*) 'myid in MPI_COMM_Global = ',j
231
232 ! ------------------------------------------------------------------
233 return
234 end
235 !=======================================================================

  ViewVC Help
Powered by ViewVC 1.1.22