#include <stdlib.h>
#include <petscoptions.h>
#include <petsc.h>
#include "nmd.h"
#include "anamod.h"
#include "anamodsalsamodules.h"
Go to the source code of this file.
Functions | |
static PetscErrorCode | get_matrix (Mat *A, PetscTruth *success) |
PetscErrorCode | analyze_matrix (Mat A, NMD_metadata nmd) |
int | main (int argc, char **argv) |
PetscErrorCode analyze_matrix | ( | Mat | A, | |
NMD_metadata | nmd | |||
) |
Definition at line 47 of file petsc.c.
References categories, CategoryGetModules(), ComputeQuantity(), GetCategories(), GetDataType(), modules, and types.
Referenced by main().
00048 { 00049 char **categories,**modules; 00050 AnalysisDataType *types; int icat,imod,ncat,nmod; 00051 PetscErrorCode ierr; 00052 00053 PetscFunctionBegin; 00054 ierr = GetCategories(&categories,&ncat); CHKERRQ(ierr); 00055 for (icat=0; icat<ncat; icat++) { 00056 ierr = CategoryGetModules 00057 (categories[icat],&modules,&types,PETSC_NULL,&nmod); CHKERRQ(ierr); 00058 for (imod=0; imod<nmod; imod++) { 00059 AnalysisItem res; int reslen; PetscTruth success; 00060 ierr = ComputeQuantity 00061 ((AnaModNumericalProblem)A,categories[icat],modules[imod], 00062 &res,&reslen,&success); CHKERRQ(ierr); 00063 #if defined(HAVE_MYSQL) 00064 00065 #endif 00066 if (success) { 00067 AnalysisDataType type; 00068 ierr = GetDataType 00069 (categories[icat],modules[imod],&type); CHKERRQ(ierr); 00070 ierr = NMDSetArrayValue 00071 (nmd,categories[icat],modules[imod], 00072 (NMDDataType)type,(void*)&res,reslen); CHKERRQ(ierr); 00073 } 00074 } 00075 } 00076 PetscFunctionReturn(0); 00077 }
static PetscErrorCode get_matrix | ( | Mat * | A, | |
PetscTruth * | success | |||
) | [static] |
Definition at line 14 of file petsc.c.
Referenced by main().
00015 { 00016 MPI_Comm comm = MPI_COMM_WORLD; char option[1000]; 00017 PetscTruth has; PetscViewer binary_dump; PetscErrorCode ierr; 00018 00019 PetscFunctionBegin; 00020 *success = PETSC_FALSE; 00021 00022 ierr = PetscOptionsGetString 00023 (PETSC_NULL,"-petsc",option,1000,&has); CHKERRQ(ierr); 00024 if (has) { 00025 PetscPrintf(comm,"reading matrix from petsc dump <%s>\n",option); 00026 ierr = PetscViewerBinaryOpen 00027 (comm,option,FILE_MODE_READ,&binary_dump); CHKERRQ(ierr); 00028 ierr = MatLoad(binary_dump,MATSEQAIJ,A); CHKERRQ(ierr); 00029 ierr = PetscViewerDestroy(binary_dump); CHKERRQ(ierr); 00030 *success = PETSC_TRUE; goto exit; 00031 } 00032 00033 ierr = PetscOptionsGetString 00034 (PETSC_NULL,"-matrixmarket",option,1000,&has); CHKERRQ(ierr); 00035 if (has) { 00036 PetscPrintf(comm,"matrix market read not yet supported\n"); 00037 *success = PETSC_FALSE; goto exit; 00038 } 00039 00040 exit: 00041 CHKMEMQ; 00042 PetscFunctionReturn(0); 00043 }
int main | ( | int | argc, | |
char ** | argv | |||
) |
Definition at line 82 of file petsc.c.
References analyze_matrix(), AnaModDeregisterSalsaModules(), AnaModFinalize(), AnaModGetTypeMySQLName(), AnaModInitialize(), AnaModRegisterSalsaModules(), CategoryGetModules(), get_matrix(), GetCategories(), and types.
00083 { 00084 Mat A; NMD_metadata nmd; PetscTruth table,success; 00085 PetscErrorCode ierr; 00086 00087 PetscFunctionBegin; 00088 PetscInitialize(&argc,&argv,0,0); 00089 ierr = AnaModInitialize(); CHKERRQ(ierr); 00090 ierr = AnaModRegisterSalsaModules(); CHKERRQ(ierr); 00091 00092 ierr = PetscOptionsHasName(PETSC_NULL,"-table",&table); CHKERRQ(ierr); 00093 if (table) { 00094 #if defined(HAVE_MYSQL) 00095 printf("CREATE TABLE anamod_data (\n"); 00096 { 00097 int ncat,icat,iwrite=0; char **cats; 00098 ierr = GetCategories(&cats,&ncat); CHKERRQ(ierr); 00099 for (icat=0; icat<ncat; icat++) { 00100 int ncmp,icmp; char **cmps; AnalysisDataType *types; 00101 ierr = CategoryGetModules 00102 (cats[icat],&cmps,&types,NULL,&ncmp); CHKERRQ(ierr); 00103 for (icmp=0; icmp<ncmp; icmp++) { 00104 char *type; 00105 if (iwrite>0) printf(",\n"); iwrite++; 00106 ierr = AnaModGetTypeMySQLName(types[icmp],&type); CHKERRQ(ierr); 00107 printf(" `%s-%s` %s",cats[icat],cmps[icmp],type); 00108 00109 } 00110 } 00111 } 00112 /* dbase = mysql_init(NULL); */ 00113 /* mysql_real_connect(dbase,MYSQLHOST,MYSQLUSER,MYSQLPASS,MYSQLDBASE, */ 00114 /* 0,NULL,0); */ 00115 #else 00116 SETERRQ(1,"Anamod was compiled without MySQL support"); 00117 #endif 00118 printf("\n)\n"); 00119 goto finalize; 00120 } 00121 ierr = get_matrix(&A,&success); CHKERRQ(ierr); 00122 if (!success) goto exit; 00123 00124 ierr = NMDCreateObject(&nmd); CHKERRQ(ierr); 00125 ierr = analyze_matrix(A,nmd); CHKERRQ(ierr); 00126 ierr = NMDViewObject(nmd); CHKERRQ(ierr); 00127 { 00128 char *key,*val; 00129 ierr = NMDReportObject(nmd,NMDFalse,&key,&val,'\t',0,0); CHKERRQ(ierr); 00130 printf("Keys: %s\nValues: %s\n",key,val); 00131 //NMD_FREE(key); NMD_FREE(val); 00132 } 00133 ierr = NMDDestroyObject(nmd); CHKERRQ(ierr); 00134 00135 exit: 00136 #if defined(HAVE_MYSQL) 00137 mysql_close(dbase); 00138 finalize: 00139 #endif 00140 ierr = AnaModDeregisterSalsaModules(); CHKERRQ(ierr); 00141 ierr = AnaModFinalize(); CHKERRQ(ierr); 00142 PetscFinalize(); 00143 PetscFunctionReturn(0); 00144 }