File: testHBIO2.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 (101 lines) | stat: -rw-r--r-- 2,712 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
/*  testHBIO2.c  */

#include "../../misc.h"
#include "../../timings.h"

/*--------------------------------------------------------------------*/
int
main ( int argc, char *argv[] )
/*
   ---------------------------------------------------
   read in a Harwell-Boeing matrix, 
   convert to a InpMtx object and write to a file.

   created -- 98sep11, cca
   ---------------------------------------------------
*/
{
char      *inFileName, *outFileName ;
double    t1, t2 ;
int       msglvl, rc ;
InpMtx    *inpmtx ;
FILE      *msgFile ;

if ( argc != 5 ) {
   fprintf(stdout, 
      "\n\n usage : %s msglvl msgFile inFile outFile"
      "\n    msglvl   -- message level"
      "\n    msgFile  -- message file"
      "\n    inFile   -- input file, must be Harwell-Boeing format"
      "\n    outFile  -- output file, must be *.inpmtxf or *.inpmtxb"
      "\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) ;
}
inFileName  = argv[3] ;
outFileName = argv[4] ;
fprintf(msgFile, 
        "\n %s "
        "\n msglvl   -- %d" 
        "\n msgFile  -- %s" 
        "\n inFile   -- %s" 
        "\n outFile  -- %s" 
        "\n",
        argv[0], msglvl, argv[2], inFileName, outFileName) ;
fflush(msgFile) ;
/*
   ---------------------------------------------
   read in the Harwell-Boeing matrix information
   ---------------------------------------------
*/
if ( strcmp(inFileName, "none") == 0 ) {
   fprintf(msgFile, "\n no file to read from") ;
   exit(0) ;
}
MARKTIME(t1) ;
inpmtx = InpMtx_new() ;
fprintf(msgFile, "\n 1. inpmtx = %p", inpmtx) ;
rc = InpMtx_readFromHBfile(inpmtx, inFileName) ;
fprintf(msgFile, "\n 2. inpmtx = %p", inpmtx) ;
MARKTIME(t2) ;
fprintf(msgFile, "\n CPU %8.3f : read in matrix", t2 - t1) ;
if ( rc != 1 ) {
   fprintf(msgFile, "\n error reading in matrix") ;
   return(1) ;
}
if ( msglvl > 2 ) {
   InpMtx_writeForHumanEye(inpmtx, msgFile) ;
   fflush(msgFile) ;
}
/*
   ----------------------------
   write out the InpMtx object
   ----------------------------
*/
if ( strcmp(outFileName, "none") != 0 ) {
   rc = InpMtx_writeToFile(inpmtx, outFileName) ;
   fprintf(msgFile, 
           "\n return value %d from InpMtx_writeToFile(%p,%s)",
           rc, inpmtx, outFileName) ;
}
/*
   ------------------------
   free the working storage
   ------------------------
*/
InpMtx_free(inpmtx) ;

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

return(1) ; }

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