以特定格式写入.txt文件

时间:2017-09-01 17:48:30

标签: fortran gfortran

这是我的代码:

Program NN_Lenght

Implicit none

Integer::i,j
Integer,parameter::Br_Dio=14,Br_NN_Mre=10
Integer,parameter,dimension(Br_Dio,Br_NN_Mre)::Lenght=50
Character(350),parameter::fmtA_0_0='(/,1x,130("-"),/,1x,"LENGHT VALUES NN DM:",/,1x,130("-"))'
Character(350),parameter::fmtA_0_1='(1x,"Network:",1x,10(1x,"||NN_DN",1x,i0,"||"))'
Character(350),parameter::fmtA_0_2='(1x,130("-"))'
Character(350),parameter::fmtA_0_3='(1x,"Dio:",1x,i2,".",2x,9("||",7x,"||",1x),"||",8x,"||",1x,/,1x,130("-"))'

Open(Unit=15,File='Lenght_values_NN.txt',Status='Unknown')

   Write(15,trim(adjustl(fmtA_0_0)))
   Write(15,trim(adjustl(fmtA_0_1)))(j,j=1,Br_NN_Mre)
   Write(15,trim(adjustl(fmtA_0_2)))

   Do concurrent(i=1:Br_Dio)

      Write(15,trim(adjustl(fmtA_0_3)))i

   End Do

Close(Unit=15,Status='Keep')

End Program NN_Lenght

代码的结果是Lenght_values_NN.txt文件,在该文件中有一个table_matrix,其中包含空字段(14x10)。我想在table_matrix的每个空字段中输入Length的值。该值为50,就像代码的变量定义部分一样。怎么做?

0 个答案:

没有答案