I get nothing,
you say. What I get are runtime errors.
Fortran runtime error: End of record
for gfortran
forrtl: severe (66): output statement overflows record
for ifort
That's because you're trying to write 12 characters into an 8 character buffer.
The first thing you can do is to correct the length:
write(filename(2:9), '(F8.5)') tmp
But this will cause unexpected behaviour if tmp < 10
: It will have a space between the p and the number, like so: p 2.12332.txt
I think it would be better if you constructed the whole file name anew every time:
write(filename, '("p", F0.5, ".txt")') tmp
write(filename, '(A1, F0.5, A4)') "p", tmp, ".txt"
(Either one of these will work.)
This will change the length of the file name:
p12.23321.txt
p2.23321.txt
Otherwise you'll have to try with leading zeros, which is described here:
How to pad FORTRAN floating point output with leading zeros?