From 0296e03dca00d23f39b1d3c30d4091ca3a9399bd Mon Sep 17 00:00:00 2001
From: Pierre Ramet <ramet@labri.fr>
Date: Thu, 11 May 2017 23:51:57 +0200
Subject: [PATCH] cleanup new api

---
 drivers/iohb.c    |  2 +-
 spm.c             | 10 +++++-----
 spm.h             | 14 ++++++++++++--
 spm_read_driver.c |  8 ++------
 z_spm.h           |  2 +-
 z_spm_expand.c    |  2 +-
 z_spm_genrhs.c    |  2 +-
 7 files changed, 23 insertions(+), 17 deletions(-)

diff --git a/drivers/iohb.c b/drivers/iohb.c
index bc0cb95b..e4afcb9f 100644
--- a/drivers/iohb.c
+++ b/drivers/iohb.c
@@ -1344,7 +1344,7 @@ int writeHB_mat_char(const char* filename, int M, int N,
     int Ptrperline, Ptrwidth, Indperline, Indwidth;
     int Rhsperline, Rhswidth, Rhsprec;
     char Rhsflag;
-    int Valperline, Valwidth, Valprec;
+    int Valperline=0, Valwidth, Valprec;
     char Valflag;           /* Indicates 'E','D', or 'F' float format */
     char pformat[16],iformat[16],vformat[19],rformat[19];
 
diff --git a/spm.c b/spm.c
index 8614efac..bc015845 100644
--- a/spm.c
+++ b/spm.c
@@ -845,13 +845,13 @@ spmPrintInfo( const pastix_spm_t* spm, FILE *stream )
             mtxtypestr[mtxtype],
             flttypestr[flttype],
             fmttypestr[fmttype],
-            spm->gN, spm->gnnz );
+            (long)spm->gN, (long)spm->gnnz );
 
     if ( spm->dof != 1 ) {
         if ( spm->dof > 1 ) {
             fprintf(stream,
                     "  Dof:          %ld\n",
-                    spm->dof );
+                    (long)spm->dof );
         }
         else {
             fprintf(stream,
@@ -861,7 +861,7 @@ spmPrintInfo( const pastix_spm_t* spm, FILE *stream )
         fprintf(stream,
                 "  N expanded:   %ld\n"
                 "  NNZ expanded: %ld\n",
-                spm->gNexp, spm->gnnzexp );
+                (long)spm->gNexp, (long)spm->gnnzexp );
     }
 }
 
