recursive non-default derived-type input/output
intel fortran v14.0.1.139 で対応していました。
Metcalf,Reid and Cohen の Modern Fortran Explained §17.2 の Fig.17.3 の例題サブルーチンがコンパイルできたので適当なメインルーチンを書いて実行してみました。
実行結果
ソース・プログラム
module list_module type node integer :: value = 0 type (node), pointer :: next_node => null ( ) contains procedure :: pwf generic :: write(formatted) => pwf end type node contains recursive subroutine pwf (dtv, unit, iotype, vlist, iostat, iomsg) ! Write the chain of values, each on a separate line in I9 format. class(node), intent(in) :: dtv integer, intent(in) :: unit character (len=*), intent(in) :: iotype integer, intent(in) :: vlist(:) integer, intent(out) :: iostat character (len=*), intent(inout) :: iomsg write(unit, '(i9,/)', iostat = iostat) dtv%value if (iostat /= 0) return if (associated(dtv%next_node)) & write (unit, '(dt)', iostat=iostat) dtv%next_node end subroutine pwf end module list_module program test use list_module implicit none type (node), allocatable, target :: root type (node), pointer :: pos integer :: i allocate(root) root%value = 0 pos => root do i = 1, 10 allocate(pos%next_node) pos => pos%next_node pos%value = i end do write(*, *) root end program test