fortran optimization errors

Steve Kargl sgk@troutmask.apl.washington.edu
Fri Jun 22 22:36:00 GMT 2007


Oe Fri, Jun 22, 2007 at 03:24:45PM -0700, Steve Kargl wrote:
> On Fri, Jun 22, 2007 at 03:10:04PM -0700, Sebastian Sandersius wrote:
> > 
> >   Please find attached, the code with the input data files (eqd_x-).
> > It is a massive code so I wish not to burden you with debugging, but I
> > am sending it since you have asked for it.  I will continue testing
> > with the updated compiler.
> > 
> > >> (3)  1.032407088285647E-002
> > >> (4)  1.032407088285647E-002
> 
> Where is this numerical output written?
> 

Nevermind.  Your code is full of precision problems.  A glance at
semn17.f90 shows

 	double precision, parameter :: pi=4.0*atan(1.0), ot=1.0/3.0
	double precision, parameter :: p2=pi/(3.0*sqrt(3.0)), p3=pi/(3.0*sqrt(2.0))
	double precision, parameter :: KbT=428.208690545*(0.0)

You have single precision constants (24-bits) on the RHS of these 
equations, and you're setting double precision (53-bits) quantities
on the LHS.

Here's a quick test:

  program a
  real(4) x4
  real(8) x8, y8
  x4 = 4.0*atan(1.0)
  x8 = 4.0*atan(1.0)
  y8 = 4.0_8*atan(1.0_8)
  print '(F24.15)', x4
  print '(F24.15)', x8
  print '(F24.15)', y8
  end program a

troutmask:sgk[245] gfc4x -o z a.f90
troutmask:sgk[246] ./z
       3.141592741012573
       3.141592741012573
       3.141592653589793

Notice anything strange.

-- 
Steve



More information about the Fortran mailing list