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.

有帮助吗?

解决方案

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

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

其他提示

Try the P editing format.

write(*,"(A,1PE8.2)") 'X=',x
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top