gfortran: Why does this fail to compile?
Arjen Markus
arjen.markus895@gmail.com
Tue Jan 22 14:37:00 GMT 2013
Hi,
a slight refinement on my remark: we may read "X1", but the compiler
probably interprets this as X, followed by the next format group that
begins with
a 1 - commas are not required. Hence it has a very good reason to report
the closing parenthesis as the erroneous part. It simply is not the way a
human being would parse the format.
Regards,
Arjen
2013/1/22 Arjen Markus <arjen.markus895@gmail.com>:
> Hi Mark,
>
> there is a small flaw in the X1 part of your format: it should be 1X.
>
> gfortran is reporting the wrong part, which is rather confusing.
>
> Regards,
>
> Arjen
>
> 2013/1/22 Mark Hounschell <markh@compro.net>:
>> Can someone tell me why this fails to compile in gfortran? I've used this
>> type of format specification in many different fortran compilers.
>>
>> gfortran -v
>> Using built-in specs.
>> COLLECT_GCC=gfortran
>> COLLECT_LTO_WRAPPER=/usr/lib/gcc/i586-suse-linux/4.7/lto-wrapper
>> Target: i586-suse-linux
>> Configured with: ../configure --prefix=/usr --infodir=/usr/share/info
>> --mandir=/usr/share/man --libdir=/usr/lib --libexecdir=/usr/lib
>> --enable-languages=c,c++,objc,fortran,obj-c++,java,ada
>> --enable-checking=release --with-gxx-include-dir=/usr/include/c++/4.7
>> --enable-ssp --disable-libssp --disable-libitm --disable-plugin
>> --with-bugurl=http://bugs.opensuse.org/ --with-pkgversion='SUSE Linux'
>> --disable-libgcj --disable-libmudflap --with-slibdir=/lib --with-system-zlib
>> --enable-__cxa_atexit --enable-libstdcxx-allocator=new
>> --disable-libstdcxx-pch --enable-version-specific-runtime-libs
>> --enable-linker-build-id --program-suffix=-4.7 --enable-linux-futex
>> --without-system-libunwind --with-arch-32=i586 --with-tune=generic
>> --build=i586-suse-linux
>> Thread model: posix
>> gcc version 4.7.1 20120723 [gcc-4_7-branch revision 189773] (SUSE Linux)
>>
>>
>>
>> program test_c3
>> IMPLICIT NONE
>> c
>> c The first read below, reads a line of ascii text
>> c containing 20 space separated, 4 char, hex fields
>> c into a buffer.
>> c The format of the file is
>> c 1 2 3 4 17 18 19 20
>> c 0002 0002 3130 0052 .... .... ff4b 0000 1024 b070
>> c
>> c The second read is to read the text fields into
>> c an array of integer*2s but the "valid" format
>> c specifier in that read is invalid to gfortran
>> c for some reason. Why????
>> c
>>
>> INTEGER*4 WYPTUNIT/100/
>> INTEGER*2 WYPTBUFF(20)
>> CHARACTER*100 READBUFF
>>
>> OPEN(UNIT = WYPTUNIT, FILE = 'waypthex.txt')
>> READ(WYPTUNIT, '(A100)') READBUFF
>> READ(READBUFF, '(19(Z4,X1),Z4)') WYPTBUFF
>>
>> STOP
>> END
>>
>> #gfortran test_c3.f
>> test_c3.f:23.37:
>>
>> READ(READBUFF, '(19(Z4,X1),Z4)') WYPTBUFF
>> 1
>> Error: Unexpected element ')' in format string at (1)
>>
>> Thanks in advance
>> Mark
More information about the Fortran
mailing list