columns_in_partition_group Subroutine

private subroutine columns_in_partition_group(me, igroup, n_cols, cols, nonzero_rows, indices, status_ok)

Returns the columns in a sparsity partition group.

Note

This is just a wrapper to get data from ngrp.

Type Bound

sparsity_pattern

Arguments

Type IntentOptional Attributes Name
class(sparsity_pattern), intent(in) :: me
integer, intent(in) :: igroup

group number. Should be >0 and <=me%mxgrp

integer, intent(out) :: n_cols

number of columns in the igroup group.

integer, intent(out), dimension(:), allocatable :: cols

the column numbers in the igroup group. (if none, then it is not allocated)

integer, intent(out), dimension(:), allocatable :: nonzero_rows

the row numbers of all the nonzero Jacobian elements in this group

integer, intent(out), dimension(:), allocatable :: indices

nonzero indices in jac for a group

logical, intent(out) :: status_ok

true if the partition is valid


Called by

proc~~columns_in_partition_group~~CalledByGraph proc~columns_in_partition_group sparsity_pattern%columns_in_partition_group proc~compute_jacobian_partitioned compute_jacobian_partitioned proc~compute_jacobian_partitioned->proc~columns_in_partition_group

Source Code

    subroutine columns_in_partition_group(me,igroup,n_cols,cols,nonzero_rows,indices,status_ok)

    implicit none

    class(sparsity_pattern),intent(in)           :: me
    integer,intent(in)                           :: igroup       !! group number. Should be `>0` and `<=me%mxgrp`
    integer,intent(out)                          :: n_cols       !! number of columns in the `igroup` group.
    integer,dimension(:),allocatable,intent(out) :: cols         !! the column numbers in the `igroup` group.
                                                                 !! (if none, then it is not allocated)
    integer,dimension(:),allocatable,intent(out) :: nonzero_rows !! the row numbers of all the nonzero
                                                                 !! Jacobian elements in this group
    integer,dimension(:),allocatable,intent(out) :: indices      !! nonzero indices in `jac` for a group
    logical,intent(out)                          :: status_ok    !! true if the partition is valid

    integer :: i  !! counter
    integer :: c  !! column number
    integer :: k  !! counter for the nonzero elements in the group
    integer :: nnz_col !! number of nonzero elements in a column
    integer :: num_nonzero_elements_in_group  !! number of nonzero elements in a group

    status_ok = me%maxgrp>0 .and. allocated(me%ngrp) .and. &
                allocated(me%grp_ptr) .and. allocated(me%col_ptr)
    if (status_ok) status_ok = igroup>=1 .and. igroup<=me%maxgrp
    if (.not. status_ok) then
        n_cols = 0
        return
    end if

    n_cols = me%grp_ptr(igroup+1) - me%grp_ptr(igroup)
    if (n_cols==0) return
    cols = me%grp_cols(me%grp_ptr(igroup):me%grp_ptr(igroup+1)-1)

    ! get all the non-zero elements in each column:
    num_nonzero_elements_in_group = 0
    do i = 1, n_cols
        c = cols(i)
        num_nonzero_elements_in_group = num_nonzero_elements_in_group + &
                                        me%col_ptr(c+1) - me%col_ptr(c)
    end do
    if (num_nonzero_elements_in_group==0) return ! no functions to compute in this group

    allocate(indices(num_nonzero_elements_in_group))
    k = 0
    do i = 1, n_cols
        c = cols(i)
        nnz_col = me%col_ptr(c+1) - me%col_ptr(c)
        indices(k+1:k+nnz_col) = me%col_idx(me%col_ptr(c):me%col_ptr(c+1)-1)
        k = k + nnz_col
    end do
    nonzero_rows = me%irow(indices)

    end subroutine columns_in_partition_group