implicit noneThis statement enforces type checking. Otherwise implicit types are assumed, i.e., undefined variables whose names begin with i, j, k, l, m, and n are assumed integers, whereas all the other undefined variables are assumed real. We don't want that, because it can easily lead to programming errors.
node. A data of type
nodewill be a node in a linked list. In this case our derived type
nodehas 4 components, of which 3 are reals and one is a pointer that will point to the next occurrence, somewhere in the memory of the computer system, of a data of this type - thus forming a list of elements linked with pointers.
nodeis recursive - this is always the case with linked lists and trees.
type(node), pointer :: list, firstWe must always keep the address of the first element of a linked list stored safely somewhere, because if we lose that, the whole data set will become dereferenced, i.e., lost.
'old': this means that the file must already exist - it is possible to open a new file for reading, although it is hard to tell what one can read from such a file) we allocate the first object of type
nodeand set its pointer component to point nowhere with the
firstpoint to the same object:
first => list; count = 0Observe the new symbol
=>, which means that
firsthas been assigned an address of object that is now referenced by
list. Once we have allocated
listis no longer a pointer. It is now an object, which may become a target for another pointer, in this case,
first = listInstead you have to do:
first => listThe meaning of this operation is
a pointer points to ( ) an object
list%x, list%y, list%sigmathe three floating point number slots of the object that is currently referred to by the name
end=100condition fires up and the program jumps to label 100. There is no other portable way to process end of file condition in Fortran.
list%nextso that we can locate it by marching along the list. At the same time we redirect the
listpointer itself so that now it points to
list%next, and within this newly created object we nullify the pointer slot. We need to do that, so that when the list ends we have some means of ascertaining that.
allocate(x(count)); allocate(y(count)); allocate(sigma(count));
listto point back at the first object, and march along the list. This time hitting a pointer that is no associated with any object terminates the march. That's why we've been always careful to nullify the pointer in a newly allocated object.