- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I use F11 to debug this code. When Line 7 executed, it backs up to the If and then executes again, then down to the next line to Print.
Why it not moves down at the first time? In my real code, it gives me wrong result. If remove the IF, it only executes once which is right.
Thanks for help.
Cheers,
Cean
integer i
integer :: isL=1
character(80) :: astr(20),cstr
cstr='tetxt'
do i=1,3
if (isL==1) then
astr(I)=cstr
print *, '>0'
endif
end do
end
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am not sure you can read too much into the slightly erratic movements of the cursor in debug. I have noted with IFX that the correspondence of the cursor is not so prescice as ifort was and does things like this on branches on quite a few occasions. Not sure this is linked to your other problems. I bet the var only changes on the second touch in the watch window.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
and you built with Debug configuration without any non-default options? O0?
At optimization I can see where there could be a lot of code changes that essentially replace this whole loop with 2 versions of a fully unrolled version. if (isl=1) is loop invariant. this IF could be fully removed by creating 2 versions of the loop, one when isl=1 and one when it is not. At runtime a branch could be made to one version or the other based on the value of isl at runtime - and NO the compiler does not know that you initalized it to 1 in the declaration. That eliminates the IF test. Next, the loop 1 to 3 could be fully unrolled to completely eliminate the loops inside these 2 versions. I haven't looked at the Qopt-report for this example at default optimization but I suspect it could do a lot of transforms on this simple example.
What exactly do you mean "gives me the wrong results"? what compiler and version, what compiler options, and what is a "wrong" result?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have just created an empty project and wrote this simple code. Yes debug. No other change.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page