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 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184
|
/* testSimple.c */
#include "../SemiImplMtx.h"
#include "../../timings.h"
/*--------------------------------------------------------------------*/
int
main ( int argc, char *argv[] )
/*
-------------------------------------------------
(1) read in a FrontMtx from a file,
(2) read in an IV object that has the domain/schur complement
information for the fronts
(3) create the SemiImplMtx object
created -- 98oct16, cca
-------------------------------------------------
*/
{
char *inFrontMtxFileName, *inInpMtxFileName, *inIVfileName ;
double t1, t2 ;
FILE *msgFile ;
FrontMtx *frontmtx ;
InpMtx *inpmtx ;
int msglvl, rc ;
IV *frontmapIV ;
SemiImplMtx *semimtx ;
if ( argc != 6 ) {
fprintf(stdout,
"\n\n usage : %s msglvl msgFile inFrontMtxFile inInpMtxFile inIVfile"
"\n msglvl -- message level"
"\n msgFile -- message file"
"\n inFrontMtxFile -- input file, must be *.frontmtxf or *.frontmtxb"
"\n inInpMtxFile -- input file, must be *.inpmtxf or *.inpmtxb"
"\n inIVfile -- input 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) ;
}
inFrontMtxFileName = argv[3] ;
inInpMtxFileName = argv[4] ;
inIVfileName = argv[5] ;
fprintf(msgFile,
"\n %s "
"\n msglvl -- %d"
"\n msgFile -- %s"
"\n inFrontMtxFile -- %s"
"\n inInpMtxFile -- %s"
"\n inIVfile -- %s"
"\n",
argv[0], msglvl, argv[2], inFrontMtxFileName,
inInpMtxFileName, inIVfileName) ;
fflush(msgFile) ;
/*
---------------------------
read in the FrontMtx object
---------------------------
*/
if ( strcmp(inFrontMtxFileName, "none") == 0 ) {
fprintf(msgFile, "\n no file to read from") ;
exit(0) ;
}
frontmtx = FrontMtx_new() ;
MARKTIME(t1) ;
rc = FrontMtx_readFromFile(frontmtx, inFrontMtxFileName) ;
MARKTIME(t2) ;
fprintf(msgFile, "\n CPU %9.5f : read in frontmtx from file %s",
t2 - t1, inFrontMtxFileName) ;
if ( rc != 1 ) {
fprintf(msgFile,
"\n return value %d from FrontMtx_readFromFile(%p,%s)",
rc, frontmtx, inFrontMtxFileName) ;
exit(-1) ;
}
fprintf(msgFile, "\n\n after reading FrontMtx object from file %s",
inFrontMtxFileName) ;
if ( msglvl > 2 ) {
FrontMtx_writeForHumanEye(frontmtx, msgFile) ;
} else {
FrontMtx_writeStats(frontmtx, msgFile) ;
}
fflush(msgFile) ;
/*
---------------------------
read in the InpMtx object
---------------------------
*/
if ( strcmp(inInpMtxFileName, "none") == 0 ) {
fprintf(msgFile, "\n no file to read from") ;
exit(0) ;
}
inpmtx = InpMtx_new() ;
MARKTIME(t1) ;
rc = InpMtx_readFromFile(inpmtx, inInpMtxFileName) ;
MARKTIME(t2) ;
fprintf(msgFile, "\n CPU %9.5f : read in inpmtx from file %s",
t2 - t1, inInpMtxFileName) ;
if ( rc != 1 ) {
fprintf(msgFile,
"\n return value %d from InpMtx_readFromFile(%p,%s)",
rc, inpmtx, inInpMtxFileName) ;
exit(-1) ;
}
fprintf(msgFile, "\n\n after reading InpMtx object from file %s",
inInpMtxFileName) ;
if ( msglvl > 2 ) {
InpMtx_writeForHumanEye(inpmtx, msgFile) ;
} else {
InpMtx_writeStats(inpmtx, msgFile) ;
}
fflush(msgFile) ;
/*
---------------------------------
read in the fronts' map IV object
---------------------------------
*/
if ( strcmp(inIVfileName, "none") == 0 ) {
fprintf(msgFile, "\n no file to read from") ;
exit(0) ;
}
frontmapIV = IV_new() ;
MARKTIME(t1) ;
rc = IV_readFromFile(frontmapIV, inIVfileName) ;
MARKTIME(t2) ;
fprintf(msgFile, "\n CPU %9.5f : read in frontmapIV from file %s",
t2 - t1, inIVfileName) ;
if ( rc != 1 ) {
fprintf(msgFile,
"\n return value %d from IV_readFromFile(%p,%s)",
rc, frontmapIV, inIVfileName) ;
exit(-1) ;
}
fprintf(msgFile, "\n\n after reading IV object from file %s",
inIVfileName) ;
if ( msglvl > 2 ) {
IV_writeForHumanEye(frontmapIV, msgFile) ;
} else {
IV_writeStats(frontmapIV, msgFile) ;
}
fflush(msgFile) ;
/*
-------------------------------
create the semi-implicit matrix
-------------------------------
*/
semimtx = SemiImplMtx_new() ;
rc = SemiImplMtx_initFromFrontMtx(semimtx, frontmtx, inpmtx,
frontmapIV, msglvl, msgFile) ;
fprintf(msgFile, "\n\n Semi-implicit matrix") ;
SemiImplMtx_writeForHumanEye(semimtx, msgFile) ;
/*
------------------------
free the working storage
------------------------
*/
{
ETree *etree ;
IVL *symbfacIVL ;
etree = frontmtx->frontETree ;
symbfacIVL = frontmtx->symbfacIVL ;
FrontMtx_free(frontmtx) ;
ETree_free(etree) ;
IVL_free(symbfacIVL) ;
}
SemiImplMtx_free(semimtx) ;
InpMtx_free(inpmtx) ;
IV_free(frontmapIV) ;
fprintf(msgFile, "\n") ;
fclose(msgFile) ;
return(1) ; }
/*--------------------------------------------------------------------*/
|