File: btprim_PVM.f

package info (click to toggle)
blacs-mpi 1.1-28.2
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 2,320 kB
  • ctags: 2,031
  • sloc: fortran: 14,968; ansic: 12,353; makefile: 531; sh: 1
file content (481 lines) | stat: -rw-r--r-- 13,250 bytes parent folder | download | duplicates (15)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
      SUBROUTINE BTSETUP( MEM, MEMLEN, CMEM, CMEMLEN, OUTNUM,
     $                    TESTSDRV, TESTBSBR, TESTCOMB, TESTAUX,
     $                    IAM, NNODES )
*
*  -- BLACS tester (version 1.0) --
*  University of Tennessee
*  December 15, 1994
*
*     .. Scalar Arguments ..
      LOGICAL TESTSDRV, TESTBSBR, TESTCOMB, TESTAUX
      INTEGER MEMLEN, CMEMLEN, OUTNUM, IAM, NNODES
*     ..
*     .. Array Arguments ..
      INTEGER MEM(MEMLEN)
      CHARACTER*1 CMEM(CMEMLEN)
*     ..
*
*  Purpose
*  =======
*  BTSETUP:  Fills in process number array, and sets up machine on
*            dynamic systems.
*
*  Arguments
*  =========
*  MEM      (input) INTEGER array, dimension MEMSIZE
*           Scratch pad memory area.
*
*  MEMLEN   (input) INTEGER
*           Number of safe elements in MEM.
*
*  CMEM     (input) CHARACTER array, dimension CMEMSIZE
*           Scratch pad memory area.
*
*  CMEMLEN  (input) INTEGER
*           Number of safe elements in MEM.
*
*  OUTNUM   (input/output) INTEGER
*           Unit number of output file for top level error information.
*           Input for process 0.  Set to zero as output for all other
*           processes as a safety precaution.
*
*  TESTSDRV (input) LOGICAL
*           Will there be point-to-point tests in this test run?
*
*  TESTBSBR (input) LOGICAL
*           Will there be broadcast tests in this test run?
*
*  TESTCOMB (input) LOGICAL
*           Will there be combine-operator tests in this test run?
*
*  TESTAUX  (input) LOGICAL
*           Will there be auxiliary tests in this test run?
*
*  IAM      (input/output) INTEGER
*           This process's node number.
*
*  NNODES   (input/output) INTEGER
*           Number of processes that are started up by this subroutine.
*
*  ====================================================================
*
*     .. Local Scalars ..
      INTEGER I, CONTEXT, MEMUSED, CMEMUSED, NGRID, PPTR, QPTR
*     ..
*     .. External Functions ..
      INTEGER BLACS_PNUM
      EXTERNAL BLACS_PNUM
*     ..
*     .. External Subroutines ..
      EXTERNAL BLACS_SETUP, BLACS_GRIDINIT, BLACS_GRIDEXIT
*     ..
*     .. Common blocks ..
      COMMON /BTPNUM/ BTPNUMS
*     ..
*     .. Arrays in Common ..
      INTEGER BTPNUMS(0:999)
*     ..
*     .. Executable Statements ..
*
      IF( NNODES .GT. 0 ) RETURN
      IF ( IAM .EQ. 0 ) THEN
         IF ( TESTSDRV ) THEN
*
*           Determine the max number of nodes required by a SDRV tests
*
            CALL RDSDRV( MEMUSED, MEM, MEMLEN, CMEMUSED, CMEM, CMEMLEN,
     $                   OUTNUM )
            IF( (MEMUSED + 24) .GT. MEMLEN ) THEN
               WRITE(OUTNUM, *) 'Not enough memory to read in sdrv.dat'
               STOP
            END IF
*
            I = MEMUSED + 1
            CALL BTUNPACK( 'SDRV', MEM, MEMUSED, MEM(I+1), MEM(I+2),
     $                     MEM(I+22), MEM(I+23), MEM(I+12), MEM(I+20),
     $                     MEM(I+3), MEM(I+13), NGRID, MEM(I+4),
     $                     MEM(I+14), MEM(I+21), MEM(I+5), MEM(I+15),
     $                     MEM(I+6), MEM(I+16), MEM(I+7), MEM(I+17),
     $                     MEM(I+8), MEM(I+18), MEM(I+9), MEM(I+19),
     $                     MEM(I+11), PPTR, QPTR )
