45 #include "paz_aztec.h"
47 void read_coo(
char *data_file,
int *proc_config,
48 int *N_global,
int *n_nonzeros,
49 double **val,
int **bindx,
50 double **x,
double **b,
double **xexact)
61 int i, n_entries, N_columns;
64 int max_ii = 0, max_jj = 0;
68 int *pntr, *indx1, *pntr1;
71 int MAXBLOCKSIZE = 25;
73 if(proc_config[PAZ_node] == 0)
77 data = fopen(data_file,
"r") ;
79 fscanf(data,
"%d %d %d", N_global, &N_columns, &n_entries) ;
80 if (N_columns != *N_global)
81 perror(
"Matrix dimensions must be the same");
82 printf(
"Reading from file: %s\n",data_file);
83 printf(
"Number of equations = %d\n",*N_global);
84 printf(
"Number of entries = %d\n",n_entries);
87 *bindx = (
int *) calloc(n_entries+1,
sizeof(
int)) ;
88 *val = (
double *) calloc(n_entries+1,
sizeof(
double)) ;
90 pntr1 = (
int *) calloc(n_entries+1,
sizeof(
int)) ;
91 indx1 = (
int *) calloc(n_entries+1,
sizeof(
int)) ;
92 val1 = (
double *) calloc(n_entries+1,
sizeof(
double)) ;
94 pntr = (
int *) calloc(n_entries+1,
sizeof(
int)) ;
97 perror(
"Error: Not enough space to create matrix");
101 fscanf(data,
"%d %d %lf", &ii, &jj, &value) ;
102 max_ii =
max(max_ii,ii);
103 max_jj =
max(max_jj,jj);
105 printf(
"Entry %d, %d = %lf.\n",ii,jj,value);
114 if (max_ii != max_jj)
perror(
"Error: Number of rows and columns not equal");
116 printf(
"Number of nonzeros = %d\n",*n_nonzeros);
124 coocsr_(N_global,n_nonzeros, *val, *bindx, pntr, val1, indx1, pntr1);
126 csrcsc_(N_global,&ione,&ione,
130 csrcsc_(N_global,&ione,&ione,
134 csrmsr_(N_global,val1,indx1,pntr1,
140 for (i=0;i<*n_nonzeros+1;i++)
143 *b = (
double *) calloc((*N_global)*MAXBLOCKSIZE,
sizeof(double)) ;
144 *x = (
double *) calloc((*N_global)*MAXBLOCKSIZE,
sizeof(double)) ;
147 perror(
"Error: Not enough space to create matrix");
151 for (i=0;i<*N_global;i++)
162 free((
void *) indx1);
163 free((
void *) pntr1);
void read_coo(char *data_file, int *proc_config, int *N_global, int *n_nonzeros, double **val, int **bindx, double **x, double **b, double **xexact)