solv_superlu Subroutine

public subroutine solv_superlu(sol_x, sulu, verbose)

Note

Subroutine to solve the system

  • If no resolution has yet occured, sulu%first=true
    • sulu%options%Fact = FACTORED
    • sulu%SMB%ncol = sulu%nrhs (usually 1)
  • otherwise
    • sulu%options%Fact = SAMEPATTERN
    • sma, smb and smx are recreated but do not forget that we still have:
      • mat%matsulu%irow => mat%irow
      • mat%matsulu%jptr => mat%jptr
      • mat%matsulu%a_elt => mat%a_elt
      • mat%matsulu%b => mat%b

Note

The solution is retrieved with the pointer store of type NCFORMAT which gives access to nzval

Warning

At the end, the memory is released with the dstruction of sml and smu

Arguments

Type IntentOptional Attributes Name
real(kind=R8), intent(inout), dimension(:) :: sol_x
type(SULU_ENV), intent(inout) :: sulu
logical(kind=I4), intent(in) :: verbose

Calls

proc~~solv_superlu~~CallsGraph proc~solv_superlu solv_superlu interface~destroy_compcol_matrix Destroy_CompCol_Matrix proc~solv_superlu->interface~destroy_compcol_matrix interface~destroy_supernode_matrix Destroy_SuperNode_Matrix proc~solv_superlu->interface~destroy_supernode_matrix interface~dgssvx dgssvx proc~solv_superlu->interface~dgssvx interface~statfree StatFree proc~solv_superlu->interface~statfree interface~statinit StatInit proc~solv_superlu->interface~statinit interface~statprint StatPrint proc~solv_superlu->interface~statprint proc~prep_superlu prep_superlu proc~solv_superlu->proc~prep_superlu interface~dcreate_compcol_matrix dCreate_CompCol_Matrix proc~prep_superlu->interface~dcreate_compcol_matrix interface~dcreate_dense_matrix dCreate_Dense_Matrix proc~prep_superlu->interface~dcreate_dense_matrix

Called by

proc~~solv_superlu~~CalledByGraph proc~solv_superlu solv_superlu proc~solution_solver solution_solver proc~solution_solver->proc~solv_superlu proc~solve_syst solve_syst proc~solution_solver->proc~solve_syst proc~solve_syst->proc~solution_solver program~test_solvers test_solvers program~test_solvers->proc~solve_syst

Source Code

   subroutine solv_superlu(sol_x, sulu, verbose)
   implicit none
   real(kind=R8),    dimension(:), intent(inout) :: sol_x
   type(SULU_ENV),                 intent(inout) :: sulu
   logical(kind=I4),               intent(in)    :: verbose
      type(NCFORMAT), pointer :: Xstore
      real(kind=R8),  pointer :: tabX(:)
      integer(kind=I4)        :: i

      call StatInit(sulu%stat)

      if ( sulu%first ) then
         sulu%options%Fact = FACTORED
         sulu%SMB%ncol     = sulu%nrhs
      else
         sulu%options%Fact = SAMEPATTERN
         call prep_superlu(sulu)
      endif

      call dgssvx(   options            = sulu%options,   & ! superlu_options_t   *options
                     A                  = sulu%SMA,       & ! SuperMatrix         *A
                     perm_c             = sulu%perm_c,    & ! int                 *perm_c
                     perm_r             = sulu%perm_r,    & ! int                 *perm_r
                     etree              = sulu%etree ,    & ! int                 *etree
                     equed              = sulu%equed,     & ! char                *equed
                     R                  = sulu%RR,        & ! double              *R
                     C                  = sulu%CC,        & ! double              *C
                     L                  = sulu%SML,       & ! SuperMatrix         *L
                     U                  = sulu%SMU,       & ! SuperMatrix         *U
                     work               = sulu%work,      & ! void                *work
                     lwork              = sulu%lwork,     & ! int                  lwork
                     B                  = sulu%SMB,       & ! SuperMatrix         *B
                     X                  = sulu%SMX,       & ! SuperMatrix         *X
                     recip_pivot_growth = sulu%rpg,       & ! double              *recip_pivot_growth
                     rcond              = sulu%rcond,     & ! double              *rcond
                     ferr               = sulu%ferr,      & ! double              *ferr
                     berr               = sulu%berr,      & ! double              *berr
                     Glu                = sulu%Glu,       & ! GlobalLU_t          *Glu
                     mem_usage          = sulu%mem_usage, & ! mem_usage_t         *mem_usage
                     stat               = sulu%stat,      & ! SuperLUStat_t       *stat
                     info               = sulu%info       & ! int                 *info
                  )

      call c_f_pointer(sulu%SMX%Store, XStore)
      call c_f_pointer(XStore%nzval, tabX, [XStore%nnz])
      do i = 1, sulu%n
         sol_x(i) = tabX(i)
      enddo
      nullify(Xstore, tabX)

      if (verbose) call StatPrint(sulu%stat)
      call StatFree(sulu%stat)

      call Destroy_SuperNode_Matrix(sulu%SML)
      call Destroy_CompCol_Matrix(  sulu%SMU)

   return
   endsubroutine solv_superlu