put_in_cache Subroutine

private subroutine put_in_cache(me, i, x, f)

Put a value into the cache.

Type Bound

function_cache

Arguments

Type IntentOptional Attributes Name
class(function_cache), intent(inout) :: me
integer(kind=ip), intent(in) :: i

index in the hash table

integer(kind=ip), intent(in), dimension(:) :: x

independant variable vector

integer(kind=ip), intent(in), dimension(:) :: f

function


Called by

proc~~put_in_cache~2~~CalledByGraph proc~put_in_cache~2 aoc_cache_module::function_cache%put_in_cache proc~get_all_pieces_above problem_22::get_all_pieces_above proc~get_all_pieces_above->proc~put_in_cache~2 proc~get_all_pieces_above->proc~get_all_pieces_above proc~get_all_pieces_below problem_22::get_all_pieces_below proc~get_all_pieces_below->proc~put_in_cache~2 proc~get_all_pieces_below->proc~get_all_pieces_below proc~go~4 problem_12b::go proc~go~4->proc~put_in_cache~2 proc~ipoint problem_12b::ipoint proc~go~4->proc~ipoint proc~ipound problem_12b::ipound proc~go~4->proc~ipound proc~index_in_queue~2 problem_17::index_in_queue proc~index_in_queue~2->proc~put_in_cache~2 proc~check~2 problem_17::check proc~check~2->proc~index_in_queue~2 proc~ipoint->proc~go~4 proc~ipound->proc~go~4 program~problem_12b problem_12b program~problem_12b->proc~go~4 program~problem_22 problem_22 program~problem_22->proc~get_all_pieces_above program~problem_22->proc~get_all_pieces_below program~problem_17~2 problem_17 program~problem_17~2->proc~check~2

Source Code

    subroutine put_in_cache(me,i,x,f)

    implicit none

    class(function_cache),intent(inout) :: me
    integer(ip),intent(in)              :: i    !! index in the hash table
    integer(ip),dimension(:),intent(in) :: x    !! independant variable vector
    integer(ip),dimension(:),intent(in) :: f    !! function

    integer(ip),parameter :: null = huge(1) !! an unusual value to initialize arrays

    if (allocated(me%c)) then
        if (i<=size(me%c)) then
            ! add to the cache
            me%c(i)%x = x
            me%c(i)%f = f
        else
            error stop 'Error: invalid index in hash table.'
        end if
    else
        error stop 'Error: the cache has not been initialized.'
    end if

    end subroutine put_in_cache