/[MITgcm]/MITgcm/eesupp/src/ini_threading_environment.F
ViewVC logotype

Annotation of /MITgcm/eesupp/src/ini_threading_environment.F

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


Revision 1.8 - (hide annotations) (download)
Fri Sep 21 03:54:35 2001 UTC (22 years, 8 months ago) by cnh
Branch: MAIN
CVS Tags: checkpoint46n_post, checkpoint51k_post, checkpoint47e_post, checkpoint52l_pre, checkpoint44e_post, hrcube4, hrcube5, checkpoint46l_post, checkpoint46g_pre, checkpoint47c_post, release1_p13_pre, checkpoint50c_post, checkpoint46f_post, checkpoint52d_pre, checkpoint48e_post, checkpoint50c_pre, checkpoint44f_post, checkpoint46b_post, checkpoint52j_pre, checkpoint43a-release1mods, checkpoint51o_pre, ecco_c50_e32, ecco_c50_e33, ecco_c50_e30, ecco_c50_e31, release1_p13, checkpoint51l_post, checkpoint48i_post, checkpoint46l_pre, checkpoint52l_post, checkpoint52k_post, chkpt44d_post, checkpoint51, checkpoint50, checkpoint52, release1_p8, release1_p9, checkpoint50d_post, release1_p1, release1_p2, release1_p3, release1_p4, release1_p5, release1_p6, release1_p7, checkpoint52f_post, checkpoint50b_pre, checkpoint44e_pre, checkpoint51f_post, release1_b1, ecco_c51_e34d, ecco_c51_e34e, ecco_c51_e34f, ecco_c51_e34g, ecco_c51_e34a, ecco_c51_e34b, ecco_c51_e34c, checkpoint48b_post, checkpoint43, checkpoint51d_post, checkpoint48c_pre, checkpoint47d_pre, checkpoint51t_post, checkpoint51n_post, release1_chkpt44d_post, checkpoint52i_pre, hrcube_1, hrcube_2, hrcube_3, checkpoint51s_post, checkpoint47a_post, checkpoint48d_pre, checkpoint51j_post, checkpoint47i_post, checkpoint52e_pre, release1_p11, checkpoint52e_post, checkpoint51n_pre, checkpoint47d_post, icebear5, icebear4, icebear3, icebear2, checkpoint46d_pre, checkpoint48d_post, release1-branch_tutorials, checkpoint48f_post, checkpoint45d_post, checkpoint52b_pre, checkpoint46j_pre, checkpoint51l_pre, chkpt44a_post, checkpoint44h_pre, checkpoint48h_post, checkpoint51q_post, ecco_c50_e29, checkpoint51b_pre, checkpoint46a_post, checkpoint47g_post, checkpoint52b_post, checkpoint52c_post, checkpoint46j_post, checkpoint51h_pre, checkpoint46k_post, ecco_c50_e28, chkpt44c_pre, checkpoint48a_post, checkpoint45a_post, checkpoint50f_post, checkpoint50a_post, checkpoint50f_pre, checkpoint52f_pre, ecco_c44_e19, ecco_c44_e18, ecco_c44_e17, ecco_c44_e16, release1_p12, release1_p10, release1_p16, release1_p17, release1_p14, release1_p15, checkpoint47j_post, ecco_c50_e33a, branch-exfmods-tag, checkpoint44g_post, branchpoint-genmake2, checkpoint46e_pre, checkpoint51r_post, checkpoint48c_post, checkpoint45b_post, checkpoint46b_pre, checkpoint51i_post, release1-branch-end, release1_final_v1, checkpoint51b_post, checkpoint51c_post, checkpoint46c_pre, checkpoint46, checkpoint47b_post, checkpoint44b_post, ecco_c51_e34, checkpoint46h_pre, checkpoint52d_post, checkpoint46m_post, checkpoint46a_pre, checkpoint50g_post, checkpoint45c_post, ecco_ice2, ecco_ice1, checkpoint44h_post, checkpoint46g_post, release1_p12_pre, checkpoint52a_pre, ecco_c44_e22, checkpoint50h_post, checkpoint52i_post, checkpoint50e_pre, checkpoint50i_post, ecco_c44_e25, checkpoint51i_pre, checkpoint52h_pre, checkpoint52j_post, checkpoint47f_post, checkpoint50e_post, chkpt44a_pre, checkpoint46i_post, ecco_c44_e23, ecco_c44_e20, ecco_c44_e21, ecco_c44_e26, ecco_c44_e27, ecco_c44_e24, checkpoint46c_post, ecco-branch-mod1, ecco-branch-mod2, ecco-branch-mod3, ecco-branch-mod4, ecco-branch-mod5, branch-netcdf, checkpoint50d_pre, checkpoint46e_post, release1_beta1, checkpoint51e_post, checkpoint44b_pre, checkpoint42, checkpoint41, checkpoint47, checkpoint44, checkpoint45, checkpoint48, checkpoint49, checkpoint46h_post, checkpoint51o_post, checkpoint51f_pre, chkpt44c_post, checkpoint48g_post, checkpoint47h_post, checkpoint52a_post, checkpoint44f_pre, checkpoint51g_post, ecco_c52_e35, checkpoint46d_post, checkpoint50b_post, release1-branch_branchpoint, checkpoint51m_post, checkpoint51a_post, checkpoint51p_post, checkpoint51u_post
Branch point for: c24_e25_ice, branch-exfmods-curt, release1_final, release1-branch, branch-genmake2, release1, branch-nonh, tg2-branch, ecco-branch, release1_50yr, netcdf-sm0, icebear, checkpoint51n_branch, release1_coupled
Changes since 1.7: +25 -16 lines
Starting to bring comments up to date and format comments
for document extraction of "prototypes".

