pgfortan vs gfortan

In order to use quasi-dynamic string for namelists I wrote the following code

program main
     implicit none
      integer::inputlen
      character(len=:),ALLOCATABLE::input
      namelist /ttdata/ input,inputlen

      ALLOCATE(character(len=10) :: input)
      input(:)=' '
      print *,'1.input="',input,'"'

      open ( unit=10,STATUS='OLD',file='input.namelist')
      read(10,nml=ttdata)
      print *,'2.input="',input,'"'
      if(inputlen.gt.10) then
        close(10)
        deallocate(input)

        allocate(character(len=inputlen) :: input)
        input(:)=' '
        print *,'3.input="',input,'"'
        open ( unit=10,STATUS='OLD',file='input.namelist')
      endif
      read(10,nml=ttdata)
      print *,'4.input="',input,'"'
     close(10)

end

input.namelist

&ttdata
  inputlen=20,
  input='123456789012345'/

The output (when compiled with pgfortran -o main.x main.f90)

1.input="          "
 2.input="1234567890"
 3.input="                    "
 4.input="1234567890          "

The output when compiled by gfortran -o main.x main.f90

1.input="          "
 2.input="1234567890"
 3.input="                    "
   4.input="123456789012345      "

Is it normal behavior?

Hello,

I have successfully replicated your behavior with the latest 17.9 release.
We have assigned the problem TPR 24817.

dave

Issue has been resolved with 18.10.