*
            DO 10 I = 0, NGRID-1
               NNODES = MAX0( MEM(PPTR+I) * MEM(QPTR+I), NNODES )
   10       CONTINUE
         END IF
         IF( TESTBSBR ) THEN
*
*           Determine the maximum number of nodes required by a
*           broadcast test case
*
            CALL RDBSBR( MEMUSED, MEM, MEMLEN, CMEMUSED, CMEM, CMEMLEN,
     $                   OUTNUM )
            I = MEMUSED + 1
            CALL BTUNPACK( 'BSBR', MEM, MEMUSED, MEM(I+1), MEM(I+2),
     $                     MEM(I+22), MEM(I+23), MEM(I+12), MEM(I+20),
     $                     MEM(I+3), MEM(I+13), NGRID, MEM(I+4),
     $                     MEM(I+14), MEM(I+21), MEM(I+5), MEM(I+15),
     $                     MEM(I+6), MEM(I+16), MEM(I+7), MEM(I+17),
     $                     MEM(I+8), MEM(I+18), MEM(I+9), MEM(I+19),
     $                     MEM(I+11), PPTR, QPTR )
            DO 20 I = 0, NGRID-1
               NNODES = MAX0( MEM(PPTR+I) * MEM(QPTR+I), NNODES )
   20       CONTINUE
*
         END IF
         IF( TESTCOMB ) THEN
*
*           Determine the maximum number of nodes required by a
*           combine test case
*
            CALL RDCOMB( MEMUSED, MEM, MEMLEN, CMEMUSED, CMEM, CMEMLEN,
     $                   OUTNUM )
            I = MEMUSED + 1
            CALL BTUNPACK( 'COMB', MEM, MEMUSED, MEM(I+1), MEM(I+2),
     $                     MEM(I+22), MEM(I+23), MEM(I+12), MEM(I+20),
     $                     MEM(I+3), MEM(I+13), NGRID, MEM(I+4),
     $                     MEM(I+14), MEM(I+21), MEM(I+5), MEM(I+15),
     $                     MEM(I+6), MEM(I+16), MEM(I+7), MEM(I+17),
     $                     MEM(I+8), MEM(I+18), MEM(I+9), MEM(I+19),
     $                     MEM(I+11), PPTR, QPTR )
*
            DO 30 I = 0, NGRID-1
               NNODES = MAX0( MEM(PPTR+I) * MEM(QPTR+I), NNODES )
   30       CONTINUE
         END IF
      END IF
*
*     If we run auxiliary tests, must have at least two nodes,
*     otherwise, minimum is 1
*
      IF( TESTAUX ) THEN
         NNODES = MAX0( NNODES, 2 )
      ELSE
         NNODES = MAX0( NNODES, 1 )
      END IF
*
      CALL BLACS_SETUP( IAM, NNODES )
*
*     We've buried a PNUM array in the common block above, and here
*     we initialize it.  The reason for carrying this along is so that
*     the TSEND and TRECV subroutines can report test results back to
*     the first process, which can then be the sole process
*     writing output files.
*
      CALL BLACS_GET( 0, 0, CONTEXT )
      CALL BLACS_GRIDINIT( CONTEXT, 'r', 1, NNODES )
*
      DO 40 I = 0, NNODES-1
         BTPNUMS(I) = BLACS_PNUM( CONTEXT, 0, I )
   40 CONTINUE
*
      CALL BLACS_GRIDEXIT( CONTEXT )
*
      RETURN
*
*     End of BTSETUP.
*
      END
*
      INTEGER FUNCTION IBTMYPROC()
*
*  -- BLACS tester (version 1.0) --
*  University of Tennessee
*  December 15, 1994
*
*  Purpose
*  =======
*  IBTMYPROC: returns a process number between 0 .. NPROCS-1.  On
*  systems not natively in this numbering scheme, translates to it.
*
*  ====================================================================
*
*     .. External Functions ..
      INTEGER  IBTNPROCS
      EXTERNAL IBTNPROCS
*     ..
*     .. Common blocks ..
      COMMON /BTPNUM/ BTPNUMS
*     ..
*     .. Arrays in Common ..
      INTEGER BTPNUMS(0:999)
*     ..
*     .. Local Scalars ..
      INTEGER IAM, I, K
