问题
sorry,
I try to write a file.dat whit a lot of columns (11) with different format (1.4e-12, 10...)
when i try ro write the code i use the following fortran command:
WRITE(7,*) id,t,a,e,inc,capom,omega,capm,mass,radius
but each line in the original file is now write in multiply lines.
From:
1222221 0.0 10.0 0.0 3.1415927 0.0 0.0 3.7828348 9.0E-9 4.0E-6
to:
1222221 0.000000000000000E+000 10.0000000000000 0.000000000000000E+000 0.000000000000000E+000 0.000000000000000E+000 0.000000000000000E+000 1.67102026939392 9.000000189551827E-010 3.999999989900971E-006
How can i resolve this?
Thanks a lot for your help!
回答1:
You need to specify the format you want. You can do this by using
i0
to specify some unknown width integerf4.1
to specify an up-to 2 digit real plus 1 decimal place (min of 0.0 and max of 99.9)f9.7
to specify an up-to 1 digit real plut 7 decimal places (fits pi nicely there)es10.1
to specify an up-to 8 digit scientific notation real with a single decimal place (will fit 9e-9 nicely)1x
to specify a space between each number
These can be used together to get
write(7,'(i0,1x,3(f4.1,1x),f9.7,1x,2(f4.1,1x),2(es10.1,1x))') &
id,t,a,e,inc,capom,omega,capm,mass,radius
来源:https://stackoverflow.com/questions/20979009/fortran-write-output-all-variables-in-a-line