Hello guys. I want to save the numbers between 0 and 1 with 0.01 increasement to a dat file. I wrote a code for this using Fortran however, after a point I get 0.314999 instead of 0.315000. Can you help me to solve my problem?(adsbygoogle = window.adsbygoogle || []).push({});

<code>

REAL, DIMENSION(:), ALLOCATABLE :: Y

REAL STEP, JEND, PX, GR, RE, RATIO

INTEGER N, I, J

JEND = 1.00

STEP = 1E-3

N = JEND/STEP+1

RE=1

GR=1

RATIO=GR/RE

PX=-12.00

ALLOCATE (Y(N))

Y(1) = 0.0

OPEN(UNIT=8, FILE='HEATLINE.DAT', STATUS='OLD', FORM='FORMATTED')

DO I = 2, N

Y(I) = Y(I-1)+STEP

END DO

PRINT *, 'N IS:' , N

PRINT *, 'I IS:',I

53 format('VARIABLES = "Y"')

WRITE(8,53)

do i=1,n

write(8,*) Y(I)

end do

CLOSE(8)

END

</code>

**Physics Forums | Science Articles, Homework Help, Discussion**

Dismiss Notice

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Fortran: Data file problem

**Physics Forums | Science Articles, Homework Help, Discussion**