module link_module type link real :: n type (link), pointer :: next end type link end module link_module program ch2202_2 use link_module use f90_iostat type (link), pointer :: root, current integer :: i = 0 integer :: io_stat_number = 0 allocate (root) print *, ' Type in some numbers' read (unit=*,fmt=*,iostat=io_stat_number) root%n if (io_stat_number==ioerr_eof) then nullify (root%next) else if (io_stat_number==ioerr_ok) then i = i + 1 allocate (root%next) end if current => root do while (associated(current%next)) current => current%next read (unit=*,fmt=*,iostat=io_stat_number) current%n if (io_stat_number==ioerr_eof) then nullify (current%next) else if (io_stat_number==ioerr_ok) then i = i + 1 allocate (current%next) end if end do print *, i, ' items read' current => root do while (associated(current%next)) print *, current%n current => current%next end do end program ch2202_2