Reversing the order of a linked-list FORTRAN (gen_ll.f90) : I've recently adopted the use of linked lists in FORTRAN and after some reading decided to use the [gen_ll.f90 package][1] from the [FORTRAN WIKI][2] which seemed simple and sufficient to my needs.

It was only later that I realized that I must reverse the order of the terms in the list (i.e. 1->2->3->...->N->NULL needs to be N->...->3->2->1->NULL).
I was trying to generate a function which replaces the pointers %P%Next to the previous instead of the next. The logic seemed good, but I keep messing it up somehow.
I would ask for your help with coding this small function.
The source code is attached in the [gen_ll.f90][1] link and the function/subroutine is straight-forward.

Thank you so much!


  [1]: http://fortran.com/gen_ll.f90
  [2]: http://fortranwiki.org/fortran/show/Linked+list