find_crs Subroutine

private subroutine find_crs(self, row, col, index)

Type Bound

type_crs

Arguments

Type IntentOptional Attributes Name
class(type_crs), intent(in) :: self
integer(kind=int32), intent(in) :: row
integer(kind=int32), intent(in) :: col
integer(kind=int32), intent(inout) :: index

Called by

proc~~find_crs~~CalledByGraph proc~find_crs type_crs%find_crs proc~apply_crs_dirichlet_base apply_crs_dirichlet_base proc~apply_crs_dirichlet_base->proc~find_crs proc~apply_crs_thermal_dirichlet apply_crs_thermal_dirichlet proc~apply_crs_thermal_dirichlet->proc~apply_crs_dirichlet_base interface~apply_crs_thermal_dirichlet type_bc_thermal_dirichlet%apply_crs_thermal_dirichlet interface~apply_crs_thermal_dirichlet->proc~apply_crs_thermal_dirichlet

Source Code

    subroutine find_crs(self, row, col, index)
        implicit none
        class(type_crs), intent(in) :: self
        integer(int32), intent(in) :: row, col
        integer(int32), intent(inout) :: index

        integer(int32) :: i
        integer(int32) :: search_start, search_end

        index = 0 ! 見つからなかった場合のデフォルト値

        ! 検索範囲を設定
        search_start = self%ptr(row)
        search_end = self%ptr(row + 1) - 1

        ! 範囲が存在しない場合は終了
        if (search_start > search_end) return

        ! 線形探索 (最初から最後まで順番に探す)
        do i = search_start, search_end
            if (self%ind(i) == col) then
                index = i
                return ! 見つかったら即座に終了
            end if
        end do

    end subroutine find_crs