Hi all,
Encountered a little puzzle. Using default project settings for a console application, the following code creates a format specification statement with an internal write and then uses that format specifier in another write statement:
program WidthSpecifierError
character(LEN=200) :: cLine
integer(KIND=4) :: iLen, iArray(11)
iLen = 11
iArray(1:11) = (/1,2,3,4,5,6,7,8,9,10,11/)
write(*,*) 'Writing integer larger than width specifier'
write(cLine,'("(",I1,"(I2,1X))")') iLen
write(*,*) cline
write(*,cline) (iArray(i), i=1,iLen)
write(*,*)
write(*,*) 'Writing integer equal to width specifier'
write(cLine,'("(",I2,"(I2,1X))")') iLen
write(*,*) cline
write(*,cline) (iArray(i), i=1,iLen)
end program WidthSpecifierError
The output is thus under default Debug and Release compilation:
Writing integer larger than width specifier
(*(I2,1X))
1 2 3 4 5 6 7 8 9 10 11
Writing integer equal to width specifier
(11(I2,1X))
1 2 3 4 5 6 7 8 9 10 11
Press any key to continue . . .
The output is correct and consistent in both cases, but the format specifier "appears" to be mangled. Code similar to this compiled with PGI generated a runtime error. Is there a compiler flag for Intel that would catch this at runtime?
Ted
Intel(R) Visual Fortran Intel(R) 64 Compiler XE for applications running on Intel(R) 64, Version 12.0.5.221 Build 20110719
Copyright (C) 1985-2011 Intel Corporation. All rights reserved.