Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28502 Discussions

same lines in internal file fail but work with external file when reading NAMELIST groups

ur
New Contributor II
551 Views

The same three lines used as input from a file that work do not work when read from an internal

file.  So If the input looks like

 

   &args

      A=T

     \

 

that works from a file, but fails from an internal file. If the lines are very long (example uses 4096 characters to cause failure) it fails from the file as well.  If add a comma after the "T" it works from internal file.

 

 

program main
logical :: a;namelist /args/ a
character(len=256) :: iomsg
integer :: iostat, i
character(len=4096) :: input(3)
input(1)='&args'
input(2)=' A=T'
input(3)=' /'

open(unit=10,status='scratch')
write(10,'(a)')(trim(input(i)),i=1,3)
!write(10,'(a)')(input(i),i=1,3) ! this fails too when lines are long
rewind(10)
read(10,nml=args,iostat=iostat,iomsg=iomsg)

if(iostat.ne.0) write(*,*)'from file iostat=',iostat,trim(iomsg)

read(input,nml=args,iostat=iostat,iomsg=iomsg)
if(iostat.ne.0) write(*,*)'from internal file iostat=',iostat,trim(iomsg)
end program main

3 Replies
Barbara_P_Intel
Moderator
501 Views

Thank you for reporting this. I filed a bug report, CMPLRLLVM-47810. I'll let you know when I know more about a fix.



0 Kudos
DavidWhite
Valued Contributor II
490 Views

The fail on the write statement may be because there is a default record length when you open the unit.  Possibly try adding RECL greater than your string size.

0 Kudos
Barbara_P_Intel
Moderator
123 Views

This problem with NAMELIST is fixed in an early version of the 2024.2 compilers. They are planned for release in mid-2024.

Watch for the announcement!



0 Kudos
Reply