add_lens Subroutine

public subroutine add_lens(me, l)

Type Bound

box

Arguments

Type IntentOptional Attributes Name
class(box), intent(inout) :: me
type(lens), intent(in) :: l

lense to add


Called by

proc~~add_lens~~CalledByGraph proc~add_lens problem_15_module::box%add_lens program~problem_15 problem_15 program~problem_15->proc~add_lens

Source Code

    subroutine add_lens(me,l) ! =
        class(box),intent(inout) :: me
        type(lens),intent(in) :: l !! lense to add
        integer :: i !! counter
        if (allocated(me%lenses)) then
            do i = 1, size(me%lenses)
                if (me%lenses(i)%label == l%label) then
                    me%lenses(i) = l  ! replace with this one
                    return
                end if
            end do
            me%lenses = [me%lenses, l]  ! if not found, add to end
        else
            me%lenses = [l]  ! first one in the box
        end if
    end subroutine add_lens