sparsity_pattern Derived Type

type, public :: sparsity_pattern

A sparsity pattern


Inherited by

type~~sparsity_pattern~~InheritedByGraph type~sparsity_pattern sparsity_pattern type~numdiff_type numdiff_type type~numdiff_type->type~sparsity_pattern sparsity

Components

Type Visibility Attributes Name Initial
logical, private :: sparsity_computed = .false.

has the sparsity pattern already been computed?

integer, private :: num_nonzero_elements = 0

number of nonzero elements in the jacobian (will be the dimension of irow and icol)

integer, private, dimension(:), allocatable :: irow

sparsity pattern - rows of non-zero elements

integer, private, dimension(:), allocatable :: icol

sparsity pattern - columns of non-zero elements

logical, private :: linear_sparsity_computed = .false.

if the linear pattern has been populated

integer, private :: num_nonzero_linear_elements = 0

number of constant elements in the jacobian

integer, private, dimension(:), allocatable :: linear_irow

linear sparsity pattern - rows of non-zero elements

integer, private, dimension(:), allocatable :: linear_icol

linear sparsity pattern - columns of non-zero elements

real(kind=wp), private, dimension(:), allocatable :: linear_vals

linear elements of the jacobian

integer, private, dimension(:), allocatable :: indices

index vector [1,2,...,num_nonzero_elements] for putting df into jac

integer, private :: maxgrp = 0

the number of groups in the partition of the columns of a.

integer, private, dimension(:), allocatable :: ngrp

specifies the partition of the columns of a. column jcol belongs to group ngrp(jcol). size(n)


Type-Bound Procedures

procedure, private :: dsm_wrapper

  • private subroutine dsm_wrapper(me, n, m, info)

    Wrapper for dsm to compute the sparsity pattern partition.

    Arguments

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

    number of columns of jacobian matrix

    integer, intent(in) :: m

    number of rows of jacobian matrix

    integer, intent(out) :: info

    status output from dsm

procedure, private :: compute_indices

  • private subroutine compute_indices(me)

    Computes the indices vector in the class.

    Arguments

    Type IntentOptional Attributes Name
    class(sparsity_pattern), intent(inout) :: me

procedure, public :: destroy => destroy_sparsity

procedure, public :: print => print_sparsity

  • private subroutine print_sparsity(me, n, m, iunit, dense)

    Print the sparsity pattern.

    Arguments

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

    number of variables (columns of jacobian)

    integer, intent(in) :: m

    number of functions (rows of jacobian)

    integer, intent(in) :: iunit

    file unit to write to. (assumed to be already opened)

    logical, intent(in), optional :: dense

    if present and true, the matrix form of the sparsity pattern is printed (default is vector form)

procedure, public :: columns_in_partition_group

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

    Returns the columns in a sparsity partition group.

    Read more…

    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

Source Code

    type,public :: sparsity_pattern

        !! A sparsity pattern

        private

        logical :: sparsity_computed = .false. !! has the sparsity pattern already been computed?
        integer :: num_nonzero_elements = 0 !! number of nonzero elements in the jacobian
                                            !! (will be the dimension of `irow` and `icol`)
        integer,dimension(:),allocatable :: irow  !! sparsity pattern - rows of non-zero elements
        integer,dimension(:),allocatable :: icol  !! sparsity pattern - columns of non-zero elements

        logical :: linear_sparsity_computed = .false. !! if the linear pattern has been populated
        integer :: num_nonzero_linear_elements = 0 !! number of constant elements in the jacobian
        integer,dimension(:),allocatable  :: linear_irow  !! linear sparsity pattern - rows of non-zero elements
        integer,dimension(:),allocatable  :: linear_icol  !! linear sparsity pattern - columns of non-zero elements
        real(wp),dimension(:),allocatable :: linear_vals  !! linear elements of the jacobian

        integer,dimension(:),allocatable :: indices  !! index vector
                                                     !! `[1,2,...,num_nonzero_elements]`
                                                     !! for putting `df` into `jac`

        integer :: maxgrp = 0 !! the number of groups in the partition
                              !! of the columns of `a`.
        integer,dimension(:),allocatable :: ngrp !! specifies the partition of the columns of `a`.
                                                 !! column `jcol` belongs to group `ngrp(jcol)`.
                                                 !! `size(n)`

        contains
        private
        procedure :: dsm_wrapper
        procedure :: compute_indices
        procedure,public :: destroy => destroy_sparsity
        procedure,public :: print => print_sparsity
        procedure,public :: columns_in_partition_group
    end type sparsity_pattern