tem_appendIntList Subroutine

private subroutine tem_appendIntList(firstEntry, entryPos)

append an entry at the end of the integer list If the first entry is zero, write into that one

Arguments

Type IntentOptional Attributes Name
type(tem_intList), pointer :: firstEntry

linked list of resulting elements building the neighbor

integer(kind=int_k), intent(in) :: entryPos

Add that element


Source Code

  subroutine tem_appendIntList(firstEntry, entryPos)
    ! ---------------------------------------------------------------------------
    !> linked list of resulting elements building the neighbor
    type(tem_intList),pointer :: firstEntry
    !> Add that element
    integer(kind=int_k),intent(in) :: entryPos
    ! ---------------------------------------------------------------------------
    type(tem_intList),pointer :: currPos    ! current position in linked list
    ! ---------------------------------------------------------------------------

    currPos => firstEntry

    if(currPos%elem .le. 0) then
       ! If the element entry of the current entry is zero
       ! write into that position
       currPos%elem = entryPos
    else
      ! If element entry /= 0 then find the end of the list
      do while(associated(currPos%next))
        currPos => currPos%next
      enddo
      ! at the end of the list, append new list item
      allocate(currPos%next)
      currPos => currPos%next
      ! And write to the item
      currPos%elem = entryPos
    endif

  end subroutine tem_appendIntList