- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi folks:
Am converting old FORTRAN code to IFORT.
Here is the code the has run for 20 years using another compiler:
DO 41 THISPG=1,PGROUPS
IF (NJGROUP(THISPG).GT.0) THEN
PZERO = PSTART(THISPG)
DO 392 THISI = 1, NI
392 IF (PGROUP(THISI).EQ.THISPG) EXIT
DO 42 K= 0, NJGROUP(THISPG)
.....
42 CONTINUE
ENDIF
41 CONTINUE
Look line 392 - what happens at the EXIT ?
With the other compiler, "DO 42 ...." is executed.
With IFORT 2021.9, "DO 41 ..." is executed
Is IFORT correct, or is this a bug in IFORT?
Thx.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I think Intel Fortran is wrong. The line containing the EXIT statement is part of the loop defined by label 392. So that is the loop to be exited. Would splitting up the line work? I mean:
if ( pgroup(thisi) .eq. thispg ) exit
392 continue
That is clearly aworkaround for the misinterpretation of the compiler is correct, but it would be a minimal change and could be an indication of what is going wrong.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am reluctant to comment on what any named compiler does without seeing a complete reproducible example code, rather than bits and pieces that cannot be compiled and run.
I have listed below one result of my attempt to construct such an example code based on the description given above. This code runs correctly with all the compilers that I tried, reinforcing my claim that you should show actual code that when run with IFort/IFX reproduces the incorrect behavior that you described.
program ifortq
implicit none
! MikeWinsteps 06/02/2023 in Intel Fortran forum
integer, parameter :: ngrp = 4, ni = 4
integer k, igrp, thisi, njg(ngrp), pzero, pstart(ngrp),pgroup(ngrp)
pstart = [1,2,3,4]
pgroup = [4,3,2,1]
njg = [10,11,12,13]
do igrp = 1, ngrp
if (njg(igrp) > 0) then
pzero = pstart(igrp)
do thisi = 1, ni
if (pgroup(thisi) == igrp)exit
do k = 0, njg(igrp)
print '(1x,3i4)',k,2*k-1,pzero
end do
end do
endif
end do
end program
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ask not what the compiler should do ask what the compiler it was developed in did and what the developer intended to happen! Logically one would say that the EXIT relates to the 392 loop but if that is the case the loop has no meaning because it does nothing. But maybe you missed out other stuff from that loop..... There are a host of deprecated things going on here. Labelled do loops, do loops that have and end statement that is not enddo or a numbered continue statement. EXIT is F90 thing that has been added to something that does not look like it was coded in F77 days...... Just make the code do what it is meant to and move on.
Do you have optimisation on? That might confuse the compiler if it optimises out a do nothing loop......
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
One effect of the do-loop with label 392 is that the index variable THISI is set to some value. The code does not show if it is used later, but I can see that as the purpose of the otherwise suspiciously empty loop.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks everyone. Yes - the purpose of the 392 loop is to find a suitable value of THISI to use in DO 42 loop. And yes, it is F77-style code. And yes, I have rewritten the 392 loop to avoid this problem. Thanks again.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page