Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Fortran > Re: Simple Prog...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 27 of 34 Topic 8551 of 8908
Post > Topic >>

Re: Simple Program, Lots of Issues (F90)

by AnotherSquid <mai@[EMAIL PROTECTED] > Jul 29, 2008 at 07:26 AM

On Jul 25, 7:57 am, e p chandler <e...@[EMAIL PROTECTED]
> wrote:

> seeftp://ftp.swcp.com/pub/walt/F/Examples/sieve.f95


I tried this simple program using six Fortran compilers but setting
the integer parameter last_number to 10000000 (10 million). All
compiled but four of the six had problems during exection.


  Sun f90:
    signal SEGV (no mapping at the fault address) in MAIN at line 24
in file "primes2.f90"
       24     nums=(/0,(ic,ic=2,mxn)/)


  gfortran:
    Segmentation fault
    Program received signal SIGSEGV, Segmentation fault.
    0x08048875 in MAIN__ () at primes2.f90:29
    29            nums(2*i:mxn:i)=0


  PGI pgf95:
    Segmentation fault
    Program received signal SIGSEGV, Segmentation fault.
    0x08049939 in sieve_of_eratosthenes () at primes2.f90:24
    24        nums=(/0,(ic,ic=2,mxn)/)


  Intel ifort:
    Segmentation fault
    Program received signal SIGSEGV, Segmentation fault.
    0x0000000000402909 in sieve_of_eratosthenes () at primes2.f90:1
    1       program Sieve_Of_Eratosthenes


  Lahey lf95:
    (worked correctly)


  IBM xlf90:
    (worked correctly)


After re-writing the code to introduce DO-loops everywhere, all six
compilers worked correctly and got the same printed output.

My conclusion: DO-loops still work better than array syntax.

Andy



For those who might care, here is my cleaned up version of the
program:

program Sieve_Of_Eratosthenes
implicit none

  integer, parameter :: mxn=10000000

  integer, dimension(mxn) :: nums
  integer :: i,ic,npr

! ..Initialize NUMBERS to 0,2,3,...,MXN (1 is a special case)
  nums(1)=0
  do ic=2,mxn
    nums(ic)=ic
  enddo

! ..The sieve of Eratosthenes: if this number is prime, eliminate all
multiples
  do i=2,mxn
    if (nums(i) /= 0) then
      do ic=2*i,mxn,i
        nums(ic)=0
      enddo
    endif
  enddo

! ..Gather them into the front of the array
  npr=0
  do i=1,mxn
    if (nums(i) /= 0) then
      npr=npr+1
      nums(npr)=nums(i)
    endif
  enddo

! ..Print them out
  print'(a,i0,a,i0)',' There are ', npr,' prime numbers less than ',
mxn
  print'(5i10)',nums(1:npr)

print*,'Normal termination'
end program Sieve_Of_Eratosthenes
 




 34 Posts in Topic:
Simple Program, Lots of Issues (F90)
ALevenson <Andrew.Leve  2008-07-24 10:55:18 
Re: Simple Program, Lots of Issues (F90)
ALevenson <Andrew.Leve  2008-07-24 10:59:09 
Re: Simple Program, Lots of Issues (F90)
Craig Powers <craig.po  2008-07-24 14:11:46 
Re: Simple Program, Lots of Issues (F90)
Paul van Delst <Paul.v  2008-07-24 14:15:22 
Re: Simple Program, Lots of Issues (F90)
Dick Hendrickson <dick  2008-07-24 18:06:28 
Re: Simple Program, Lots of Issues (F90)
Craig Powers <craig.po  2008-07-24 14:09:35 
Re: Simple Program, Lots of Issues (F90)
ALevenson <Andrew.Leve  2008-07-24 11:12:13 
Re: Simple Program, Lots of Issues (F90)
Craig Powers <craig.po  2008-07-24 14:15:20 
Re: Simple Program, Lots of Issues (F90)
ALevenson <Andrew.Leve  2008-07-24 11:19:35 
Re: Simple Program, Lots of Issues (F90)
Alois Steindl <Alois.S  2008-07-24 20:28:47 
Re: Simple Program, Lots of Issues (F90)
Sebastian Hanigk <hani  2008-07-24 20:45:13 
Re: Simple Program, Lots of Issues (F90)
ALevenson <Andrew.Leve  2008-07-24 11:40:38 
Re: Simple Program, Lots of Issues (F90)
Gib Bogle <bogle@[EMAI  2008-07-25 09:47:44 
Re: Simple Program, Lots of Issues (F90)
dpb <none@[EMAIL PROTE  2008-07-24 17:43:53 
Re: Simple Program, Lots of Issues (F90)
"Kevin G. Rhoads&quo  2008-07-25 20:29:05 
Re: Simple Program, Lots of Issues (F90)
dpb <none@[EMAIL PROTE  2008-07-25 17:21:03 
Re: Simple Program, Lots of Issues (F90)
Richard L Walker <rlwa  2008-07-25 19:06:03 
Re: Simple Program, Lots of Issues (F90)
dpb <none@[EMAIL PROTE  2008-07-25 19:15:40 
Re: Simple Program, Lots of Issues (F90)
Ron Ford <ron@[EMAIL P  2008-07-25 01:36:42 
Re: Simple Program, Lots of Issues (F90)
e p chandler <epc8@[EM  2008-07-25 06:57:35 
Re: Simple Program, Lots of Issues (F90)
Ron Ford <ron@[EMAIL P  2008-07-25 16:57:39 
Re: Simple Program, Lots of Issues (F90)
"Dr Ivan D. Reid&quo  2008-07-25 23:12:58 
Re: Simple Program, Lots of Issues (F90)
e p chandler <epc8@[EM  2008-07-25 17:14:15 
Re: Simple Program, Lots of Issues (F90)
nospam@[EMAIL PROTECTED]   2008-07-25 17:30:39 
Re: Simple Program, Lots of Issues (F90)
Ron Ford <ron@[EMAIL P  2008-07-25 22:49:22 
Re: Simple Program, Lots of Issues (F90)
e p chandler <epc8@[EM  2008-07-25 18:02:47 
Re: Simple Program, Lots of Issues (F90)
AnotherSquid <mai@[EMA  2008-07-29 07:26:26 
Re: Simple Program, Lots of Issues (F90)
"Dr Ivan D. Reid&quo  2008-07-29 19:07:40 
Re: Simple Program, Lots of Issues (F90)
Reinhold Bader <Bader@  2008-07-29 21:19:21 
Re: Simple Program, Lots of Issues (F90)
Craig Powers <craig.po  2008-07-29 15:29:20 
Re: Simple Program, Lots of Issues (F90)
"Dr Ivan D. Reid&quo  2008-07-29 22:51:25 
Re: Simple Program, Lots of Issues (F90)
Tobias Burnus <burnus@  2008-07-29 11:39:10 
Re: Simple Program, Lots of Issues (F90)
kargl@[EMAIL PROTECTED]   2008-07-29 19:29:07 
Re: Simple Program, Lots of Issues (F90)
AnotherSquid <mai@[EMA  2008-07-30 06:49:43 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed Nov 19 7:58:52 CST 2008.