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.

Was it helpful?

Solution

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

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

OTHER TIPS

Try the P editing format.

write(*,"(A,1PE8.2)") 'X=',x
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top