~ubuntu-branches/ubuntu/precise/slurm-llnl/precise

« back to all changes in this revision

Viewing changes to src/smap/grid_functions.c

  • Committer: Bazaar Package Importer
  • Author(s): Gennaro Oliva
  • Date: 2011-04-08 11:21:17 UTC
  • mfrom: (3.3.16 sid)
  • Revision ID: james.westby@ubuntu.com-20110408112117-nfnyq9dtm55hqoaw
Tags: 2.2.4-1
* New upstream releases 
* Cleaning spare file and directories, not belonging to the sources
  generated by the building process and not removed by distclean.
  Added debian/clean with spare files and rm -rf inside debian/rules
  for directories.
* Added new packages libslurm-perl, libslurmdb-perl, slurm-llnl-torque
  (Closes: #575822) thanks to Julien Blache

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
 
41
41
#include "src/smap/smap.h"
42
42
 
43
 
#ifdef HAVE_3D
44
43
static int _coord(char coord)
45
44
{
46
45
        if ((coord >= '0') && (coord <= '9'))
50
49
        return -1;
51
50
}
52
51
 
53
 
#endif
54
 
 
55
 
/* Set grid color based upon node names containing X-, Y- and Z-
56
 
 * coordinates in last three positions. It is not based upon the
57
 
 * nodes in the node table being numerically ordered. */
58
 
extern int set_grid_name(char *nodes, int count)
59
 
{
60
 
#ifdef HAVE_3D
61
 
        hostlist_t hl;
62
 
        char *node;
63
 
        int i, x = 0, y = 0, z = 0;
64
 
 
65
 
        if (!nodes)
66
 
                return 1;
67
 
 
68
 
        hl = hostlist_create(nodes);
69
 
        while ((node = hostlist_shift(hl))) {
70
 
                i = strlen(node);
71
 
                if (i < 4)
72
 
                        x = -1;
73
 
                else {
74
 
                        x = _coord(node[i-3]);
75
 
                        y = _coord(node[i-2]);
76
 
                        z = _coord(node[i-1]);
77
 
                }
78
 
                if ((ba_system_ptr->grid[x][y][z].state
79
 
                                != NODE_STATE_DOWN) &&
80
 
                    (!(ba_system_ptr->grid[x][y][z].state
81
 
                                & NODE_STATE_DRAIN)) &&
82
 
                    (x >= 0) && (x < DIM_SIZE[X]) &&
83
 
                    (y >= 0) && (y < DIM_SIZE[Y]) &&
84
 
                    (z >= 0) && (z < DIM_SIZE[Z])) {
85
 
                        ba_system_ptr->grid[x][y][z].letter =
86
 
                                letters[count%62];
87
 
                        ba_system_ptr->grid[x][y][z].color =
88
 
                                colors[count%6];
89
 
                }
90
 
                free(node);
91
 
        }
92
 
        hostlist_destroy(hl);
93
 
#endif
94
 
        return 1;
95
 
}
96
 
 
97
52
extern int set_grid_inx(int start, int end, int count)
98
53
{
99
 
        int x;
100
 
#ifdef HAVE_3D
101
 
        int y, z;
 
54
        int x, y, z;
 
55
 
102
56
        for (y = DIM_SIZE[Y] - 1; y >= 0; y--) {
103
57
                for (z = 0; z < DIM_SIZE[Z]; z++) {
104
58
                        for (x = 0; x < DIM_SIZE[X]; x++) {
120
74
                        }
121
75
                }
122
76
        }
123
 
#else
124
 
        for (x = 0; x < DIM_SIZE[X]; x++) {
125
 
                if ((ba_system_ptr->grid[x].index < start)
126
 
                    ||  (ba_system_ptr->grid[x].index > end))
127
 
                        continue;
128
 
                if ((ba_system_ptr->grid[x].state == NODE_STATE_DOWN)
129
 
                    ||  (ba_system_ptr->grid[x].state & NODE_STATE_DRAIN))
130
 
                        continue;
131
 
 
132
 
                ba_system_ptr->grid[x].letter = letters[count%62];
133
 
                ba_system_ptr->grid[x].color = colors[count%6];
 
77
        return 1;
 
78
}
 
79
 
 
80
extern int set_grid_inx2(char *node_names, int count)
 
81
{
 
82
        hostlist_t hl;
 
83
        hostlist_iterator_t hl_iter;
 
84
        char *host;
 
85
        int i, x, y, z;
 
86
 
 
87
        hl = hostlist_create(node_names);
 
88
        hl_iter = hostlist_iterator_create(hl);
 
89
        while ((host = hostlist_next(hl_iter))) {
 
90
                i = strlen(host);
 
91
                x = _coord(host[i-3]);
 
92
                y = _coord(host[i-2]);
 
93
                z = _coord(host[i-1]);
 
94
                ba_system_ptr->grid[x][y][z].letter = letters[count%62];
 
95
                ba_system_ptr->grid[x][y][z].color  = colors[count%6];
 
96
                free(host);
134
97
        }
135
 
#endif
 
98
        hostlist_iterator_destroy(hl_iter);
136
99
        return 1;
137
100
}
138
101
 
139
102
/* This function is only called when HAVE_BG is set */
140
103
extern int set_grid_bg(int *start, int *end, int count, int set)
141
104
{
142
 
        int x=0;
 
105
        int x=0, y=0, z=0;
143
106
        int i = 0;
144
 
#ifdef HAVE_3D
145
 
        int y=0, z=0;
146
 
#endif
 
107
 
147
108
        assert(end[X] < DIM_SIZE[X]);
148
109
        assert(start[X] >= 0);
149
110
        assert(count >= 0);
150
111
        assert(set >= 0);
151
112
        assert(set <= 2);
152
 
#ifdef HAVE_3D
153
113
        assert(end[Y] < DIM_SIZE[Y]);
154
114
        assert(start[Y] >= 0);
155
115
        assert(end[Z] < DIM_SIZE[Z]);
179
139
                        }
180
140
                }
181
141
        }
