- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In the following example code, the behaviour changes if the value of the parameter clen is more than 7196
[fortran]program test
integer, parameter :: clen = 7197
TYPE T_BLOCK
character(len=clen) :: ch
end type T_BLOCK
type(T_BLOCK) :: b2
type(T_BLOCK) :: b1 = T_BLOCK( '' )
b2 = T_BLOCK( '' )
print *, "clen :", clen
print *, "len_trim b1%ch:", len_trim(b1%ch)
print *, "len_trim b2%ch:", len_trim(b2%ch)
if (b1%ch /= '') then
print *, "b1 ch is not empty"
else
print *, "b1 ch is empty"
endif
if (b2%ch /= '') then
print *, "b2 ch is not empty"
else
print *, "b2 ch is empty"
endif
end program[/fortran]
with the value of 7196 i get the following:
[plain] clen : 7196 len_trim b1%ch: 0 len_trim b2%ch: 0 b1 ch is empty b2 ch is empty [/plain]
with the value of 7197 i get this:
[plain]clen : 7197 len_trim b1%ch: 7197 len_trim b2%ch: 0 b1 ch is not empty b2 ch is empty[/plain]
I compile without any options:
C:\\TEMP>ifort test.f90
Intel Visual Fortran Compiler XE for applications running on IA-32, Version 12.1.1.258 Build 20111011
Copyright (C) 1985-2011 Intel Corporation. All rights reserved.
Microsoft Incremental Linker Version 10.00.40219.01
Copyright (C) Microsoft Corporation. All rights reserved.
-out:test.exe
-subsystem:console
test.obj
In the compiler documentation I read about a limit for character and Hollerith constants of 7198. However, in the above example, if I set clen to 50000 the behaviour is still the same as for 7197 (b1 not empty, b2 empty).
I can not understand if this is a compiler limit, compiler bug or a missunderstanding on my behalf.
I'd be grateful for any explanation
Johny
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This happened in a piece of code that is generated where several character components of a derived type have a length of > 32000 characters. We have recently acquired licenses for Intel Fortran and I am porting our code, which worked nicely except for this small trouble.
I can work around the bug by changing the tests generated to something like if ( .not. b1%ch > '')
It only happens with derived types, simple character variables work correctly:
[fortran]program test
integer, parameter :: clen = 50000
character(len=clen) :: ch1 = ''
character(len=clen) :: ch2
ch2 = ''
print *, "clen :", clen
print *, "ch1:", len_trim(ch1)
print *, "ch2:", len_trim(ch2)
if (ch1 /= '') then
print *, "ch1 is not empty"
else
print *, "ch1 is empty"
endif
if (ch2 /= '') then
print *, "ch2 is not empty"
else
print *, "ch2 is empty"
endif
end program[/fortran]and the result:
[plain] clen : 50000 ch1: 0 ch2: 0 ch1 ch is empty ch2 ch is empty[/plain]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
We've found and fixed the bug here - it was indeed restricted to structure constructors when the character component was longer than 7196. I expect the fix to appear in the first update to the 15.0 compiler.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page