This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: character arrays in format tags (bug?)
- From: Brian Barnes <bcbarnes at gmail dot com>
- To: Tobias Schlüter <tobias dot schlueter at physik dot uni-muenchen dot de>
- Cc: fortran at gcc dot gnu dot org
- Date: Mon, 28 Jan 2008 22:02:49 -0600
- Subject: Re: 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:in-reply-to:references:mime-version:content-type:message-id:cc:content-transfer-encoding:from:subject:date:to:x-mailer; bh=xr5yr26+gKI16qUoVqaCAgVddncoMKHm8eRsxQ52ckU=; b=hUUxwnNYG1KP84qq3P7SIbOzY6O/g1+4cv6G934oYK/NQE53egIeb8s3wowh/SGogSqWwfNSBafCvf7LJCuZuEHvXemYvLotdn6+MbZlin+Jnb95+IKwX8u2/85hzKDlBAlsFSmygLSsEqkPd6k8tHB7wVeqa00LmWtL70a3s1s=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=in-reply-to:references:mime-version:content-type:message-id:cc:content-transfer-encoding:from:subject:date:to:x-mailer; b=DK6pswnf+IOKqJfek4vUr1mY+8p2j2f/+33Fek9RfAVnGrY5KVLrzr5gGuiDPFJvDt+6WFBO2a+NkPDX0JpuSC/Jh9sxJZ5lnJlg8ebBqWVZf59V9U+p+7nJdZ2xmIQ/VzfREdJQNTtGcE7fRyPs9xAtE091+k4mA8PGKu4g4qU=
- References: <5EB82E8D-F879-4263-A7BB-8188FA6B1826@gmail.com> <479E8E4C.4070909@physik.uni-muenchen.de>
On Jan 28, 2008, at 8:24 PM, Tobias Schlüter wrote:
This is a bug, can you please file a bug report in http://
gcc.gnu.org/bugzilla so that it doesn't get lost?
Yes; filed @ http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35009 -- my
second bug today! And second bug... ever. heh.
You have two options: use a large enough number in the format
string, or, if such a number doesn't exist, use an internal write
to create the format string and then use that format string, say
charater*4 :: f
write(f, "(i2,'i3')") num
write(6, f) variable(1:num)
I think the internal write scheme may work (my actual output is more
complicated). I have a short example working similar to yours, which
had problems with parentheses on my system:
program testcase
character(6) :: f
integer num,var(3)
num=2
var(1)=1
var(2)=2
var(3)=3
write(f,"(A,i0,'i3',A)") '(',num,')' ! ugly but works
write(6,*) f
write(6,f) var(1:num)
end
outputs:
nell:~/work/bit barnes$ gfortran -Wall -o t.x testcase.f ; ./t.x
(2i3)
1 2
I had never (intentionally, knowingly) made use of internal writes
before. Thanks for the tip!
-Brian