This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
character arrays in format tags (bug?)
- From: Brian Barnes <bcbarnes at gmail dot com>
- To: fortran at gcc dot gnu dot org
- Date: Mon, 28 Jan 2008 20:13:07 -0600
- Subject: character arrays in format tags (bug?)
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:mime-version:content-transfer-encoding:message-id:content-type:to:from:subject:date:x-mailer; bh=MwqKcM7pR83thhK4WDSB8DTCPrxDGcFEUbbye+GKu8s=; b=R69ZXi52v+IF4IWJh9WMAUglJaQQ+gxOLcC2DM+muNv836yemVV8CTw3YZ7pwkak2D9ED8/WhUXhImhxqAHMxxFt1Gf1a73wS2pyT7zlOZ0YU7kN73ggX0c8zRliZwnYrIuPfPSL41a6aDkTKfyAxLxMureYfhvrgm3P+VYLokY=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:content-transfer-encoding:message-id:content-type:to:from:subject:date:x-mailer; b=wTTn5g+B9g47WT1VaqUoAtNElThuO4PcBQIW+Mnm9KTxHBN++pBDZf/2gMvBxbWYSIjwUwAF5glGVIRG1InTVM7JKMPnIbIphuDi2U29jgnrFKc1OC4QRSBX0Mn1Hfd9kXF2Xgm74+aXaSXgXXgTJ0ErJmSBBWweWTZMC2vRfjg=
I have a program which uses conditional format tags, similar to this
testcase which is taken from page 187 of Metcalf, Reid and Cohen's
Fortran 95/2003 explained:
---
program testcase
integer :: ival(30),key,i
character(30) :: buffer
character(6) :: form2(3) = (/ '(30i1)', '(15i2)', '(10i3)' /)
read (*, '(a30,i1)') buffer, key
read (buffer, form2 (key)) (ival(i), i=1,30/key)
end
---
When compiled with -std=gnu (gfortran 4.2.2, darwin8), no warning is
issued (which is good). But when compiled with -std=f95 or -
std=f2003, the following error results:
---
nell:~/work/bit barnes$ gfortran -std=f95 testcase.f
testcase.f:7.19:
read (buffer, form2 (key)) (ival(i), i=1,30/key)
1
Error: Extension: Character array in FORMAT tag at (1)
---
Intel Fortran 10 gives no warning or error, at its "-warn all -
stand=f95" level. Is this a gfortran bug or is the Metcalf example bad?
As an aside, if anyone knows how to create a formatting string that
does something like:
write(6,'(NUMI3)') variable(1:NUM)
...where NUM is an integer that is determined at runtime, I would
love to know how to write that code. Right now I am enumerating the
various cases, which kind of sucks. I tried a couple different ways
to work the integer variable into the format expression, with no luck.
thanks,
Brian