File: testmap.c

package info (click to toggle)
ga 5.9.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 18,472 kB
  • sloc: ansic: 192,963; fortran: 53,761; f90: 11,218; cpp: 5,784; makefile: 2,248; sh: 1,945; python: 1,734; perl: 534; csh: 134; asm: 106
file content (39 lines) | stat: -rw-r--r-- 791 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#if HAVE_CONFIG_H
#   include "config.h"
#endif

#if HAVE_STDIO_H
#   include <stdio.h>
#endif

#include "typesf2c.h"

int ncols;
int nrows;

/* Given the col and row no. return the actual process no. */
#define MAP(Row,Col) (ncols*(Row) + (Col))

/* Given the node return the row no. */
#define ROW(Node) ((Node) / ncols)

/* Given the node return the column no. */
#define COL(Node) ((Node) - ncols*((Node)/ncols))

int main(int argc, char **argv)
{
    int node, type, len, me;

    (void) printf("Input nrows, ncols ");
    (void) scanf("%d %d",&nrows, &ncols);

    node = 0;
    type = 1;
    len = 4;

    for (me=0; me<(nrows*ncols); me++) {
        (void) printf(" me=%d row=%d col=%d map=%d\n",me,
                      ROW(me),COL(me),MAP(ROW(me),COL(me)));
    }
    return 0;
}