9{
11 Int nctxt, P0, Q0, Np, i, *g;
12
14 Np = P * Q;
15 if (Np+pstart > P0*Q0)
16 {
17 fprintf(stderr, "Illegal reshape command in %s\n",__FILE__);
19 }
20 g = (
Int *) malloc(Np *
sizeof(
Int));
21 if (!g)
22 {
23 fprintf(stderr, "Cannot allocate memory in %s\n",__FILE__);
25 }
26 if (row_major_in)
27 {
28 if (row_major_out)
29 for (i=0; i != Np; i++)
30 g[(i%Q)*P+i/Q] =
Cblacs_pnum(ctxt, (pstart+i)/Q0, (pstart+i)%Q0);
31 else
32 for (i=0; i != Np; i++)
33 g[i] =
Cblacs_pnum(ctxt, (pstart+i)/Q0, (pstart+i)%Q0);
34 }
35 else
36 {
37 if (row_major_out)
38 for (i=0; i != Np; i++)
39 g[(i%Q)*P+i/Q] =
Cblacs_pnum(ctxt, (pstart+i)%P0, (pstart+i)/P0);
40 else
41 for (i=0; i != Np; i++)
42 g[i] =
Cblacs_pnum(ctxt, (pstart+i)%P0, (pstart+i)/P0);
43 }
46 free(g);
47
48 return(nctxt);
49}