3 void Creshape( context_in, major_in, context_out, major_out,
4 first_proc, nprow_new, npcol_new )
5 int context_in, *context_out, first_proc, major_in, major_out, nprow_new, npcol_new;
19 int nprow_in, npcol_in, myrow_in, mycol_in;
21 int myrow_old, mycol_old, myrow_new, mycol_new;
27 nprocs_new = nprow_new * npcol_new;
29 Cblacs_gridinfo( context_in, &nprow_in, &npcol_in, &myrow_in, &mycol_in );
32 if( ( nprow_in == nprow_new ) && ( npcol_in == npcol_new ) &&
33 ( first_proc == 0 ) && ( major_in == major_out ) )
35 *context_out = context_in;
40 grid_new = (
int *) malloc( nprocs_new *
sizeof(
int ) );
43 myrow_old = 0; mycol_old = 0;
46 myrow_old = first_proc / nprow_in;
47 mycol_old = first_proc % nprow_in;
51 myrow_old = first_proc % nprow_in;
52 mycol_old = first_proc / nprow_in;
55 myrow_new = 0; mycol_new = 0;
58 for (i=0; i< nprocs_new; i++ )
60 pnum =
Cblacs_pnum( context_in, myrow_old, mycol_old );
61 grid_new[ (mycol_new * nprow_new) + myrow_new ] = pnum;
62 proc_inc( &myrow_old, &mycol_old, nprow_in, npcol_in, major_in );
63 proc_inc( &myrow_new, &mycol_new, nprow_new, npcol_new, major_out );
70 Cblacs_gridmap( context_out, grid_new, nprow_new, nprow_new, npcol_new );
77 void reshape( context_in, major_in, context_out, major_out,
78 first_proc, nprow_new, npcol_new )
79 int *context_in, *context_out, *first_proc, *major_in, *major_out, *nprow_new, *npcol_new;
81 Creshape( *context_in, *major_in, context_out, *major_out,
82 *first_proc, *nprow_new, *npcol_new );
85 void RESHAPE( context_in, major_in, context_out, major_out,
86 first_proc, nprow_new, npcol_new )
87 int *context_in, *context_out, *first_proc, *major_in, *major_out, *nprow_new, *npcol_new;
89 Creshape( *context_in, *major_in, context_out, *major_out,
90 *first_proc, *nprow_new, *npcol_new );
93 void reshape_( context_in, major_in, context_out, major_out,
94 first_proc, nprow_new, npcol_new )
95 int *context_in, *context_out, *first_proc, *major_in, *major_out, *nprow_new, *npcol_new;
97 Creshape( *context_in, *major_in, context_out, *major_out,
98 *first_proc, *nprow_new, *npcol_new );
102 int *myrow, *mycol, nprow, npcol, major;
106 if( *mycol == npcol-1 )
109 if( *myrow == nprow-1 )
125 if( *myrow == nprow-1 )
128 if( *mycol == npcol-1 )