PROGRAM SAMPLE IMPLICIT NONE ! define new data type "NODE" TYPE NODE INTEGER :: INFO TYPE (NODE), POINTER :: NEXT END TYPE NODE ! declare variables of type "NODE" TYPE (NODE), POINTER :: LIST, TEMP ! create first node -- allocate space ! and assign values to each section of the node. ALLOCATE(LIST) LIST%INFO = 1 NULLIFY(LIST%NEXT) ! let TEMP point to this node TEMP => LIST ! create second node -- LIST points to ! new node while TEMP points to old node ALLOCATE(LIST) LIST%INFO = 2 LIST%NEXT => TEMP ! since new node is now linked to old ! node, TEMP can be reset to point to ! new node TEMP => LIST ! create third node ALLOCATE(LIST) LIST%INFO=3 LIST%NEXT=>TEMP ! write out contents of nodes ! This starts with the node LIST points to, ! which is the last node created. ! LIST is repeatedly reset to the NEXT node, ! ending with the first node created. DO WRITE(6,*) LIST%INFO IF( .NOT. ASSOCIATED(LIST%NEXT)) EXIT LIST => LIST%NEXT END DO END PROGRAM SAMPLE