@@ -1076,12 +1076,12 @@ spmMatVec(const pastix_trans_t trans,
  *
  *******************************************************************************/
 int
-spmGenRHS( int type, int nrhs,
+spmGenRHS( pastix_rhstype_t type, int nrhs,
            const pastix_spm_t  *spm,
            void                *x, int ldx,
            void                *b, int ldb )
 {
-    static int (*ptrfunc[4])(int, int,
+    static int (*ptrfunc[4])(pastix_rhstype_t, int,
                              const pastix_spm_t *,
                              void *, int, void *, int) =
         {
diff --git a/spm.h b/spm.h
index c3d059ca..2f111183 100644
--- a/spm.h
+++ b/spm.h
@@ -53,6 +53,16 @@ typedef enum pastix_driver_e {
     /* PastixDriverBRGMD,      /\**< Not supported yet *\/ */
 } pastix_driver_t;
 
+/**
+ * @brief How to generate RHS
+ */
+typedef enum pastix_rhstype_e {
+    PastixRhsOne,
+    PastixRhsI,
+    PastixRhsRndX,
+    PastixRhsRndB
+} pastix_rhstype_t;
+
 /**
  *
  * @brief The sparse matrix data structure
@@ -87,7 +97,7 @@ typedef struct pastix_spm_s {
                                     otherwise, irregular degree of freedom (refer to dofs)         */
     pastix_int_t     *dofs;    /**< Array of the first column of each element in the
                                     expanded matrix [+baseval]                                     */
-    pastix_order_t    layout;  /**< PastixColMajor, or PastixRowMajor                              */
+    pastix_layout_t   layout;  /**< PastixColMajor, or PastixRowMajor                              */
 
     pastix_int_t     *colptr;  /**< List of indirections to rows for each vertex [+baseval]        */
     pastix_int_t     *rowptr;  /**< List of edges for each vertex [+baseval]                       */
@@ -131,7 +141,7 @@ pastix_spm_t *spmCheckAndCorrect( pastix_spm_t *spm );
  * @name SPM subroutines to check factorization/solve
  * @{
  */
-int           spmGenRHS( int type, int nrhs, const pastix_spm_t *spm, void *x, int ldx, void *b, int ldb );
+int           spmGenRHS( pastix_rhstype_t type, int nrhs, const pastix_spm_t *spm, void *x, int ldx, void *b, int ldb );
 int           spmCheckAxb( int nrhs, const pastix_spm_t *spm, void *x0, int ldx0, void *b, int ldb, const void *x, int ldx );
 
 /**
diff --git a/spm_read_driver.c b/spm_read_driver.c
index 5233420e..7eba9963 100644
--- a/spm_read_driver.c
+++ b/spm_read_driver.c
@@ -152,13 +152,9 @@ spmReadDriver( pastix_driver_t  driver,
 
     if ( mpiinit )
     {
-        pastix_int_t nnz;
+        pastix_int_t nnz = spm->nnz;
 
-        if (mpirank == 0) {
-            nnz = spm->nnz;
-        }
-
-        MPI_Bcast( spm, 2*sizeof(int)+3*sizeof(pastix_int_t), MPI_CHAR, 0, comm );
+        MPI_Bcast( spm, sizeof(pastix_spm_t), MPI_CHAR, 0, comm );
         MPI_Bcast( &nnz, 1, PASTIX_MPI_INT, 0, comm );
 
         fprintf(stderr, "%d: mtxtype=%d, flttype=%d, nnz=%ld, gN=%ld\n",
diff --git a/z_spm.h b/z_spm.h
index caa7cf9a..53c67c36 100644
--- a/z_spm.h
+++ b/z_spm.h
@@ -57,7 +57,7 @@ void         z_spmSort( pastix_spm_t *spm );
 pastix_int_t z_spmMergeDuplicate( pastix_spm_t *spm );
 pastix_int_t z_spmSymmetrize( pastix_spm_t *spm );
 
-int z_spmGenRHS(int type, int nrhs, const pastix_spm_t *spm, void *x, int ldx, void *b, int ldb );
+int z_spmGenRHS(pastix_rhstype_t type, int nrhs, const pastix_spm_t *spm, void *x, int ldx, void *b, int ldb );
 int z_spmCheckAxb( int nrhs, const pastix_spm_t *spm, void *x0, int ldx0, void *b, int ldb, const void *x, int ldx );
 
 /**
diff --git a/z_spm_expand.c b/z_spm_expand.c
index 9e62c153..ecbcb849 100644
--- a/z_spm_expand.c
+++ b/z_spm_expand.c
@@ -414,7 +414,7 @@ z_spmIJVExpand(const pastix_spm_t *spm)
     pastix_spm_t       *newspm;
     pastix_int_t        i, j, k, ii, jj, dofi, dofj, col, row, baseval;
     pastix_int_t       *newcol, *newrow, *oldcol, *oldrow, *dofs;
-    pastix_complex64_t *newval, *oldval;
+    pastix_complex64_t *newval, *oldval=NULL;
 
     assert( spm->fmttype == PastixIJV );
     assert( spm->flttype == PastixComplex64 );
diff --git a/z_spm_genrhs.c b/z_spm_genrhs.c
index 248a01ee..0876c435 100644
--- a/z_spm_genrhs.c
+++ b/z_spm_genrhs.c
@@ -193,7 +193,7 @@ z_spmRndVect( double scale, int m, int n, pastix_complex64_t *A, int lda,
  *
  *******************************************************************************/
 int
-z_spmGenRHS( int type, int nrhs,
+z_spmGenRHS( pastix_rhstype_t type, int nrhs,
              const pastix_spm_t  *spm,
              void                *x, int ldx,
              void                *b, int ldb )
-- 
GitLab