File: writeStagesIV.c

package info (click to toggle)
spooles 2.2-5
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 18,824 kB
  • ctags: 3,665
  • sloc: ansic: 146,828; csh: 3,615; makefile: 2,045; perl: 70
file content (133 lines) | stat: -rw-r--r-- 3,592 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/*  writeStagesIV.c  */

#include "../DSTree.h"
#include "../../timings.h"

/*--------------------------------------------------------------------*/
int
main ( int argc, char *argv[] )
/*
   --------------------------------------------------
   read in a DSTree object, create a stagesIV object
   and write it to a file.

   created -- 97feb01, cca
   --------------------------------------------------
*/
{
char     *inDSTreeFileName, *outIVfileName, *type ;
double   t1, t2 ;
int      msglvl, rc ;
IV       *stagesIV ;
DSTree   *dstree ;
FILE     *msgFile ;

if ( argc != 6 ) {
   fprintf(stdout, 
      "\n\n usage : %s msglvl msgFile inFile type outFile"
      "\n    msglvl   -- message level"
      "\n    msgFile  -- message file"
      "\n    inFile   -- input file, must be *.dstreef or *.dstreeb"
      "\n    type     -- type of stages vector"
      "\n    outFile  -- output file, must be *.ivf or *.ivb"
      "\n", argv[0]) ;
   return(0) ;
}
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\n",
           argv[0], argv[2]) ;
   return(-1) ;
}
inDSTreeFileName = argv[3] ;
type             = argv[4] ;
outIVfileName    = argv[5] ;
fprintf(msgFile, 
        "\n %s "
        "\n msglvl   -- %d" 
        "\n msgFile  -- %s" 
        "\n inFile   -- %s" 
        "\n outFile  -- %s" 
        "\n",
        argv[0], msglvl, argv[2], inDSTreeFileName, outIVfileName) ;
fflush(msgFile) ;
/*
   -------------------------
   read in the DSTree object
   -------------------------
*/
if ( strcmp(inDSTreeFileName, "none") == 0 ) {
   fprintf(msgFile, "\n no file to read from") ;
   exit(0) ;
}
dstree = DSTree_new() ;
MARKTIME(t1) ;
rc = DSTree_readFromFile(dstree, inDSTreeFileName) ;
MARKTIME(t2) ;
fprintf(msgFile, "\n CPU %9.5f : read in dstree from file %s",
        t2 - t1, inDSTreeFileName) ;
if ( rc != 1 ) {
   fprintf(msgFile, "\n return value %d from DSTree_readFromFile(%p,%s)",
           rc, dstree, inDSTreeFileName) ;
   exit(-1) ;
}
fprintf(msgFile, "\n\n after reading DSTree object from file %s",
        inDSTreeFileName) ;
if ( msglvl > 2 ) {
   DSTree_writeForHumanEye(dstree, msgFile) ;
} else {
   DSTree_writeStats(dstree, msgFile) ;
}
fflush(msgFile) ;
/*
   ---------------------
   get the stages vector
   ---------------------
*/
if ( strcmp(type, "ND") == 0 ) {
   stagesIV = DSTree_NDstages(dstree) ;
} else if ( strcmp(type, "ND2") == 0 ) {
   stagesIV = DSTree_ND2stages(dstree) ;
} else if ( strcmp(type, "MS2") == 0 ) {
   stagesIV = DSTree_MS2stages(dstree) ;
} else if ( strcmp(type, "MS3") == 0 ) {
   stagesIV = DSTree_MS3stages(dstree) ;
} else {
   stagesIV = NULL ;
}
/*
   ---------------------------
   write out the DSTree object
   ---------------------------
*/
if ( stagesIV != NULL && strcmp(outIVfileName, "none") != 0 ) {
   MARKTIME(t1) ;
   rc = IV_writeToFile(stagesIV, outIVfileName) ;
   MARKTIME(t2) ;
   fprintf(msgFile, "\n CPU %9.5f : write dstree to file %s",
           t2 - t1, outIVfileName) ;
   if ( rc != 1 ) {
      fprintf(msgFile, 
              "\n return value %d from IV_writeToFile(%p,%s)",
              rc, stagesIV, outIVfileName) ;
   }
}
/*
   ----------------------
   free the DSTree object
   ----------------------
*/
DSTree_free(dstree) ;
if ( stagesIV != NULL ) {
   IV_free(stagesIV) ;
}

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

return(1) ; }

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