From: Denis Davydov Date: Fri, 16 Feb 2018 20:20:03 +0000 (+0100) Subject: scalapack: query lwork from ppocon X-Git-Tag: v9.0.0-rc1~427^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8bd94c824a568ad2eae07bf27719f6fff1afe9c0;p=dealii.git scalapack: query lwork from ppocon --- diff --git a/source/lac/scalapack.cc b/source/lac/scalapack.cc index 1fbe23f489..74e3ce3a2d 100644 --- a/source/lac/scalapack.cc +++ b/source/lac/scalapack.cc @@ -831,12 +831,22 @@ NumberType ScaLAPACKMatrix::reciprocal_condition_number(const Number if (grid->mpi_process_is_active) { - int lwork = 2 * n_local_rows + 3 * n_local_columns + column_block_size; int liwork = n_local_rows; - work.resize(lwork); iwork.resize(liwork); + int info = 0; const NumberType *A_loc = &this->values[0]; + + // by setting lwork to -1 a workspace query for optimal length of work is performed + int lwork = -1; + work.resize(1); + ppocon(&uplo, &n_columns, A_loc, &submatrix_row, &submatrix_column, descriptor, + &a_norm, &rcond, &work[0], &lwork, &iwork[0], &liwork, &info); + AssertThrow (info==0, LAPACKSupport::ExcErrorCode("pdpocon", info)); + lwork = std::ceil(work[0]); + work.resize(lwork); + + // now the actual run: ppocon(&uplo, &n_columns, A_loc, &submatrix_row, &submatrix_column, descriptor, &a_norm, &rcond, &work[0], &lwork, &iwork[0], &liwork, &info); AssertThrow (info==0, LAPACKSupport::ExcErrorCode("pdpocon", info));