File: ggcm_grid.C

package info (click to toggle)
paraview 4.0.1-1~bpo70%2B1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy-backports
  • size: 526,572 kB
  • sloc: cpp: 2,284,430; ansic: 816,374; python: 239,936; xml: 70,162; tcl: 48,295; fortran: 39,116; yacc: 5,466; java: 3,518; perl: 3,107; lex: 1,620; sh: 1,555; makefile: 932; asm: 471; pascal: 228
file content (34 lines) | stat: -rw-r--r-- 1,000 bytes parent folder | download | duplicates (6)
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
#include "libggcm.h"

#include <stdlib.h>
#include <string.h>

/** looks through an MHDdata structure for a particular
 * data set which is given by the third argument.
 * Returns the data set, and side effects the 2nd argument to give
 * the length of the set. */
float *ggcm_grid(MHDdata *data, int *ndim, char * const grid_name)
{
    MHDdata *dat = data;
    float *grid;

    /* find the size of the data referenced by grid_name, and
     * return it via side effect in ndim */
    while (dat != NULL) {
        if(strcmp(dat->field_name, grid_name) == 0) {
            *ndim = dat->dim_size[0];
            break;
        }
        dat = dat->next;
    }

    /* we know the sizeof the data now, gather them up */
    grid = (float *)malloc((*ndim)*sizeof(float));
    memcpy(grid, dat->data, sizeof(float) * (*ndim));
    return grid;
}

/** alias for ggcm_grid */
__deprecated float *ggcmGrid(MHDdata *data, int *ndim, char * const grid_name) {
    return ggcm_grid(data, ndim, grid_name);
}