Question

Using scientific format in output file, I get: 0.245E+02 instead of 2.45E+01.

How to output in the later format in Fortran?

x = 2.45
write(*,130) 'x=', x
130 format (A,E8.2)

Update: According to @Bálint Aradi's answer, I should have set x = 24.5 in order to get 2.45E+01.

Était-ce utile?

La solution

You should use the "scientific exponential" (ES) format:

x = 2.45
write(*, "(A,ES8.2)") "X=", x

Autres conseils

Try the P editing format.

write(*,"(A,1PE8.2)") 'X=',x
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top