Commits

Lisandro Dalcin committed 07a2d54

Update after changes to PetscBLASIntCast() in petsc-dev

  • Participants
  • Parent commits 84e8f8c

Comments (0)

Files changed (3)

File src/petigapc.h

                          PetscBLASInt*,PetscScalar*,PetscBLASInt*,
                          PetscBLASInt*);
 EXTERN_C_END
+
+#if PETSC_VERSION_(3,3,0) || PETSC_VERSION_(3,2,0)
+#undef PetscBLASIntCast
+#undef __FUNCT__
+#define __FUNCT__ "PetscBLASIntCast"
+PETSC_STATIC_INLINE PetscErrorCode PetscBLASIntCast(PetscInt a,PetscBLASInt *b)
+{
+  PetscFunctionBegin;
+#if defined(PETSC_USE_64BIT_INDICES) && !defined(PETSC_HAVE_64BIT_BLAS_INDICES)
+  if ((a) > PETSC_BLAS_INT_MAX) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Array too long for BLAS/LAPACK");
+#endif
+  *b =  (PetscBLASInt)(a);
+  PetscFunctionReturn(0);
+}
+#endif

File src/petigapcb.c

 
     for (n=dof, i=0; i<dim; n *= (2*overlap[i++] + 1));
 
+    ierr = PetscBLASIntCast(n,&m);CHKERRQ(ierr);
     ierr = PetscMalloc2(n,PetscInt,&indices,n*n,PetscScalar,&values);CHKERRQ(ierr);
-    m = PetscBLASIntCast(n); lwork = -1; work = &lwkopt;
     ierr = PetscMalloc1(m,PetscBLASInt,&ipiv);CHKERRQ(ierr);
+    lwork = -1; work = &lwkopt;
     LAPACKgetri_(&m,values,&m,ipiv,work,&lwork,&info);
     lwork = (info==0) ? (PetscBLASInt)work[0] : m*128;
     ierr = PetscMalloc1(lwork,PetscScalar,&work);CHKERRQ(ierr);
             ierr = MatGetValues(A,n,indices,n,indices,values);CHKERRQ(ierr);
             /* compute inverse of element matrix */
             if (PetscLikely(n > 1)) {
-              m = PetscBLASIntCast(n);
+              ierr = PetscBLASIntCast(n,&m);CHKERRQ(ierr);
               LAPACKgetrf_(&m,&m,values,&m,ipiv,&info);
               if (info<0) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_LIB,"Bad argument to LAPACKgetrf_");
               if (info>0) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_MAT_LU_ZRPVT,"Zero-pivot in LU factorization");

File src/petigapce.c

     start /= dof; end /= dof;
 
     n = nen*dof;
+    ierr = PetscBLASIntCast(n,&m);CHKERRQ(ierr);
     ierr = PetscMalloc2(n,PetscInt,&indices,n*n,PetscScalar,&values);CHKERRQ(ierr);
-    m = PetscBLASIntCast(n); lwork = -1; work = &lwkopt;
     ierr = PetscMalloc1(m,PetscBLASInt,&ipiv);CHKERRQ(ierr);
+    lwork = -1; work = &lwkopt;
     LAPACKgetri_(&m,values,&m,ipiv,work,&lwork,&info);
     lwork = (info==0) ? (PetscBLASInt)work[0] : m*128;
     ierr = PetscMalloc1(lwork,PetscScalar,&work);CHKERRQ(ierr);