*     ..
*     .. Save statement ..
      SAVE IAM
*     ..
*     .. Data statements ..
      DATA IAM /-1/
*     ..
*     .. Executable Statements ..
*
      IF (IAM .EQ. -1) THEN
         CALL PVMFMYTID(K)
         DO 10 I = 0, IBTNPROCS()-1
            IF( K .EQ. BTPNUMS(I) ) IAM = I
   10    CONTINUE
      END IF
*
      IBTMYPROC = IAM
      RETURN
*
*     End of IBTMYPROC
*
      END
*
      INTEGER FUNCTION IBTNPROCS()
*
*  -- BLACS tester (version 1.0) --
*  University of Tennessee
*  December 15, 1994
*
*  Purpose
*  =======
*  IBTNPROCS: returns the number of processes in the machine.
*
*  ====================================================================
*     .. Local Scalars ..
      INTEGER IAM, NNODES
*     ..
*
*     Got to use BLACS, since it set up the machine . . .
*
      CALL BLACS_PINFO(IAM, NNODES)
      IBTNPROCS = NNODES
*
      RETURN
*
*     End of IBTNPROCS
*
      END
*
      SUBROUTINE BTSEND(DTYPE, N, BUFF, DEST, MSGID)
*
*  -- BLACS tester (version 1.0) --
*  University of Tennessee
*  December 15, 1994
*
*     .. Scalar Arguments ..
      INTEGER N, DTYPE, DEST, MSGID
*     ..
*     .. Array Arguments ..
      REAL BUFF(*)
*     ..
*
*     PURPOSE
*     =======
*     BTSEND: Communication primitive used to send messages independent
*     of the BLACS.  May safely be either locally or globally blocking.
*
*     Arguments
*     =========
*     DTYPE    (input) INTEGER
*              Indicates what data type BUFF is (same as PVM):
*                1  =  RAW BYTES
*                3  =  INTEGER
*                4  =  SINGLE PRECISION REAL
*                6  =  DOUBLE PRECISION REAL
*                5  =  SINGLE PRECISION COMPLEX
*                7  =  DOUBLE PRECISION COMPLEX
*
*     N        (input) INTEGER
*              The number of elements of type DTYPE in BUFF.
*
*     BUFF     (input) accepted as INTEGER array
*              The array to be communicated.  Its true data type is
*              indicated by DTYPE.
*
*     DEST      (input) INTEGER
*               The destination of the message.
*
*     MSGID     (input) INTEGER
*               The message ID (AKA message tag or type).
*
* =====================================================================
*     .. External Functions ..
      INTEGER  IBTNPROCS
      EXTERNAL IBTNPROCS
*     ..
*     .. Common blocks ..
      COMMON /BTPNUM/ BTPNUMS
*     ..
*     .. Arrays in Common ..
      INTEGER BTPNUMS(0:999)
*     ..
*     .. Include Files ..
      INCLUDE 'fpvm3.h'
*     ..
*     .. Local Scalars ..
      INTEGER INFO, PVMTYPE
*     ..
*     .. Executable Statements ..
*
*     Map internal type parameters to PVM
*
      IF( DTYPE .EQ. 1 ) THEN
         PVMTYPE = BYTE1
      ELSE IF( DTYPE .EQ. 3 ) THEN
         PVMTYPE = INTEGER4
      ELSE IF( DTYPE .EQ. 4 ) THEN
         PVMTYPE = REAL4
      ELSE IF( DTYPE .EQ. 5 ) THEN
         PVMTYPE = COMPLEX8
      ELSE IF( DTYPE .EQ. 6 ) THEN
         PVMTYPE = REAL8
      ELSE IF( DTYPE .EQ. 7 ) THEN
         PVMTYPE = COMPLEX16
      END IF
*
*     pack and send data to specified process
*
      CALL PVMFINITSEND(PVMDATADEFAULT, INFO)
      CALL PVMFPACK(DTYPE, BUFF, N, 1, INFO)
      IF( DEST .EQ. -1 ) THEN
         CALL PVMFMCAST(IBTNPROCS(), BTPNUMS, MSGID, INFO)
      ELSE
         CALL PVMFSEND(BTPNUMS(DEST) , MSGID, INFO)
      ENDIF
*
      RETURN
*
*     End BTSEND
*
      END
