append_stFunArray_ToLinkList Subroutine

private subroutine append_stFunArray_ToLinkList(me, st_fun, new)

This routine appends a new array of space time functions st_fun to the linked list me.

HK: It might be useful to return a pointer to the appended new stfun entry from this routine.

Arguments

Type IntentOptional Attributes Name
type(tem_st_fun_linkedList_type), intent(inout) :: me

Linked list to append the array of spacetime functions to.

type(tem_spacetime_fun_type), intent(in) :: st_fun(:)

Spacetime fun information to add to the list.

type(tem_st_fun_listElem_type), intent(out), optional, pointer :: new

Called by

proc~~append_stfunarray_tolinklist~~CalledByGraph proc~append_stfunarray_tolinklist append_stFunArray_ToLinkList interface~append~21 append interface~append~21->proc~append_stfunarray_tolinklist

Source Code

  subroutine append_stFunArray_ToLinkList(me, st_fun, new)
    ! -------------------------------------------------------------------- !
    !> Linked list to append the array of spacetime functions to.
    type(tem_st_fun_linkedList_type), intent(inout) :: me

    !> Spacetime fun information to add to the list.
    type(tem_spacetime_fun_type), intent(in) :: st_fun(:)

    type(tem_st_fun_listElem_type), optional, pointer, intent(out) :: new
    ! -------------------------------------------------------------------- !
    type(tem_st_fun_listElem_type), pointer :: current
    type(tem_st_fun_listElem_type), pointer :: lnew
    ! -------------------------------------------------------------------- !

    current => NULL()
    allocate(lnew)
    lnew%nVals = size(st_fun)
    allocate(lnew%val(lnew%nVals))
    lnew%val = st_fun

    !look for the last element in the linked list
    if (associated(me%head)) then
      current => me%head
      do while (associated(current%next))
        current => current%next
      enddo

      allocate(current%next)
      current%next => lnew
    else
      ! If current does not point anywhere yet, this has to be the first entry,
      ! allocate that and store it as the head element.
      allocate(me%head)
      me%head => lnew
    endif

    if (present(new)) new => lnew

  end subroutine append_stFunArray_ToLinkList