4
5
6
7
8
9
10
11
12 CHARACTER JOBZ
13 INTEGER MINSIZE, N
14
15
16 INTEGER DESCA( * )
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 INTEGER BLOCK_CYCLIC_2D, DLEN_, DTYPE_, CTXT_, M_, N_,
51 $ MB_, NB_, RSRC_, CSRC_, LLD_
52 parameter( block_cyclic_2d = 1, dlen_ = 9, dtype_ = 1,
53 $ ctxt_ = 2, m_ = 3, n_ = 4, mb_ = 5, nb_ = 6,
54 $ rsrc_ = 7, csrc_ = 8, lld_ = 9 )
55
56
57 LOGICAL WANTZ
58 INTEGER CONTEXTC, CSRC_A, IACOL, IAROW, ICOFFA, IROFFA,
59
60
61
62
63
64
65
66
67 LOGICAL LSAME
68 INTEGER ILCM, INDXG2P, NUMROC, SL_GRIDRESHAPE
70
71
72 EXTERNAL blacs_gridinfo, blacs_gridexit
73
74
76
77
78
79 IF( block_cyclic_2d*csrc_*ctxt_*dlen_*dtype_*lld_*mb_*m_*nb_*n_*
80 $ rsrc_.LT.0 )RETURN
81
82 CALL blacs_gridinfo( desca( ctxt_ ), nprow, npcol, myrow, mycol )
83 nb = desca( mb_ )
84 n = desca( m_ )
85 rsrc_a = desca( rsrc_ )
86 csrc_a = desca( csrc_ )
87 lcm =
ilcm( nprow, npcol )
88 lcmq = lcm / npcol
89 iroffa = 0
90 icoffa = 0
91 iarow =
indxg2p( 1, nb, myrow, rsrc_a, nprow )
92 iacol =
indxg2p( 1, nb, mycol, csrc_a, npcol )
93 np =
numroc( n+iroffa, nb, myrow, iarow, nprow )
94 nq =
numroc( n+icoffa, nb, mycol, iacol, npcol )
95 sizemqrleft =
max( ( nb*( nb-1 ) ) / 2, ( np+nq )*nb ) + nb*nb
96 sizemqrright =
max( ( nb*( nb-1 ) ) / 2,
98 $ npcol ), nb, 0, 0, lcmq ), np ) )*nb ) + nb*nb
100 np0 =
numroc( nn, nb, 0, 0, nprow )
101 mq0 =
numroc( nn, nb, 0, 0, npcol )
102 nprocs = nprow*npcol
103 wantz =
lsame( jobz,
'V' )
104 ldc = 0
105
106
107
108 IF( wantz ) THEN
110 CALL blacs_gridinfo( contextc, nprowc, npcolc, myprowc,
111 $ mypcolc )
112 nrc =
numroc( n, nb, myprowc, 0, nprocs)
114 CALL blacs_gridexit( contextc )
115 END IF
116
117
118
119
120 IF( wantz ) THEN
121 qrmem = 5*n +
max( 2*np0 +mq0 + nb*nn, 2*nn-2 ) + n*ldc
122 minsize =
max( sizemqrleft, sizemqrright, qrmem )
123 ELSE
124 minsize = 5*n + 2*np0 +mq0 + nb*nn
125 END IF
126
127 RETURN
128
129
130
Int sl_gridreshape(Int *ctxt, Int *pstart, Int *row_major_in, Int *row_major_out, Int *P, Int *Q)
integer function ilcm(m, n)
integer function indxg2p(indxglob, nb, iproc, isrcproc, nprocs)
integer function numroc(n, nb, iproc, isrcproc, nprocs)