module link_module type link character :: c type (link), pointer :: next => null() end type link end module link_module program ch2201 use link_module implicit none type (link), pointer :: root, current integer :: io_stat_number = 0 allocate (root) print *, ' type in some text' read (unit=*,fmt='(a)',advance='no',iostat=io_stat_number) root%c if (io_stat_number==-1) then nullify (root%next) else allocate(root%next) end if current => root do while (associated(current%next)) current => current%next read (unit=*,fmt='(a)',advance='no',iostat=io_stat_number) current%c if (io_stat_number==-1) then nullify (current%next) else allocate (current%next) end if end do current => root do while (associated(current%next)) print *, current%c current => current%next end do end program ch2201