Commits

Stefano Zampini committed 5b08dc5

PCBDDC: Solved compilation errors and warnings for complex builds

Example code changed by using LAPACK steqr method.

Comments (0)

Files changed (5)

src/ksp/ksp/examples/tutorials/ex59.c

 
 #include <petscksp.h>
 #include <petscpc.h>
+#include <petscblaslapack.h>
 #define DEBUG 0
 
-/* lapack functions needed by gll computations */
-/* All PETSC configurations not yet completely covered! */
-#if !defined(PETSC_USE_COMPLEX)
-# if defined(PETSC_USE_REAL_SINGLE)
-#  define LAPACKsterf_ ssterf_
-# elif defined(PETSC_USE_REAL_DOUBLE)
-#  define LAPACKsterf_ dsterf_
-# else
-#  define LAPACKsterf_ qsterf_
-# endif
-#else
-# if defined(PETSC_USE_REAL_SINGLE)
-#  define LAPACKsterf_ steqrf_
-# else
-#  define LAPACKsterf_ zsterf_
-# endif
-#endif
-PETSC_EXTERN void LAPACKsterf_(PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*);
-
 /* structure holding domain data */
 typedef struct {
   /* communicator */
 /* structure holding GLL data */
 typedef struct {
   /* GLL nodes */
-  PetscScalar *zGL;
+  PetscReal   *zGL;
   /* GLL weights */
   PetscScalar *rhoGL;
   /* aux_mat */
 static PetscErrorCode GLLStuffs(DomainData dd, GLLData *glldata)
 {
   PetscErrorCode ierr;
-  PetscScalar    *M;
-  PetscScalar    si,x,z0,z1,z2,Lpj,Lpr,rhoGLj,rhoGLk;
+  PetscReal      *M,si;
+  PetscScalar    x,z0,z1,z2,Lpj,Lpr,rhoGLj,rhoGLk;
   PetscBLASInt   pm1,lierr;
   PetscInt       i,j,n,k,s,r,q,ii,jj,p=dd.p;
   PetscInt       xloc,yloc,zloc,xyloc,xyzloc;
 
   PetscFunctionBeginUser;
   /* Gauss-Lobatto-Legendre nodes zGL on [-1,1] */
-  ierr = PetscMalloc((p+1)*sizeof(PetscScalar),&glldata->zGL);CHKERRQ(ierr);
-  ierr = PetscMemzero(glldata->zGL,(p+1)*sizeof(PetscScalar));CHKERRQ(ierr);
+  ierr = PetscMalloc((p+1)*sizeof(*glldata->zGL),&glldata->zGL);CHKERRQ(ierr);
+  ierr = PetscMemzero(glldata->zGL,(p+1)*sizeof(*glldata->zGL));CHKERRQ(ierr);
 
   glldata->zGL[0]=-1.0;
   glldata->zGL[p]= 1.0;
   if (p > 1) {
     if (p == 2) glldata->zGL[1]=0.0;
     else {
-      ierr = PetscMalloc((p-1)*sizeof(PetscScalar),&M);CHKERRQ(ierr);
+      ierr = PetscMalloc((p-1)*sizeof(*M),&M);CHKERRQ(ierr);
       for (i=0; i<p-1; i++) {
-        si  = (PetscScalar)(i+1.0);
-        M[i]=0.5*PetscSqrtReal((PetscReal)(si*(si+2.0)/((si+0.5)*(si+1.5))));
+        si  = (PetscReal)(i+1.0);
+        M[i]=0.5*PetscSqrtReal(si*(si+2.0)/((si+0.5)*(si+1.5)));
       }
       pm1  = p-1;
       ierr = PetscFPTrapPush(PETSC_FP_TRAP_OFF);CHKERRQ(ierr);
-      LAPACKsterf_(&pm1,&glldata->zGL[1],M,&lierr);
+      PetscStackCallBLAS("LAPACKsteqr",LAPACKsteqr_("N",&pm1,&glldata->zGL[1],M,&x,&pm1,M,&lierr));
       if (lierr) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in STERF Lapack routine %d",(int)lierr);
       ierr = PetscFPTrapPop();CHKERRQ(ierr);
       ierr = PetscFree(M);CHKERRQ(ierr);
   }
 
   /* Weights for 1D quadrature */
-  ierr = PetscMalloc((p+1)*sizeof(PetscScalar),&glldata->rhoGL);CHKERRQ(ierr);
+  ierr = PetscMalloc((p+1)*sizeof(*glldata->rhoGL),&glldata->rhoGL);CHKERRQ(ierr);
 
   glldata->rhoGL[0]=2.0/(PetscScalar)(p*(p+1.0));
   glldata->rhoGL[p]=glldata->rhoGL[0];
     z0 = 1.0;
     z1 = x;
     for (n=1; n<p; n++) {
-      z2 = x*z1*(2.0*n+1.0)/(n+1.0)-z0*n/(n+1.0);
+      z2 = x*z1*(2.0*n+1.0)/(n+1.0)-z0*(PetscScalar)(n/(n+1.0));
       z0 = z1;
       z1 = z2;
     }
   }
 
   /* Auxiliary mat for laplacian */
-  ierr = PetscMalloc((p+1)*sizeof(PetscScalar*),&glldata->A);CHKERRQ(ierr);
-  ierr = PetscMalloc((p+1)*(p+1)*sizeof(PetscScalar),&glldata->A[0]);CHKERRQ(ierr);
+  ierr = PetscMalloc((p+1)*sizeof(*glldata->A),&glldata->A);CHKERRQ(ierr);
+  ierr = PetscMalloc((p+1)*(p+1)*sizeof(**glldata->A),&glldata->A[0]);CHKERRQ(ierr);
   for (i=1; i<p+1; i++) glldata->A[i]=glldata->A[i-1]+p+1;
 
   for (j=1; j<p; j++) {
     z0=1.0;
     z1=x;
     for (n=1; n<p; n++) {
-      z2=x*z1*(2.0*n+1.0)/(n+1.0)-z0*n/(n+1.0);
+      z2=x*z1*(2.0*n+1.0)/(n+1.0)-z0*(PetscScalar)(n/(n+1.0));
       z0=z1;
       z1=z2;
     }
         z0 = 1.0;
         z1 = x;
         for (n=1; n<p; n++) {
-          z2=x*z1*(2.0*n+1.0)/(n+1.0)-z0*n/(n+1.0);
+          z2=x*z1*(2.0*n+1.0)/(n+1.0)-z0*(PetscScalar)(n/(n+1.0));
           z0=z1;
           z1=z2;
         }
     z0 = 1.0;
     z1 = x;
     for (n=1; n<p; n++) {
-      z2=x*z1*(2.0*n+1.0)/(n+1.0)-z0*n/(n+1.0);
+      z2=x*z1*(2.0*n+1.0)/(n+1.0)-z0*(PetscScalar)(n/(n+1.0));
       z0=z1;
       z1=z2;
     }
     z0 = 1.0;
     z1 = x;
     for (n=1; n<p; n++) {
-      z2=x*z1*(2.0*n+1.0)/(n+1.0)-z0*n/(n+1.0);
+      z2=x*z1*(2.0*n+1.0)/(n+1.0)-z0*(PetscScalar)(n/(n+1.0));
       z0=z1;
       z1=z2;
     }
   factor = 0.0;
   ierr   = PetscOptionsGetInt(NULL,"-jump",&factor,NULL);CHKERRQ(ierr);
   /* checkerboard pattern */
-  dd->scalingfactor = PetscPowScalar(10,(PetscScalar)factor*PetscPowScalar(-1.0,(PetscScalar)rank));
+  dd->scalingfactor = PetscPowScalar(10.0,(PetscScalar)factor*PetscPowScalar(-1.0,(PetscScalar)rank));
   /* test data passed in */
   if (dd->dim==1) {
     if (nprocs!=dd->npx) SETERRQ(dd->gcomm,PETSC_ERR_USER,"Number of mpi procs in 1D must be equal to npx");
   PetscErrorCode ierr;
   DomainData     dd;
   PetscReal      norm,maxeig,mineig;
+  PetscScalar    scalar_value;
   PetscInt       ndofs,its;
   Mat            A                  =0,F=0;
   KSP            KSPwithBDDC        =0,KSPwithFETIDP=0;
   ierr = VecScale(exact_solution,100.0);CHKERRQ(ierr);
   ierr = VecGetSize(exact_solution,&ndofs);
   if (dd.pure_neumann) {
-    ierr = VecSum(exact_solution,&norm);CHKERRQ(ierr);
-    norm = -norm/(PetscScalar)ndofs;
-    ierr = VecShift(exact_solution,norm);CHKERRQ(ierr);
+    ierr = VecSum(exact_solution,&scalar_value);CHKERRQ(ierr);
+    scalar_value = -scalar_value/(PetscScalar)ndofs;
+    ierr = VecShift(exact_solution,scalar_value);CHKERRQ(ierr);
   }
   /* assemble BDDC rhs */
   ierr = MatMult(A,exact_solution,bddc_rhs);CHKERRQ(ierr);
   ierr = KSPGetIterationNumber(KSPwithBDDC,&its);CHKERRQ(ierr);
   ierr = KSPComputeExtremeSingularValues(KSPwithBDDC,&maxeig,&mineig);CHKERRQ(ierr);
   if (dd.pure_neumann) {
-    ierr = VecSum(bddc_solution,&norm);CHKERRQ(ierr);
-    norm = -norm/(PetscScalar)ndofs;
-    ierr = VecShift(bddc_solution,norm);CHKERRQ(ierr);
+    ierr = VecSum(bddc_solution,&scalar_value);CHKERRQ(ierr);
+    scalar_value = -scalar_value/(PetscScalar)ndofs;
+    ierr = VecShift(bddc_solution,scalar_value);CHKERRQ(ierr);
   }
   /* check exact_solution and BDDC solultion */
   ierr = VecAXPY(bddc_solution,-1.0,exact_solution);CHKERRQ(ierr);
   ierr = PCBDDCMatFETIDPGetSolution(F,fetidp_solution,fetidp_solution_all);CHKERRQ(ierr);
   /* check FETIDP sol */
   if (dd.pure_neumann) {
-    ierr = VecSum(fetidp_solution_all,&norm);CHKERRQ(ierr);
-    norm = -norm/(PetscScalar)ndofs;
-    ierr = VecShift(fetidp_solution_all,norm);CHKERRQ(ierr);
+    ierr = VecSum(fetidp_solution_all,&scalar_value);CHKERRQ(ierr);
+    scalar_value = -scalar_value/(PetscScalar)ndofs;
+    ierr = VecShift(fetidp_solution_all,scalar_value);CHKERRQ(ierr);
   }
   ierr = VecAXPY(fetidp_solution_all,-1.0,exact_solution);CHKERRQ(ierr);
   ierr = VecNorm(fetidp_solution_all,NORM_INFINITY,&norm);CHKERRQ(ierr);

src/ksp/pc/impls/bddc/bddc.c

   PetscScalar*      array;
   PetscScalar       *coarse_submat_vals;
   PetscInt          *idx_R_local;
-  PetscScalar       *coarsefunctions_errors;
-  PetscScalar       *constraints_errors;
+  PetscReal         *coarsefunctions_errors,*constraints_errors;
   /* auxiliary indices */
   PetscInt          i,j,k;
   /* for verbose output of bddc */
   PetscViewer       viewer=pcbddc->dbg_viewer;
-  PetscBool         dbg_flag=pcbddc->dbg_flag;
+  PetscInt          dbg_flag=pcbddc->dbg_flag;
   /* for counting coarse dofs */
   PetscInt          n_vertices,n_constraints;
   PetscInt          size_of_constraint;
     }
 
     if (dbg_flag) {
-      ierr = PetscMalloc(2*pcbddc->local_primal_size*sizeof(PetscScalar),&coarsefunctions_errors);CHKERRQ(ierr);
-      ierr = PetscMalloc(2*pcbddc->local_primal_size*sizeof(PetscScalar),&constraints_errors);CHKERRQ(ierr);
+      ierr = PetscMalloc(2*pcbddc->local_primal_size*sizeof(*coarsefunctions_errors),&coarsefunctions_errors);CHKERRQ(ierr);
+      ierr = PetscMalloc(2*pcbddc->local_primal_size*sizeof(*constraints_errors),&constraints_errors);CHKERRQ(ierr);
     }
     /* Subdomain contribution (Non-overlapping) to coarse matrix  */
     ierr = PetscMalloc ((pcbddc->local_primal_size)*(pcbddc->local_primal_size)*sizeof(PetscScalar),&coarse_submat_vals);CHKERRQ(ierr);
       Mat         coarse_psi_D,coarse_psi_B;
       Mat         A_II,A_BB,A_IB,A_BI;
       MatType     checkmattype=MATSEQAIJ;
-      PetscScalar value;
+      PetscReal   real_value;
 
       ierr = MatConvert(pcis->A_II,checkmattype,MAT_INITIAL_MATRIX,&A_II);CHKERRQ(ierr);
       ierr = MatConvert(pcis->A_IB,checkmattype,MAT_INITIAL_MATRIX,&A_IB);CHKERRQ(ierr);
       ierr = MatAXPY(TM1,one,TM4,DIFFERENT_NONZERO_PATTERN);CHKERRQ(ierr);
       ierr = MatConvert(TM1,MATSEQDENSE,MAT_REUSE_MATRIX,&TM1);CHKERRQ(ierr);
       ierr = MatAXPY(TM1,m_one,coarse_sub_mat,SAME_NONZERO_PATTERN);CHKERRQ(ierr);
-      ierr = MatNorm(TM1,NORM_INFINITY,&value);CHKERRQ(ierr);
+      ierr = MatNorm(TM1,NORM_INFINITY,&real_value);CHKERRQ(ierr);
       ierr = PetscViewerASCIISynchronizedPrintf(viewer,"----------------------------------\n");CHKERRQ(ierr);
       ierr = PetscViewerASCIISynchronizedPrintf(viewer,"Subdomain %04d \n",PetscGlobalRank);CHKERRQ(ierr);
-      ierr = PetscViewerASCIISynchronizedPrintf(viewer,"matrix error = % 1.14e\n",value);CHKERRQ(ierr);
+      ierr = PetscViewerASCIISynchronizedPrintf(viewer,"matrix error = % 1.14e\n",real_value);CHKERRQ(ierr);
       ierr = PetscViewerASCIISynchronizedPrintf(viewer,"coarse functions (phi) errors\n");CHKERRQ(ierr);
       for (i=0;i<pcbddc->local_primal_size;i++) {
         ierr = PetscViewerASCIISynchronizedPrintf(viewer,"local %02d-th function error = % 1.14e\n",i,coarsefunctions_errors[i]);CHKERRQ(ierr);
   PetscMPIInt master_proc=0;
   PetscInt    ins_local_primal_size;
   /* specific to MULTILEVEL_BDDC */
-  PetscMPIInt *ranks_recv;
+  PetscMPIInt *ranks_recv=0;
   PetscMPIInt count_recv=0;
-  PetscMPIInt rank_coarse_proc_send_to;
+  PetscMPIInt rank_coarse_proc_send_to=-1;
   PetscMPIInt coarse_color = MPI_UNDEFINED;
   ISLocalToGlobalMapping coarse_ISLG;
   /* some other variables */
   PetscInt max_it_coarse_ksp=1;  /* don't increase this value */
   /* verbose output viewer */
   PetscViewer viewer=pcbddc->dbg_viewer;
-  PetscBool   dbg_flag=pcbddc->dbg_flag;
+  PetscInt    dbg_flag=pcbddc->dbg_flag;
 
   PetscInt      offset,offset2;
   PetscMPIInt   im_active,active_procs;
       }
       ierr = PetscViewerFlush(viewer);CHKERRQ(ierr);
       for (i=0;i<pcis->n;i++) {
-        if (array[i] > 0.0) array[i] = 1.0/array[i];
+        if (PetscRealPart(array[i]) > 0.0) array[i] = 1.0/PetscRealPart(array[i]);
       }
       ierr = VecRestoreArray(pcis->vec1_N,&array);CHKERRQ(ierr);
       ierr = VecSet(pcis->vec1_global,0.0);CHKERRQ(ierr);
         ierr = VecAssemblyEnd(vec_onz);CHKERRQ(ierr);
         j = mat_ranges[rank_prec_comm+1]-mat_ranges[rank_prec_comm];
         ierr = VecGetArray(vec_dnz,&array);CHKERRQ(ierr);
-        for (i=0; i<j; i++) dnz[i] = (PetscInt)array[i];
+        for (i=0; i<j; i++) dnz[i] = (PetscInt)PetscRealPart(array[i]);
 
         ierr = VecRestoreArray(vec_dnz,&array);CHKERRQ(ierr);
         ierr = VecGetArray(vec_onz,&array);CHKERRQ(ierr);
-        for (i=0;i<j;i++) onz[i] = (PetscInt)array[i];
+        for (i=0;i<j;i++) onz[i] = (PetscInt)PetscRealPart(array[i]);
 
         ierr = VecRestoreArray(vec_onz,&array);CHKERRQ(ierr);
         ierr = PetscFree(my_dnz);CHKERRQ(ierr);

src/ksp/pc/impls/bddc/bddcfetidp.c

   ierr = VecScatterBegin(matis->ctx,pcis->vec1_N,pcis->vec1_global,ADD_VALUES,SCATTER_REVERSE);CHKERRQ(ierr);
   ierr = VecScatterEnd  (matis->ctx,pcis->vec1_N,pcis->vec1_global,ADD_VALUES,SCATTER_REVERSE);CHKERRQ(ierr);
   ierr = VecSum(pcis->vec1_global,&scalar_value);CHKERRQ(ierr);
-  fetidpmat_ctx->n_lambda = (PetscInt) scalar_value;
+  fetidpmat_ctx->n_lambda = (PetscInt)PetscRealPart(scalar_value);
 
   /* compute global ordering of lagrange multipliers and associate l2g map */
   ierr = PCBDDCSubsetNumbering(comm,matis->mapping,partial_sum,aux_local_numbering_1,aux_local_numbering_2,&i,&aux_global_numbering);CHKERRQ(ierr);
 
   if (test_fetidp && !pcbddc->use_deluxe_scaling) {
 
+    PetscReal real_value;
+
     ierr = PetscViewerASCIIGetStdout(comm,&viewer);CHKERRQ(ierr);
     ierr = PetscViewerASCIISynchronizedAllow(viewer,PETSC_TRUE);CHKERRQ(ierr);
     ierr = PetscViewerASCIIPrintf(viewer,"----------FETI_DP TESTS--------------\n");CHKERRQ(ierr);
     ierr = VecScatterEnd  (fetidpmat_ctx->l2g_lambda,lambda_global,fetidpmat_ctx->lambda_local,INSERT_VALUES,SCATTER_REVERSE);CHKERRQ(ierr);
     scalar_value = -1.0;
     ierr = VecAXPY(test_vec,scalar_value,fetidpmat_ctx->lambda_local);CHKERRQ(ierr);
-    ierr = VecNorm(test_vec,NORM_INFINITY,&scalar_value);CHKERRQ(ierr);
+    ierr = VecNorm(test_vec,NORM_INFINITY,&real_value);CHKERRQ(ierr);
     ierr = VecDestroy(&test_vec);CHKERRQ(ierr);
-    ierr = PetscViewerASCIISynchronizedPrintf(viewer,"A[%04d]: CHECK glob to loc: % 1.14e\n",rank,scalar_value);CHKERRQ(ierr);
+    ierr = PetscViewerASCIISynchronizedPrintf(viewer,"A[%04d]: CHECK glob to loc: % 1.14e\n",rank,real_value);CHKERRQ(ierr);
     ierr = PetscViewerFlush(viewer);CHKERRQ(ierr);
     if (fully_redundant) {
       ierr = VecSet(lambda_global,0.0);CHKERRQ(ierr);
       ierr = VecScatterBegin(fetidpmat_ctx->l2g_lambda,fetidpmat_ctx->lambda_local,lambda_global,ADD_VALUES,SCATTER_FORWARD);CHKERRQ(ierr);
       ierr = VecScatterEnd  (fetidpmat_ctx->l2g_lambda,fetidpmat_ctx->lambda_local,lambda_global,ADD_VALUES,SCATTER_FORWARD);CHKERRQ(ierr);
       ierr = VecSum(lambda_global,&scalar_value);CHKERRQ(ierr);
-      ierr = PetscViewerASCIISynchronizedPrintf(viewer,"B[%04d]: CHECK loc to glob: % 1.14e\n",rank,scalar_value-fetidpmat_ctx->n_lambda);CHKERRQ(ierr);
+      ierr = PetscViewerASCIISynchronizedPrintf(viewer,"B[%04d]: CHECK loc to glob: % 1.14e\n",rank,PetscRealPart(scalar_value)-fetidpmat_ctx->n_lambda);CHKERRQ(ierr);
       ierr = PetscViewerFlush(viewer);CHKERRQ(ierr);
     }
 
     ierr = VecSet(lambda_global,0.0);CHKERRQ(ierr);
     ierr = VecScatterBegin(fetidpmat_ctx->l2g_lambda,fetidpmat_ctx->lambda_local,lambda_global,ADD_VALUES,SCATTER_FORWARD);CHKERRQ(ierr);
     ierr = VecScatterEnd  (fetidpmat_ctx->l2g_lambda,fetidpmat_ctx->lambda_local,lambda_global,ADD_VALUES,SCATTER_FORWARD);CHKERRQ(ierr);
-    ierr = VecNorm(lambda_global,NORM_INFINITY,&scalar_value);CHKERRQ(ierr);
-    ierr = PetscViewerASCIIPrintf(viewer,"C[coll]: CHECK infty norm of B_delta*w (w continuous): % 1.14e\n",scalar_value);CHKERRQ(ierr);
+    ierr = VecNorm(lambda_global,NORM_INFINITY,&real_value);CHKERRQ(ierr);
+    ierr = PetscViewerASCIIPrintf(viewer,"C[coll]: CHECK infty norm of B_delta*w (w continuous): % 1.14e\n",real_value);CHKERRQ(ierr);
     ierr = PetscViewerFlush(viewer);CHKERRQ(ierr);
 
     /******************************************************************/
     ierr = VecAXPY(pcis->vec1_B,scalar_value,pcis->vec2_B);CHKERRQ(ierr);
     scalar_value = -1.0;
     ierr = VecAXPY(pcis->vec1_B,scalar_value,test_vec);CHKERRQ(ierr);
-    ierr = VecNorm(pcis->vec1_B,NORM_INFINITY,&scalar_value);CHKERRQ(ierr);
+    ierr = VecNorm(pcis->vec1_B,NORM_INFINITY,&real_value);CHKERRQ(ierr);
     ierr = VecDestroy(&test_vec);CHKERRQ(ierr);
-    ierr = PetscViewerASCIISynchronizedPrintf(viewer,"D[%04d] CHECK infty norm of E_D + P_D - I: % 1.14e\n",rank,scalar_value);CHKERRQ(ierr);
+    ierr = PetscViewerASCIISynchronizedPrintf(viewer,"D[%04d] CHECK infty norm of E_D + P_D - I: % 1.14e\n",rank,real_value);CHKERRQ(ierr);
     ierr = PetscViewerFlush(viewer);CHKERRQ(ierr);
 
     /******************************************************************/
     ierr = MatMultTranspose(fetidpmat_ctx->B_Ddelta,fetidpmat_ctx->lambda_local,pcis->vec1_B);CHKERRQ(ierr);
     /* scaling */
     ierr = PCBDDCScalingExtension(fetidpmat_ctx->pc,pcis->vec1_B,pcis->vec1_global);CHKERRQ(ierr);
-    ierr = VecNorm(pcis->vec1_global,NORM_INFINITY,&scalar_value);CHKERRQ(ierr);
-    ierr = PetscViewerASCIIPrintf(viewer,"E[coll]: CHECK infty norm of R^T_D P_D: % 1.14e\n",scalar_value);CHKERRQ(ierr);
+    ierr = VecNorm(pcis->vec1_global,NORM_INFINITY,&real_value);CHKERRQ(ierr);
+    ierr = PetscViewerASCIIPrintf(viewer,"E[coll]: CHECK infty norm of R^T_D P_D: % 1.14e\n",real_value);CHKERRQ(ierr);
     ierr = PetscViewerFlush(viewer);CHKERRQ(ierr);
 
     if (!fully_redundant) {
       ierr = VecScatterEnd  (fetidpmat_ctx->l2g_lambda,fetidpmat_ctx->lambda_local,test_vec,ADD_VALUES,SCATTER_FORWARD);CHKERRQ(ierr);
       scalar_value = -1.0;
       ierr = VecAXPY(lambda_global,scalar_value,test_vec);CHKERRQ(ierr);
-      ierr = VecNorm(lambda_global,NORM_INFINITY,&scalar_value);CHKERRQ(ierr);
-      ierr = PetscViewerASCIIPrintf(viewer,"E[coll]: CHECK infty norm of P^T_D - I: % 1.14e\n",scalar_value);CHKERRQ(ierr);
+      ierr = VecNorm(lambda_global,NORM_INFINITY,&real_value);CHKERRQ(ierr);
+      ierr = PetscViewerASCIIPrintf(viewer,"E[coll]: CHECK infty norm of P^T_D - I: % 1.14e\n",real_value);CHKERRQ(ierr);
       ierr = PetscViewerFlush(viewer);CHKERRQ(ierr);
       ierr = PetscViewerFlush(viewer);CHKERRQ(ierr);
       ierr = VecDestroy(&test_vec);CHKERRQ(ierr);

src/ksp/pc/impls/bddc/bddcgraph.c

   ierr = VecScatterEnd(scatter_ctx,global_vec,local_vec,INSERT_VALUES,SCATTER_FORWARD);CHKERRQ(ierr);
   ierr = VecGetArray(local_vec,&array);CHKERRQ(ierr);
   for (i=0;i<graph->nvtxs;i++) {
-    if (array[i] > 0.0) {
+    if (PetscRealPart(array[i]) > 0.0) {
       graph->which_dof[i] = NEUMANN_MARK;
     }
   }
     for (i=0;i<is_size;i++){
       k = is_indices[i];
       if (graph->count[k] && !graph->touched[k]) {
-        if (array[k] > 0.0) {
+        if (PetscRealPart(array[k]) > 0.0) {
           SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_USER,"BDDC cannot have boundary nodes which are marked Neumann and Dirichlet at the same time! Local node %d is wrong!\n",k);
         }
         array2[k] = 1.0;
   ierr = VecScatterEnd(scatter_ctx,global_vec,local_vec,INSERT_VALUES,SCATTER_FORWARD);CHKERRQ(ierr);
   ierr = VecGetArray(local_vec,&array);CHKERRQ(ierr);
   for (i=0;i<graph->nvtxs;i++) {
-    if (array[i] > 0.0) {
+    if (PetscRealPart(array[i]) > 0.0) {
       graph->touched[i] = PETSC_TRUE;
       graph->subset[i] = 0; /* dirichlet nodes treated as internal -> is it ok? */
       graph->which_dof[i] = DIRICHLET_MARK;

src/ksp/pc/impls/bddc/bddcprivate.c

   PetscInt       *temp_indices,*temp_indices_to_constraint,*temp_indices_to_constraint_B,*local_to_B;
   PetscInt       local_primal_size,i,j,k,total_counts,max_size_of_constraint;
   PetscInt       n_vertices,size_of_constraint;
-  PetscScalar    quad_value;
+  PetscReal      real_value;
   PetscBool      nnsp_has_cnst=PETSC_FALSE,use_nnsp_true=pcbddc->use_nnsp_true;
   PetscInt       nnsp_size=0,nnsp_addone=0,temp_constraints,temp_start_ptr,n_ISForFaces,n_ISForEdges;
   IS             *used_IS,ISForVertices,*ISForFaces,*ISForEdges;
       boolforchange = PETSC_FALSE;
     }
     if (nnsp_has_cnst) {
+      PetscScalar quad_value;
       temp_constraints++;
       quad_value = (PetscScalar)(1.0/PetscSqrtReal((PetscReal)size_of_constraint));
       for (j=0;j<size_of_constraint;j++) {
         temp_quadrature_constraint[temp_indices[total_counts]+j]=array_vector[is_indices[j]];
       }
       ierr = VecRestoreArrayRead(localnearnullsp[k],(const PetscScalar**)&array_vector);CHKERRQ(ierr);
-      quad_value = 1.0;
+      real_value = 1.0;
       if (use_nnsp_true) { /* check if array is null on the connected component in case use_nnsp_true has been requested */
         ierr = PetscBLASIntCast(size_of_constraint,&Bs);CHKERRQ(ierr);
-        PetscStackCallBLAS("BLASasum",quad_value = BLASasum_(&Bs,&temp_quadrature_constraint[temp_indices[total_counts]],&Bone));
+        PetscStackCallBLAS("BLASasum",real_value = BLASasum_(&Bs,&temp_quadrature_constraint[temp_indices[total_counts]],&Bone));
       }
-      if (quad_value > 0.0) { /* keep indices and values */
+      if (real_value > 0.0) { /* keep indices and values */
         temp_constraints++;
         temp_indices[total_counts+1]=temp_indices[total_counts]+size_of_constraint;  /* store new starting point */
         change_basis[total_counts]=boolforchange;
       /* Store upper triangular part of correlation matrix */
       for (j=0;j<temp_constraints;j++) {
         for (k=0;k<j+1;k++) {
-          PetscStackCallBLAS("BLASdot_",correlation_mat[j*temp_constraints+k]=BLASdot_(&Bs,&temp_quadrature_constraint[temp_indices[temp_start_ptr+j]],&Bone,&temp_quadrature_constraint[temp_indices[temp_start_ptr+k]],&Bone));
+          PetscStackCallBLAS("BLASdot",correlation_mat[j*temp_constraints+k]=BLASdot_(&Bs,&temp_quadrature_constraint[temp_indices[temp_start_ptr+j]],&Bone,&temp_quadrature_constraint[temp_indices[temp_start_ptr+k]],&Bone));
 
         }
       }
   ierr = VecRestoreArray(local_vec,&array);CHKERRQ(ierr);
   /* scatter into global vec and get total number of global dofs */
   ierr = VecScatterBegin(scatter_ctx,local_vec,global_vec,INSERT_VALUES,SCATTER_FORWARD);CHKERRQ(ierr);
-  ierr = VecScatterEnd  (scatter_ctx,local_vec,global_vec,INSERT_VALUES,SCATTER_FORWARD);CHKERRQ(ierr);
+  ierr = VecScatterEnd(scatter_ctx,local_vec,global_vec,INSERT_VALUES,SCATTER_FORWARD);CHKERRQ(ierr);
   ierr = VecSum(global_vec,&globalsum);CHKERRQ(ierr);
-  *n_global_subset = (PetscInt)globalsum;
+  *n_global_subset = (PetscInt)PetscRealPart(globalsum);
   /* Fill global_vec with cumulative function for global numbering */
   ierr = VecGetArray(global_vec,&array);CHKERRQ(ierr);
   ierr = VecGetLocalSize(global_vec,&s);CHKERRQ(ierr);
   first_index = -1;
   first_found = PETSC_FALSE;
   for (i=0;i<s;i++) {
-    if (!first_found && array[i] > 0.0) {
+    if (!first_found && PetscRealPart(array[i]) > 0.0) {
       first_found = PETSC_TRUE;
       first_index = i;
     }
-    nlocals += (PetscInt)array[i];
+    nlocals += (PetscInt)PetscRealPart(array[i]);
   }
   ierr = MPI_Gather(&nlocals,1,MPIU_INT,dof_sizes,1,MPIU_INT,0,comm);CHKERRQ(ierr);
   if (!rank_prec_comm) {
     array[first_index] += (PetscScalar)nlocals;
     old_index = first_index;
     for (i=first_index+1;i<s;i++) {
-      if (array[i] > 0.0) {
+      if (PetscRealPart(array[i]) > 0.0) {
         array[i] += array[old_index];
         old_index = i;
       }
   ierr = VecGetArray(local_vec,&array);CHKERRQ(ierr);
   if (local_dofs_mult) {
     for (i=0;i<n_local_dofs;i++) {
-      temp_global_dofs[i] = (PetscInt)array[local_dofs[i]]-local_dofs_mult[i];
+      temp_global_dofs[i] = (PetscInt)PetscRealPart(array[local_dofs[i]])-local_dofs_mult[i];
     }
   } else {
     for (i=0;i<n_local_dofs;i++) {
-      temp_global_dofs[i] = (PetscInt)array[local_dofs[i]]-1;
+      temp_global_dofs[i] = (PetscInt)PetscRealPart(array[local_dofs[i]])-1;
     }
   }
   ierr = VecRestoreArray(local_vec,&array);CHKERRQ(ierr);