/[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.1 - (show annotations) (download)
Mon Dec 15 02:35:29 2003 UTC (20 years, 5 months ago) by jmc
Branch: MAIN
CVS Tags: checkpoint58l_post, checkpoint57t_post, checkpoint57o_post, checkpoint52l_pre, checkpoint52e_pre, hrcube4, checkpoint58e_post, checkpoint57v_post, checkpoint52n_post, checkpoint52j_post, checkpoint53d_post, checkpoint58u_post, checkpoint58w_post, checkpoint54a_pre, checkpoint57m_post, checkpoint55c_post, checkpoint54e_post, checkpoint52e_post, checkpoint57s_post, checkpoint54a_post, checkpoint53c_post, checkpoint57k_post, checkpoint55d_pre, checkpoint57d_post, checkpoint57g_post, checkpoint57b_post, checkpoint57c_pre, checkpoint58r_post, checkpoint55j_post, checkpoint56b_post, checkpoint57i_post, checkpoint57y_post, checkpoint57e_post, checkpoint52l_post, checkpoint55h_post, checkpoint58n_post, checkpoint58x_post, checkpoint52k_post, checkpoint57g_pre, checkpoint54b_post, checkpoint53b_pre, checkpoint55b_post, checkpoint58t_post, checkpoint58h_post, checkpoint54d_post, checkpoint56c_post, checkpoint52m_post, checkpoint57y_pre, checkpoint55, checkpoint53a_post, checkpoint57f_pre, checkpoint57a_post, checkpoint54, checkpoint58q_post, checkpoint54f_post, checkpoint53b_post, checkpoint55g_post, checkpoint58j_post, checkpoint59e, checkpoint59d, checkpoint59g, checkpoint59f, checkpoint59a, checkpoint55f_post, checkpoint59c, checkpoint59b, checkpoint59h, checkpoint57r_post, checkpoint59, checkpoint58, checkpoint57a_pre, checkpoint55i_post, checkpoint57, checkpoint56, checkpoint53, checkpoint52d_post, eckpoint57e_pre, checkpoint57h_done, checkpoint58f_post, checkpoint53g_post, checkpoint52f_post, checkpoint57x_post, checkpoint57n_post, checkpoint58d_post, checkpoint58c_post, checkpoint57w_post, checkpoint57p_post, checkpint57u_post, checkpoint57f_post, checkpoint58a_post, checkpoint58i_post, checkpoint57q_post, checkpoint58g_post, hrcube5, checkpoint58o_post, checkpoint57z_post, checkpoint57c_post, checkpoint58y_post, checkpoint55e_post, checkpoint58k_post, checkpoint52i_post, checkpoint52j_pre, checkpoint58v_post, checkpoint53f_post, checkpoint55a_post, checkpoint53d_pre, checkpoint54c_post, checkpoint58s_post, checkpoint58p_post, checkpoint57j_post, checkpoint58b_post, checkpoint57h_pre, checkpoint58m_post, checkpoint57l_post, checkpoint52i_pre, checkpoint52h_pre, checkpoint52f_pre, checkpoint57h_post, hrcube_2, hrcube_3, checkpoint56a_post, checkpoint55d_post
coupler - multi-components interface: low-level communication S/R package.

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

  ViewVC Help
Powered by ViewVC 1.1.22