1 cnh 1.8 C $Header: /u/gcmpack/models/MITgcmUV/eesupp/src/ini_threading_environment.F,v 1.7 2001/02/04 14:38:43 cnh Exp $
2     C $Name: $
3 cnh 1.1
4     #include "CPP_EEOPTIONS.h"
5    
6 cnh 1.8 CBOP
7    
8     C !ROUTINE: INI_THREADING_ENVIRONMENT
9    
10     C !INTERFACE:
11 cnh 1.1 SUBROUTINE INI_THREADING_ENVIRONMENT
12 adcroft 1.6 IMPLICIT NONE
13 cnh 1.1
14 cnh 1.8 C !DESCRIPTION:
15     C *==========================================================*
16     C | SUBROUTINE INI_THREADING_ENVIRONMENT
17     C | o Initialise multi-threaded environment.
18     C *==========================================================*
19     C | Generally we do not start separate threads here.
20     C | The separate threads a spawned at later on.
21     C | Here we perform initialisation of data-structures
22     C | that indicate which of the nSx x nSy tiles a thread is
23     C | responsible for.
24     C | The multiple threads are spawned in the top level MAIN
25     C | routine.
26     C *==========================================================*
27    
28     C !USES:
29 cnh 1.1 C == Global data ==
30     #include "SIZE.h"
31     #include "EEPARAMS.h"
32     #include "EESUPPORT.h"
33    
34 cnh 1.8 C !LOCAL VARIABLES:
35 cnh 1.1 C == Local variables ==
36     C bXPerThread - Blocks of size sNx per thread.
37     C byPerThread - Blocks of size sNy per thread.
38     C Thid - Thread index. Temporary used in loops
39     C which set per. thread values on a
40     C cartesian grid.
41     C bxLo, bxHi - Work vars. for thread index
42     C byLo, byHi range. bxLo is the lowest i index
43     C that a thread covers, bxHi is the
44     C highest i index. byLo is the lowest
45     C j index, byHi is the highest j index.
46     C I, J - Loop counter
47     C msgBuf - I/O buffer for reporting status information.
48     C myThid - Dummy thread id for use in printed messages
49 cnh 1.5 C ( this routine "INI_THREADING_ENVIRONMENT" is
50     C called before multi-threading has started.)
51 cnh 1.1 INTEGER bxPerThread
52     INTEGER byPerThread
53     INTEGER Thid
54     INTEGER bxLo, bxHi
55     INTEGER byLo, byHi
56 cnh 1.5 INTEGER I, J, nT
57 cnh 1.1 CHARACTER*(MAX_LEN_MBUF) msgBuf
58     INTEGER myThid
59 cnh 1.8
60     CEOP
61 cnh 1.1
62     C-- Set default for all threads of having no blocks to
63     C-- work on - except for thread 1.
64     myBxLo(1) = 1
65     myBxHi(1) = nSx
66     myByLo(1) = 1
67     myByHi(1) = nSy
68     DO I = 2, MAX_NO_THREADS
69     myBxLo(I) = 0
70 cnh 1.5 myBxHi(I) = 0
71 cnh 1.1 myByLo(I) = 0
72 cnh 1.5 myByHi(I) = 0
73 cnh 1.1 ENDDO
74     myThid = 1
75 cnh 1.5 commName(COMM_NONE) = 'none'
76     commName(COMM_MSG ) = 'messages'
77     commName(COMM_PUT ) = 'put'
78     commName(COMM_GET ) = 'get'
79 cnh 1.1
80     C-- If there are multiple threads allocate different range of the
81     C-- nSx*nSy blocks to each thread.
82     C For now handle simple case of no. blocks nSx = n*nTx and
83     C no. blocks nSy = m*nTy ( where m and n are integer ). This
84     C is handled by simply mapping threads to blocks in sequence
85     C with the x thread index moving fastest.
86     C Later code which sets the thread number of neighboring blocks
87 cnh 1.5 C needs to be consistent with the code here.
88 cnh 1.1 nThreads = nTx * nTy
89    
90 cnh 1.5 C-- Initialise the barrier mechanisms
91     C BAR2 will eventually replace barrier everywhere.
92 cnh 1.1 CALL BARRIER_INIT
93 cnh 1.5 DO I=1, MAX_NO_THREADS
94     CALL BAR2_INIT(I)
95     ENDDO
96    
97     C-- Initialise exchange mechanism
98     CALL EXCH_INIT
99 cnh 1.1
100     IF ( nThreads .NE. nTx*nTy ) THEN
101 adcroft 1.6 WRITE(msgBuf,'(A,A,A,I5,A,I5)')
102 cnh 1.1 & 'S/R INI_THREADING_ENVIRONMENT:',
103     & ' Total number of threads is not the same as nTx*nTy.',
104     & ' nTx * nTy = ',nTx*nTy,' nThreads = ',nThreads
105     CALL PRINT_ERROR(msgBuf, myThid)
106     eeBootError = .TRUE.
107     STOP 'ABNORMAL END: S/R INI_THREADING_ENVIRONMENT'
108     ENDIF
109     bxPerThread = nSx/nTx
110     IF ( bxPerThread*nTx .NE. nSx ) THEN
111 cnh 1.5 WRITE(msgBuf,'(A,A,A)')
112 cnh 1.1 & 'S/R INI_THREADING_ENVIRONMENT:',
113 cnh 1.5 & ' Number of blocks in X (nSx)',
114     & ' must be exact multiple of threads in X (nTx).'
115 cnh 1.1 CALL PRINT_ERROR(msgBuf, myThid)
116     eeBootError = .TRUE.
117     STOP 'ABNORMAL END: S/R INI_THREADING_ENVIRONMENT'
118     ENDIF
119     byPerThread = nSy/nTy
120     IF ( byPerThread*nTy .NE. nSy ) THEN
121 cnh 1.5 WRITE(msgBuf,'(A,A,A)')
122 cnh 1.1 & 'S/R INI_THREADING_ENVIRONMENT:',
123 cnh 1.5 & ' Number of blocks in Y (nSy)',
124     & ' must be exact multiple of threads in Y (nTy).'
125 cnh 1.1 CALL PRINT_ERROR(msgBuf, myThid)
126     eeBootError = .TRUE.
127     STOP 'ABNORMAL END: S/R INI_THREADING_ENVIRONMENT'
128     ENDIF
129     IF ( .NOT. eeBootError ) THEN
130     byLo = 1
131     DO J=1,nTy
132     byHi = byLo+byPerThread-1
133     bxLo = 1
134     DO I=1,nTx
135     Thid = (J-1)*nTx+I
136     bxHi = bxLo+bxPerThread-1
137     myBxLo(Thid) = bxLo
138     myBxHi(Thid) = bxHi
139     myByLo(Thid) = byLo
140     myByHi(Thid) = byHi
141     bxLo = bxHi+1
142     ENDDO
143     byLo = byHi+1
144     ENDDO
145     ENDIF
146    
147 cnh 1.5 DO nT=1,nThreads
148     CALL INI_COMMUNICATION_PATTERNS( nT )
149 cnh 1.1 ENDDO
150    
151     C-- Print mapping of threads to grid points.
152 cnh 1.5 WRITE(msgBuf,'(A)')
153     &'// ======================================================'
154 cnh 1.1 CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
155     & SQUEEZE_RIGHT , 1)
156     WRITE(msgBuf,'(A)') '// Mapping of tiles to threads'
157     CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
158     & SQUEEZE_RIGHT , 1)
159 cnh 1.5 C o Write list of tiles each thread is responsible for
160     WRITE(msgBuf,'(A)')
161     &'// ======================================================'
162 cnh 1.1 CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
163     & SQUEEZE_RIGHT , 1)
164     DO I=1,nThreads
165     WRITE(msgBuf,'(A,I4,A,4(I4,A1))')
166     & '// -o- Thread',I,', tiles (',
167     & myBxLo(I),':',myBxHi(I),',',myByLo(I),':',myByHi(I),')'
168 cnh 1.5 CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,SQUEEZE_BOTH , 1)
169 cnh 1.1 ENDDO
170     WRITE(msgBuf,'(A)') ' '
171 cnh 1.5 CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,SQUEEZE_RIGHT , 1)
172 cnh 1.1
173 cnh 1.5 C o For each tile print its communication method(s)
174     WRITE(msgBuf,'(A)')
175     &'// ======================================================'
176     CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
177     & SQUEEZE_RIGHT , 1)
178     WRITE(msgBuf,'(A)') '// Tile <-> Tile connectvity table'
179     CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
180     & SQUEEZE_RIGHT , 1)
181     WRITE(msgBuf,'(A)')
182     &'// ======================================================'
183     CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
184     & SQUEEZE_RIGHT , 1)
185     DO J=1,nSy
186     DO I=1,nSx
187     WRITE(msgBuf,'(A,A,I6.6,A,I6.6,A)')
188     & '//',' Tile number: ',tileNo(I,J),
189     & ' (process no. = ',myPid,')'
190     CALL PRINT_MESSAGE(msgBuf,standardMessageUnit,SQUEEZE_RIGHT , 1)
191     C o West communication details
192     IF ( tileNoW(I,J).NE. NULL_TILE ) THEN
193     WRITE(msgBuf,'(A,A,I6.6,A,I6.6,A,A)')
194     & '// WEST: ',
195     & 'Tile = ',tileNoW(I,J),
196     & ', Process = ',tilePidW(I,J),
197     & ', Comm = ',commName(tileCommModeW(I,J))
198     CALL PRINT_MESSAGE(msgBuf,standardMessageUnit,SQUEEZE_RIGHT, 1)
199     WRITE(msgBuf,'(A,A,I6.6,A,I6.6)')
200     & '// ',
201     & ' bi = ',tileBiW(I,J),
202     & ', bj = ',tileBjW(I,J)
203     CALL PRINT_MESSAGE(msgBuf,standardMessageUnit,SQUEEZE_RIGHT, 1)
204     ELSE
205     WRITE(msgBuf,'(A)')
206     & '// WEST: no neighbor'
207     CALL PRINT_MESSAGE(msgBuf,standardMessageUnit,SQUEEZE_RIGHT, 1)
208     ENDIF
209     C o East communication details
210     IF ( tileNoE(I,J).NE. NULL_TILE ) THEN
211     WRITE(msgBuf,'(A,A,I6.6,A,I6.6,A,A)')
212     & '// EAST: ',
213     & 'Tile = ',tileNoE(I,J),
214     & ', Process = ',tilePidE(I,J),
215     & ', Comm = ',commName(tileCommModeE(I,J))
216     CALL PRINT_MESSAGE(msgBuf,standardMessageUnit,SQUEEZE_RIGHT, 1)
217     WRITE(msgBuf,'(A,A,I6.6,A,I6.6)')
218     & '// ',
219     & ' bi = ',tileBiE(I,J),
220     & ', bj = ',tileBjE(I,J)
221     CALL PRINT_MESSAGE(msgBuf,standardMessageUnit,SQUEEZE_RIGHT, 1)
222     ELSE
223     WRITE(msgBuf,'(A)')
224     & '// EAST: no neighbor'
225     CALL PRINT_MESSAGE(msgBuf,standardMessageUnit,SQUEEZE_RIGHT, 1)
226     ENDIF
227     C o South communication method
228     IF ( tileNoS(I,J).NE. NULL_TILE ) THEN
229     WRITE(msgBuf,'(A,A,I6.6,A,I6.6,A,A)')
230     & '// SOUTH: ',
231     & 'Tile = ',tileNoS(I,J),
232     & ', Process = ',tilePidS(I,J),
233     & ', Comm = ',commName(tileCommModeS(I,J))
234     CALL PRINT_MESSAGE(msgBuf,standardMessageUnit,SQUEEZE_RIGHT, 1)
235     WRITE(msgBuf,'(A,A,I6.6,A,I6.6)')
236     & '// ',
237     & ' bi = ',tileBiS(I,J),
238     & ', bj = ',tileBjS(I,J)
239     CALL PRINT_MESSAGE(msgBuf,standardMessageUnit,SQUEEZE_RIGHT, 1)
240     ELSE
241     WRITE(msgBuf,'(A)')
242     & '// SOUTH: no neighbor'
243     CALL PRINT_MESSAGE(msgBuf,standardMessageUnit,SQUEEZE_RIGHT, 1)
244     ENDIF
245     C o North communication method
246     IF ( tileNoN(I,J).NE. NULL_TILE ) THEN
247     WRITE(msgBuf,'(A,A,I6.6,A,I6.6,A,A)')
248     & '// NORTH: ',
249     & 'Tile = ',tileNoN(I,J),
250     & ', Process = ',tilePidN(I,J),
251     & ', Comm = ',commName(tileCommModeN(I,J))
252     CALL PRINT_MESSAGE(msgBuf,standardMessageUnit,SQUEEZE_RIGHT, 1)
253     WRITE(msgBuf,'(A,A,I6.6,A,I6.6)')
254     & '// ',
255     & ' bi = ',tileBiN(I,J),
256     & ', bj = ',tileBjN(I,J)
257     CALL PRINT_MESSAGE(msgBuf,standardMessageUnit,SQUEEZE_RIGHT, 1)
258     ELSE
259     WRITE(msgBuf,'(A)')
260     & '// NORTH: no neighbor'
261     CALL PRINT_MESSAGE(msgBuf,standardMessageUnit,SQUEEZE_RIGHT, 1)
262 cnh 1.1 ENDIF
263     ENDDO
264     ENDDO
265 cnh 1.5 WRITE(msgBuf,'(A)') ' '
266     CALL PRINT_MESSAGE( msgBuf,standardMessageUnit,SQUEEZE_RIGHT, 1)
267 cnh 1.1
268     RETURN
269     END

  ViewVC Help
Powered by ViewVC 1.1.22