Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29353 Discussions

PRINT statement generates a breakpoint (?)

WSinc
New Contributor I
852 Views

Why doesn't my message get posted?

This is the FOURTH try.

Anyway, the error message says: "Internal consistency check."

Then removing the COMMON block cures the problem.

Changing the PRINT statement to PRINT * changes the behavior, it

runs farther, but still crashes.

-------------------------------------------------------------------------------

program get_primes

implicit NONE

parameter maxprime=500001

common/primes01/nprime,pr

integer(4) pr(50000),nprime

integer(4) ipr,jpr,p,pmod

nprime=1;pr(1)=2 ! first prime

do 10 ipr=3,maxprime,2 ! odd candidates

! test all prime factors <= sqrt(ipr)

! print *,"candidate:",ipr

do jpr=1,nprime-1

p=pr(jpr)

if(p*p.gt.ipr)exit

pmod=mod(ipr,p)

if(pmod.eq.0)go to 10

end do

! HERE IF PRIME FOUND

nprime=nprime+1

pr(nprime)=ipr

! this print statement generates a breakpoint

print 101,nprime,ipr

101 format("pr:",2I10)

if(nprime.ge.50000)go to 99

10 end do

99 print *,"nprime=",nprime

pause "primes are done"

end program

0 Kudos
5 Replies
mecej4
Honored Contributor III
852 Views
I saw no errors after compiling and running this program* with several compilers. The last three lines of output:

pr: 41538 499979
nprime= 41538
primes are done


Which Fortran compiler and version did you use, and what is the platform and version?

----------------------------
* Edit, added later:

after inserting the declaration

INTEGER MAXPRIME
0 Kudos
TimP
Honored Contributor III
852 Views
Might the question be why maxprime doesn't raise an error indication?
0 Kudos
WSinc
New Contributor I
852 Views
MAXPRIME is just a parameter.

The PRINT statement is the puzzler.

I am using the laterst Fortran 12.0 XE, with a Windows XP, SP3.

Perhaps my VS 2008 got corrupted - IS there an integrity check, i.e.
maybe download and reinstall it?

OR maybe I should reinstall the compiler?

Can you think of a reason why NOT putting the arrays in a COMMON block would make the
problem go away? When mine crashes the numbers aren't anywhere big enough to cause
an integer overflow or a subscript check. NPRIME is only 56.

does Steve have any ideas I could try?
0 Kudos
WSinc
New Contributor I
852 Views
BTW, I am still getting the disappearing source files, so maybe that's also related to this.
Perhaps reinstalling VS 2008 will cure it - how may I do that?
0 Kudos
Steven_L_Intel1
Employee
852 Views
Uninstall Fortran and then Visual Studio from the control panel. Delete the Program Files\Visual Studio 9.0 folder. Reboot. Reinstall. (The middle two steps are just me being cautious.)
0 Kudos
Reply