Search code examples
fortrangfortranfortran95

End of record when writing real to a string


I am getting a runtime error using Fortran 95:

At line 73 of file calcCenterOfMass.f95
Fortran runtime error: End of record

Code in line 73 is

WRITE(TIMEDIR, '(f10.2)') CURRENTTIME

where TIMEDIR is a string and CURRENTTIME a real.

I guess the problem is that TIMEDIR has a length of four because the string has to be of the shape 0.00, 0.01 etc. But a default length real is longer than four characters.

Is that the problem, and then, how to solve it?


Solution

  • The Format f10.2 means 10 characters in length, with 2 decimals. (So it will be xxxxxxx.xx)

    If you want 0.01 or so, you need format f4.2