我遇到麻烦让我的代码以正确的形式写出结果。
问题似乎与this one非常相似,但没有帮助。
当我运行以下代码时,输出文件“results / traj.dat”应该只包含一行,但实际上所有数据都溢出到行中。 此问题仅发生在N_BOD = 8,如果N_BOD = 7且IPOSITIONS已使用相应数量的数据进行初始化,则正确写入文件。
有人建议我可能会使用一些编译器选项,以便在没有额外换行符的情况下允许大输出,但我没有找到任何(我正在使用gfortran)。
program ephemerids
implicit none
integer,parameter :: N_BOD=8
character(len=30) :: OFMT2
real(8),parameter,dimension(3*N_BOD) :: IPOSITIONS=(/ &
0.00450250878464055477,0.00076707642709100705,0.00026605791776697764,&
0.36176271656028195477,-0.09078197215676599295,-0.08571497256275117236,&
0.61275194083507215477,-0.34836536903362219295,-0.19527828667594382236,&
0.12051741410138465477,-0.92583847476914859295,-0.40154022645315222236,&
-0.11018607714879824523,-1.32759945030298299295,-0.60588914048429142236,&
-5.37970676855393644523,-0.83048132656339789295,-0.22482887442656542236,&
7.89439068290953155477,4.59647805517127300705,1.55869584283189997764,&
-18.26540225387235944523,-1.16195541867586999295,-0.25010605772133802236/)
OFMT2 = "(22E18.8E3)"
open(20,file='results/traj.dat',status='replace')
write(20,OFMT2) IPOSITIONS
end program ephemerids
编辑:正如francescalus所问,这是我得到的输出:
0.45025088E-002 0.76707645E-003 0.26605790E-003 0.36176270E+000 -0.90781972E-001 -0.85714974E-001 0.61275196E+000 -0.34836537E+000 -0.19527829E+000 0.12051742E+000 -0.92583847E+000 -0.40154022E+000 -0.11018608E+000 -0.13275994E+001 -0.60588914E+000 -0.53797069E+001 -0.83048135E+000 -0.22482887E+000 0.78943906E+001 0.45964780E+001 0.15586958E+001 -0.18265402E+002
-0.11619555E+001 -0.25010607E+000