OpenRadioss 2025.1.11
OpenRadioss project
Loading...
Searching...
No Matches
SL_gridreshape.c File Reference
#include <stdlib.h>
#include <stdio.h>

Go to the source code of this file.

Macros

#define Int   int

Functions

Int SL_Cgridreshape (Int ctxt, Int pstart, Int row_major_in, Int row_major_out, Int P, Int Q)
Int sl_gridreshape_ (Int *ctxt, Int *pstart, Int *row_major_in, Int *row_major_out, Int *P, Int *Q)
Int SL_GRIDRESHAPE (Int *ctxt, Int *pstart, Int *row_major_in, Int *row_major_out, Int *P, Int *Q)
Int sl_gridreshape__ (Int *ctxt, Int *pstart, Int *row_major_in, Int *row_major_out, Int *P, Int *Q)
Int sl_gridreshape (Int *ctxt, Int *pstart, Int *row_major_in, Int *row_major_out, Int *P, Int *Q)

Macro Definition Documentation

◆ Int

#define Int   int

Definition at line 5 of file SL_gridreshape.c.

Function Documentation

◆ SL_Cgridreshape()

Int SL_Cgridreshape ( Int ctxt,
Int pstart,
Int row_major_in,
Int row_major_out,
Int P,
Int Q )

Definition at line 8 of file SL_gridreshape.c.

9{
11 Int nctxt, P0, Q0, Np, i, *g;
12
13 Cblacs_gridinfo(ctxt, &P0, &Q0, &i, &Np);
14 Np = P * Q;
15 if (Np+pstart > P0*Q0)
16 {
17 fprintf(stderr, "Illegal reshape command in %s\n",__FILE__);
18 Cblacs_abort(ctxt, -22);
19 }
20 g = (Int *) malloc(Np * sizeof(Int));
21 if (!g)
22 {
23 fprintf(stderr, "Cannot allocate memory in %s\n",__FILE__);
24 Cblacs_abort(ctxt, -23);
25 }
26 if (row_major_in) /* Read in in row-major order */
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 /* read in in column-major order */
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 }
44 Cblacs_get(ctxt, 10, &nctxt);
45 Cblacs_gridmap(&nctxt, g, P, P, Q);
46 free(g);
47
48 return(nctxt);
49}
#define Int
Definition Bconfig.h:22
void Cblacs_gridmap()
void Cblacs_abort()
Int Cblacs_pnum()
void Cblacs_get()
void Cblacs_gridinfo()

◆ SL_GRIDRESHAPE()

Int SL_GRIDRESHAPE ( Int * ctxt,
Int * pstart,
Int * row_major_in,
Int * row_major_out,
Int * P,
Int * Q )

Definition at line 57 of file SL_gridreshape.c.

58{
59 return( SL_Cgridreshape(*ctxt, *pstart, *row_major_in, *row_major_out,
60 *P, *Q) );
61}
Int SL_Cgridreshape(Int ctxt, Int pstart, Int row_major_in, Int row_major_out, Int P, Int Q)

◆ sl_gridreshape()

Int sl_gridreshape ( Int * ctxt,
Int * pstart,
Int * row_major_in,
Int * row_major_out,
Int * P,
Int * Q )

Definition at line 69 of file SL_gridreshape.c.

70{
71 return( SL_Cgridreshape(*ctxt, *pstart, *row_major_in, *row_major_out,
72 *P, *Q) );
73}

◆ sl_gridreshape_()

Int sl_gridreshape_ ( Int * ctxt,
Int * pstart,
Int * row_major_in,
Int * row_major_out,
Int * P,
Int * Q )

Definition at line 51 of file SL_gridreshape.c.

52{
53 return( SL_Cgridreshape(*ctxt, *pstart, *row_major_in, *row_major_out,
54 *P, *Q) );
55}

◆ sl_gridreshape__()

Int sl_gridreshape__ ( Int * ctxt,
Int * pstart,
Int * row_major_in,
Int * row_major_out,
Int * P,
Int * Q )

Definition at line 63 of file SL_gridreshape.c.

64{
65 return( SL_Cgridreshape(*ctxt, *pstart, *row_major_in, *row_major_out,
66 *P, *Q) );
67}