ScaLAPACK 2.1  2.1
ScaLAPACK: Scalable Linear Algebra PACKage
npreroc.f
Go to the documentation of this file.
1  INTEGER FUNCTION npreroc( N, NB, IPROC, ISRCPROC, NPROCS )
2 *
3 * -- ScaLAPACK tools routine (version 1.7) --
4 * University of Tennessee, Knoxville, Oak Ridge National Laboratory,
5 * and University of California, Berkeley.
6 * May 1, 1997
7 *
8 * .. Scalar Arguments ..
9  INTEGER iproc, isrcproc, n, nb, nprocs
10 * ..
11 *
12 * Purpose
13 * =======
14 *
15 * NPREROC computes the Number of PREceeding Rows Or Columns of a
16 * distributed matrix that are possessed by processes closer to
17 * ISRCPROC than IPROC. Therefore, if ISRCPROC=0 and IPROC=4, then
18 * NPREROC returns the number of distributed matrix rows or columns
19 * owned by processes 0, 1, 2, and 3.
20 *
21 * Arguments
22 * =========
23 *
24 * N (global input) INTEGER
25 * The number of rows or columns in the distributed matrix.
26 *
27 * NB (global input) INTEGER
28 * Block size, size of the blocks the distributed matrix is
29 * split into.
30 *
31 * IPROC (local intput) INTEGER
32 * The coordinate of the process whose preceeding distributed
33 * matrix rows or columns are to be determined.
34 *
35 * ISRCPROC (global input) INTEGER
36 * The coordinate of the process that possesses the first
37 * row or column of the distributed matrix.
38 *
39 * NPROCS (global input) INTEGER
40 * The total number processes over which the matrix is
41 * distributed.
42 *
43 * =====================================================================
44 *
45 * .. Local Scalars ..
46  INTEGER extrablks, mydist, nblocks
47 * ..
48 * .. Intrinsic Functions ..
49  INTRINSIC mod
50 * ..
51 * .. Executable Statements ..
52 *
53 * Figure PROC's distance from source process
54 *
55  mydist = mod( nprocs+iproc-isrcproc, nprocs )
56 *
57 * Figure the total number of whole NB blocks N is split up into
58 *
59  nblocks = n / nb
60 *
61 * Figure the minimum number of rows/cols previous processes could have
62 *
63  npreroc = (nblocks/nprocs) * nb * mydist
64 *
65 * See if there are any extra blocks
66 *
67  extrablks = mod( nblocks, nprocs )
68 *
69 * If I have an extra block, all processes in front of me got one too
70 *
71  IF( mydist.LE.extrablks ) THEN
72  npreroc = npreroc + nb*mydist
73 *
74 * If I have don't have an extra block, add in extra blocks of
75 * preceeding processes and the partial block, if it exists
76 *
77  ELSE
78  npreroc = npreroc + extrablks*nb + mod( n, nb )
79  END IF
80 *
81  RETURN
82 *
83 * End of NPREROC
84 *
85  END
npreroc
integer function npreroc(N, NB, IPROC, ISRCPROC, NPROCS)
Definition: npreroc.f:2