File: dbg_write.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 (74 lines) | stat: -rw-r--r-- 1,934 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#if HAVE_CONFIG_H
#   include "config.h"
#endif

#include <stdlib.h>

#include "macommon.h"
#include "global.h"
#include "dra.h"
#include "drap.h"

#define LEN 10

int main(int argc, char **argv)
{
    int from, to, type;
    Integer idata[LEN];
#if 0
    int fd;
#endif
    Integer i, ii, imax, offset, status;
    DoublePrecision ddata[LEN];

    if(argc < 2){
        printf("program writes test data to a binary file\n");
        printf("usage: dbg_write.x <filename> <type> <from> <to>\n");
        printf("type: 1 - integer 2 - double \n <from> <to> -range of elements (0, ...)\n");
        return(1);
    }

    type = atoi(argv[2]);
    from = atoi(argv[3]);
    to   = atoi(argv[4]);

    if(from < 0 || to < from) {printf("range error\n"); return 1;}
#if 0
    if(!(fd = dra_el_open(argv[1],DRA_W))){printf("not found\n"); return 1;} 
#else
    /* TODO This must be an old test program using an old API...
     * consider removing this program. */
    return 1;
#endif

    switch (type){

        case 1: 
            for(i=from; i<= to; i+= LEN){
                imax = PARIO_MIN(i+LEN-1,to);
                offset = sizeof(Integer)*i;
                for(ii=0;ii<imax-i+1;ii++) idata[ii]=ii;
#if 0
                status=dra_el_write(idata, sizeof(Integer), imax-i+1, fd, offset);
#else
                status = 1;
#endif
                if(!status)printf("error write failed\n");
            }
            break;
        case 2: 
            for(i=from; i<= to; i+= LEN){ 
                imax = PARIO_MIN(i+LEN-1,to);
                offset = sizeof(DoublePrecision)*i;
                for(ii=0;ii<imax-i+1;ii++) ddata[ii]=1.*ii;
#if 0
                status=dra_el_write(ddata,sizeof(DoublePrecision), imax -i+1, fd,offset);
#else
                status = 1;
#endif
                if(!status)printf("error write failed\n");
            }
            break;
        default: printf("type error\n"); return 1;
    }
}