- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- 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
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Perhaps reinstalling VS 2008 will cure it - how may I do that?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page