Quantcast
Channel: Intel® Fortran Compiler
Viewing all articles
Browse latest Browse all 3270

compile failure for recursive derived type input-output

$
0
0

WARNING: If the code below does not compile immediately, please Ctrl-C fast; otherwise, huge cores are being produced, and you may have to restart your workstation. 

! Code from Figure 19.3 on page 324 of "Fortran 95/2003 explained"

! IFORT 15.0.1 compiles the code, and the program runs fine.

! IFORT 16.0.0 never returns from compilation; Ctrl-C causes
! huge core files to be created

Module list_module
   Implicit None

   Type node
      Integer              :: value = 0
      Class(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)
      Class(node), Intent(In)     :: dtv
      Integer, Intent(In)         :: unit
      Character(*), Intent(In)    :: iotype
      Integer, Intent(In)         :: vlist(:)
      Integer, Intent(Out)        :: iostat
      Character(*), Intent(InOut) :: iomsg

      Character(10)                :: pfmt

      Write(unit, fmt = '(i9,/)', iostat = iostat) dtv%value
      If(iostat /= 0) return
      If(Associated(dtv%next_node)) Write(unit, fmt='(dt)', iostat=iostat) dtv%next_node
   End Subroutine pwf

End Module list_module

Program test
   Use list_module
   Implicit None

   Type(node), Target :: first_link = node(42, Null())
   Type(node), Target :: second_link = node(43, Null())
   Type(node), Target :: third_link = node(44, Null())

   first_link%next_node  => second_link
   second_link%next_node => third_link

   Print '(dt)', first_link

End Program test

 


Viewing all articles
Browse latest Browse all 3270

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>