File: mk9PCoords.c

package info (click to toggle)
spooles 2.2-11
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 19,656 kB
  • ctags: 3,690
  • sloc: ansic: 146,836; sh: 7,571; csh: 3,615; makefile: 1,968; perl: 74
file content (83 lines) | stat: -rw-r--r-- 2,136 bytes parent folder | download | duplicates (7)
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
75
76
77
78
79
80
81
82
83
/*  mk9PCoords.c  */

#include "../Coords.h"
#include "../../timings.h"

/*--------------------------------------------------------------------*/

int
main ( int argc, char *argv[] )
/*
   ------------------------------------
   create a Coords object for a 9P grid
   
   created -- 96feb02, cca
   ------------------------------------
*/
{
Coords   *coords ;
double   t1, t2 ;
FILE     *msgFile ;
float    bbox[4] = { 0.0, 0.0, 1.0, 1.0 } ;
int      msglvl, n1, n2 ;

if ( argc != 6 ) {
   fprintf(stdout, 
"\n\n usage : %s msglvl msgFile n1 n2 outCoordsFile \n"
"\n msglvl        -- message level"
"\n msgFile       -- message file"
"\n n1            -- # of grid points in first direction"
"\n n2            -- # of grid points in second direction"
"\n outCoordsFile -- file to write out Coords object"
"\n", argv[0]) ;
   return(1) ;
}
msglvl = atoi(argv[1]) ;
if ( strcmp(argv[2], "stdout") == 0 ) {
   msgFile = stdout ;
} else if ( (msgFile = fopen(argv[2], "a")) == NULL ) {
   fprintf(stderr, "\n fatal error in %s"
           "\n unable to open file %s", argv[0], argv[2]) ;
   exit(-1) ; 
}
n1 = atoi(argv[3]) ;
n2 = atoi(argv[4]) ;
fprintf(msgFile, "\n\n %s %d %s %d %d %s",
        argv[0], msglvl, argv[2], n1, n2, argv[5]) ;
fflush(msgFile) ;
/*
   ------------------------
   create the Coords object
   ------------------------
*/
MARKTIME(t1) ;
coords = Coords_new() ;
Coords_init9P(coords, bbox, COORDS_BY_TUPLE, n1, n2, 1) ;
MARKTIME(t2) ;
fprintf(msgFile, "\n CPU %.3f : create Coords object", (t2 - t1)) ;
if ( msglvl <= 2 ) {
   Coords_writeStats(coords, msgFile) ;
   fflush(msgFile) ;
} else {
   Coords_writeForHumanEye(coords, msgFile) ;
   fflush(msgFile) ;
}
/*
   ---------------------------
   write out the Coords object
   ---------------------------
*/
if ( strcmp("none", argv[5]) != 0 ) {
   MARKTIME(t1) ;
   Coords_writeToFile(coords, argv[5]) ;
   MARKTIME(t2) ;
   fprintf(msgFile, "\n CPU %.3f : write out Coords to file %s",
           (t2 - t1), argv[5]) ;
}

fprintf(msgFile, "\n") ;
fflush(msgFile) ;

return(1) ; }

/*--------------------------------------------------------------------*/