Skip to content

[flang] NML: multiple name-value subsequences stopped reading the next item. #151756

@DanielCChen

Description

@DanielCChen

Consider the following code:

module m
   type base
      integer(4)   :: i(3) = (/ 9, 9, 9 /)
   end type

   type, extends(base) :: child
      real(4)      :: r(3) = (/ 9.0, 9.0, 9.0 /)
   end type

   type, extends(child) :: gen3
      character(3) :: c(3) = (/ 'xxx', 'xxx', 'xxx' /)
   end type
end module

program input104a
   use m

   integer :: stat
   character(150) :: msg = 'original'
   procedure(logical) :: precision_r4
   type(child)               :: b1
   type(child), pointer      :: b2
   type(gen3)                :: b3
   type(gen3), allocatable   :: b4

   namelist /n1/ b1, b2, b3, b4

   allocate(b2,b4)

   open (1, file='input104a.1', form='formatted', access='sequential', blank='zero' )

   read (1, n1, iostat = stat, iomsg = msg)
   if ( ( stat /= 0 ) .or. ( msg /= 'original' ) ) ERROR STOP 1

   print *, b1
   print *, b2
   print *, b3
   print *, b4

end program

The input file input104a.1 is

 &n1
 b1= 2, 4, 6, 8.0, 10.0,
 b1%i=    ,
 b2=1,12,1*,
 b2= ,
 b3%c= 'abc', b3= 3,6,9,12.0,15.0,18.0,
 b4= , , , 4.0, 8.0, 12.0, ,
 /

It seems line b1%i= , and b2=, stopped Flang from reading the next name-list-group-object.

Flang outputs:

> a.out
 2 4 6 8. 10. 9.
 9 9 9 9. 9. 9.
 9 9 9 9. 9. 9. xxxxxxxxx
 9 9 9 9. 9. 9. xxxxxxxxx

Expected output is (after I removed those mentioned two lines from the input file.)

> a.out
 2 4 6 8. 10. 9.
 1 12 9 9. 9. 9.
 3 6 9 12. 15. 18. abcxxxxxx
 9 9 9 4. 8. 12. xxxxxxxxx

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions