qrm_solver Subroutine

public subroutine qrm_solver(me, n_cols, n_rows, n_nonzero, irow, icol, a, b, x, istat)

Custom solver that uses QR_MUMPS

TODO: add a compiler directive to indicate this is present so it can be optional

Arguments

Type IntentOptional Attributes Name
class(nlesolver_type), intent(inout) :: me
integer, intent(in) :: n_cols

n: number of columns in A.

integer, intent(in) :: n_rows

m: number of rows in A.

integer, intent(in) :: n_nonzero

number of nonzero elements of A.

integer, intent(in), dimension(n_nonzero) :: irow

sparsity pattern (size is n_nonzero)

integer, intent(in), dimension(n_nonzero) :: icol

sparsity pattern (size is n_nonzero)

real(kind=wp), intent(in), dimension(n_nonzero) :: a

matrix elements (size is n_nonzero)

real(kind=wp), intent(in), dimension(n_rows) :: b

right hand side (size is m)

real(kind=wp), intent(out), dimension(n_cols) :: x

solution (size is n)

integer, intent(out) :: istat

status code (=0 for success)


Source Code

    subroutine qrm_solver(me,n_cols,n_rows,n_nonzero,irow,icol,a,b,x,istat)
#ifdef WITH_QRMUMPS
        use dqrm_mod
#endif
        implicit none

        class(nlesolver_type),intent(inout) :: me
        integer,intent(in) :: n_cols !! `n`: number of columns in A.
        integer,intent(in) :: n_rows !! `m`: number of rows in A.
        integer,intent(in) :: n_nonzero !! number of nonzero elements of A.
        integer,dimension(n_nonzero),intent(in) :: irow, icol !! sparsity pattern (size is `n_nonzero`)
        real(wp),dimension(n_nonzero),intent(in) :: a !! matrix elements (size is `n_nonzero`)
        real(wp),dimension(n_rows),intent(in) :: b !! right hand side (size is `m`)
        real(wp),dimension(n_cols),intent(out) :: x !! solution (size is `n`)
        integer,intent(out) :: istat !! status code (=0 for success)

#ifdef WITH_QRMUMPS
        type(dqrm_spmat_type) :: qrm_spmat

        ! hack because we have to point to them ! can we avoid this ?? <-----
        integer,dimension(:),allocatable,target :: irow_, icol_
        real(wp),dimension(:),allocatable,target :: a_, r_
        !--------------------------------------------------------------------

        allocate(irow_, source=irow)
        allocate(icol_, source=icol)
        allocate(a_ , source=a)
        allocate(r_ , source=b)

        call qrm_init()

        ! initialize the matrix data structure.
        call qrm_spmat_init(qrm_spmat)

        qrm_spmat%m   =  n_rows
        qrm_spmat%n   =  n_cols
        qrm_spmat%nz  =  n_nonzero
        qrm_spmat%irn => irow_
        qrm_spmat%jcn => icol_
        qrm_spmat%val => a_

        call qrm_spmat_gels(qrm_spmat, r_, x)

        istat = 0 ! how to get status code?

#else
    error stop 'This code was not build with QR_MUMPS'
#endif
    end subroutine qrm_solver