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

Format syntax error

$
0
0

In my application I obtain a format syntax error, but I  do not recognize why.

I created a minimal example:

program test
  implicit none
  character(len=200) :: formatstr
  character(len=*), parameter :: formatstr2 = '("test",I2.2,"")'

  formatstr = formatstr2
  write(*,'(A)') formatstr
  write(*,'(A)') formatstr2
  write(*,*) formatstr == formatstr2
  write(*,formatstr2) 12
  ! the next line creates an error
  write(*,formatstr) 12

end program test

I obtain the following output:

> ifort -g -traceback test2.f90> ./a.out
("test",I2.2,"")
("test",I2.2,"")
 T
test12
forrtl: info (58): format syntax error at or near ")
forrtl: severe (62): syntax error in format, unit -1, file /dev/pts/4
Image              PC                Routine            Line        Source
a.out              00000000004286C6  Unknown               Unknown  Unknown
a.out              0000000000409C05  Unknown               Unknown  Unknown
a.out              000000000040314E  MAIN__                     12  test2.f90
a.out              0000000000402E6E  Unknown               Unknown  Unknown
libc.so.6          00007FAC1836CBE5  Unknown               Unknown  Unknown
a.out              0000000000402D79  Unknown               Unknown  Unknown

I tested this with the Intel Fortran Compiler 15.0.1 on a 64bit Linux and with some older version.
The code seems to work fine with both the GNU Fortran compiler (gfortran) and the PGI Fortran compiler (pgf90).

It also works when I change the format string to ("test",I2.2) or ("test",I2.2,"test"),
but in my application the formatstring is generated and thus one may obtain an empty string there.


Viewing all articles
Browse latest Browse all 3270

Trending Articles



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