From: paul.nord@valpo.edu
Date: Fri, 25 Jun 1999 11:56:16 -0500
To: E614Software@relay.phys.ualberta.ca
Subject: Example of LINKED LIST management in F90

SUBROUTINE MOVE_FROM_LIST_TO_LIST (FROM_LIST, TO_LIST, ELEMENT)
! Subroutine for moving a list element from one list to another
! Assumes that ELEMENT is strictly a member of the FROM_LIST
! (The PREV is necessary if you want to remove anything from the
!  middle of the list without searching all the way through the list.
!  An order(N/2) operation.)

! ****** Remove ELEMENT from the origional list

  IF (ELEMENT.eq.FROM_LIST) then
    FROM_LIST=>ELEMENT%next
    IF (ASSOCIATED(FROM_LIST))
      NULLIFY(FROM_LIST%prev)
    ENDIF
  ENDIF

  IF (ASSOCIATED(FROM_LIST%prev)) then 
    FROM_LIST%prev%next =>FROM_LIST%next   !Reassign the dc_ptl pointers
  ENDIF

  IF (ASSOCIATED(FROM_LIST%prev)) then
    FROM_LIST%next%prev =>FROM_LIST%prev   !to skip this hit
  ENDIF

! **** Add the element to the TO_LIST

  IF (ASSOCIATED(TO_LIST)) then      !Test if not first track point
      ELEMENT%next => TO_LIST        !Assign pointers for track list
      TO_LIST%prev => ELEMENT
    ELSE
      NULLIFY(ELEMENT%next)
    END IF
    NULLIFY(ELEMENT%prev)
    TO_LIST => ELEMENT

Example of LINKED LIST management in F90 / paul.nord@valpo.edu

Created for the The Center for Subatomic Research E614 Project Projects Page.
Created by The CoCoBoard.