This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/20618] New: Variable format expressions not supported
- From: "Thomas dot Koenig at online dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 24 Mar 2005 12:37:53 -0000
- Subject: [Bug fortran/20618] New: Variable format expressions not supported
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
This occurs in a legacy package that I inherited.
A testcase looks like this:
$ cat v-fmt.f
program main
implicit none
integer i,n
real a(10)
a(1) = 1.
a(2) = -1.
n = 2
print 9000,(a(i),i=1,n)
9000 format (<n>F12.5," and that's all.")
end
$ ifort v-fmt.f
$ ./a.out
1.00000 -1.00000 and that's all.
$ gfortran v-fmt.f
In file v-fmt.f:9
9000 format (<n>F12.5," and that's all.")
1
Error: Unexpected element in format string at (1)
In file v-fmt.f:8
print 9000,(a(i),i=1,n)
1
Error: FORMAT label 9000 at (1) not defined
$ gfortran -v
Using built-in specs.
Target: ia64-unknown-linux-gnu
Configured with: ../gcc-4.1-20050320/configure --prefix=/home/zfkts
--enable-languages=c,f95
Thread model: posix
gcc version 4.1.0 20050320 (experimental)
There, the repeat count <n> is substituded by
the value of the expression n. This also works
with expressions like <n-1>, and for other parts
of a format expression.
For new code, this can be done with an internal write
to the format. For legacy code, this can be a bit of
a headache to convert.
g77 also doesn't support this extension, so this is
not a regression wrt g77.
--
Summary: Variable format expressions not supported
Product: gcc
Version: 4.1.0
Status: UNCONFIRMED
Severity: enhancement
Priority: P2
Component: fortran
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: Thomas dot Koenig at online dot de
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20618