182
 
#else
183
 
        for (x = start[X]; x <= end[X]; x++) {
184
 
                if(!set) {
185
 
                        ba_system_ptr->grid[x].letter =
186
 
                                letters[count%62];
187
 
                        ba_system_ptr->grid[x].color =
188
 
                                colors[count%6];
189
 
                }
190
 
                i++;
191
 
        }
192
 
 
193
 
#endif
194
142
 
195
143
        return i;
196
144
}
200
148
{
201
149
        int x;
202
150
        int grid_xcord, grid_ycord = 2;
203
 
 
204
 
#ifdef HAVE_3D
205
151
        int y, z, offset = DIM_SIZE[Z];
 
152
 
206
153
        for (y = DIM_SIZE[Y] - 1; y >= 0; y--) {
207
154
                offset = DIM_SIZE[Z] + 1;
208
155
                for (z = 0; z < DIM_SIZE[Z]; z++) {
239
186
                }
240
187
                grid_ycord++;
241
188
        }
242
 
#else
243
 
        grid_xcord=1;
244
 
        grid_ycord=1;
245
 
 
246
 
        for (x = dir; x < DIM_SIZE[X]; x++) {
247
 
                if (ba_system_ptr->grid[x].color)
248
 
                        init_pair(ba_system_ptr->grid[x].color,
249
 
                                  ba_system_ptr->grid[x].color,
250
 
                                  COLOR_BLACK);
251
 
                else
252
 
                        init_pair(ba_system_ptr->grid[x].color,
253
 
                                  ba_system_ptr->grid[x].color,
254
 
                                  7);
255
 
 
256
 
                wattron(grid_win,
257
 
                        COLOR_PAIR(ba_system_ptr->grid[x].color));
258
 
 
259
 
                mvwprintw(grid_win,
260
 
                          grid_ycord, grid_xcord, "%c",
261
 
                          ba_system_ptr->grid[x].letter);
262
 
                wattroff(grid_win,
263
 
                         COLOR_PAIR(ba_system_ptr->grid[x].color));
264
 
 
265
 
                grid_xcord++;
266
 
                if(grid_xcord==grid_win->_maxx) {
267
 
                        grid_xcord=1;
268
 
                        grid_ycord++;
269
 
                }
270
 
                if(grid_ycord==grid_win->_maxy) {
271
 
                        break;
272
 
                }
273
 
        }
274
 
#endif
275
189
        return;
276
190
}
277
191