Linked List

Richard E Maine Richard.Maine@nasa.gov
Tue Oct 11 19:20:00 GMT 2005


On Oct 11, 2005, at 11:26 AM, Bill Denney wrote:

> Sorry if this is not the list for this type of question,

No, it really isn't. This list is for issues specific to gfortran, as 
opposed to general programming help. (And the gfortran developers have 
quite enough on their hands as it is). For this type of question, I 
would suggest either the comp.lang.fortran usenet newsgroup or the 
comp-fortran90 mailing list (see 
<http://www.jiscmail.ac.uk/lists/comp-fortran-90.html>). But I'll 
answer your question anyway.

This line in your main program is the problem one

      current => current%next

When this line executes, current%next is always a null pointer, as the 
actual next node hasn't yet been defined. So this line is equivalent to 
nullify(current), which isn't what you want. What you want to do is set 
the next pointer in the *PREVIOUS* node to point to the current one. 
Lots of ways  to do that. One would be to define another pointer, 
perhaps named previous, and then add the line

   previous => current

right before the allocate statement for current. Then, in place of the 
bad line above, do

   if (associated(previous)) previous%next => current

-- 
Richard Maine                |  Good judgment comes from experience;
Richard.Maine@nasa.gov       |  experience comes from bad judgment.
                             |        -- Mark Twain



More information about the Fortran mailing list