*
      SUBROUTINE BTRECV(DTYPE, N, BUFF, SRC, MSGID)
*
*  -- BLACS tester (version 1.0) --
*  University of Tennessee
*  December 15, 1994
*
*
*     .. Scalar Arguments ..
      INTEGER N, DTYPE, SRC, MSGID
*     ..
*     .. Array Arguments ..
      REAL BUFF(*)
*     ..
*
*     PURPOSE
*     =======
*     BTRECV: Globally blocking receive.
*
*     Arguments
*     =========
*     DTYPE    (input) INTEGER
*              Indicates what data type BUFF is:
*                1  =  RAW BYTES
*                3  =  INTEGER
*                4  =  SINGLE PRECISION REAL
*                6  =  DOUBLE PRECISION REAL
*                5  =  SINGLE PRECISION COMPLEX
*                7  =  DOUBLE PRECISION COMPLEX
*
*     N        (input) INTEGER
*              The number of elements of type DTYPE in BUFF.
*
*     BUFF     (output) INTEGER
*              The buffer to receive into.
*
*     SRC      (input) INTEGER
*              The source of the message.
*
*     MSGID    (input) INTEGER
*              The message ID.
*
* =====================================================================
*
*     .. Common blocks ..
      COMMON /BTPNUM/ BTPNUMS
*     ..
*     .. Arrays in Common ..
      INTEGER BTPNUMS(0:999)
*     ..
*     .. Include Files ..
      INCLUDE 'fpvm3.h'
*     ..
*     .. Local Scalars ..
      INTEGER INFO, PVMTYPE
*     ..
*     .. Executable Statements ..
*
*     Map internal type parameters to PVM
*
      IF( DTYPE .EQ. 1 ) THEN
         PVMTYPE = BYTE1
      ELSE IF( DTYPE .EQ. 3 ) THEN
         PVMTYPE = INTEGER4
      ELSE IF( DTYPE .EQ. 4 ) THEN
         PVMTYPE = REAL4
      ELSE IF( DTYPE .EQ. 5 ) THEN
         PVMTYPE = COMPLEX8
      ELSE IF( DTYPE .EQ. 6 ) THEN
         PVMTYPE = REAL8
      ELSE IF( DTYPE .EQ. 7 ) THEN
         PVMTYPE = COMPLEX16
      END IF
      CALL PVMFRECV(BTPNUMS(SRC), MSGID, INFO)
      CALL PVMFUNPACK(DTYPE, BUFF, N, 1, INFO)
*     ..
*     .. Local Scalars ..
*
      RETURN
*
*     End of BTRECV
*
      END
*
      INTEGER FUNCTION IBTSIZEOF(TYPE)
*
*  -- BLACS tester (version 1.0) --
*  University of Tennessee
*  December 15, 1994
*
*     .. Scalar Arguments ..
      CHARACTER*1 TYPE
*     ..
*
*  Purpose
*  =======
*  IBTSIZEOF: Returns the size, in bytes, of the 5 data types.
*  If your platform has a different size for DOUBLE PRECISION, you must
*  change the parameter statement in BLACSTEST as well.
*
*  Arguments
*  =========
*  TYPE     (input) CHARACTER*1
*           The data type who's size is to be determined:
*           'I' : INTEGER
*           'S' : SINGLE PRECISION REAL
*           'D' : DOUBLE PRECISION REAL
*           'C' : SINGLE PRECISION COMPLEX
*           'Z' : DOUBLE PRECISION COMPLEX
*
* =====================================================================
*
*     .. External Functions ..
      LOGICAL  LSAME
      EXTERNAL LSAME
*     ..
*     .. Local Scalars ..
      INTEGER LENGTH
*     ..
*     .. Executable Statements ..
*
      IF( LSAME(TYPE, 'I') ) THEN
         LENGTH = 4
      ELSE IF( LSAME(TYPE, 'S') ) THEN
         LENGTH = 4
      ELSE IF( LSAME(TYPE, 'D') ) THEN
         LENGTH = 8
      ELSE IF( LSAME(TYPE, 'C') ) THEN
         LENGTH = 8
      ELSE IF( LSAME(TYPE, 'Z') ) THEN
         LENGTH = 16
      END IF
      IBTSIZEOF = LENGTH
*
      RETURN
      END