|
各位老师好,有一个程序,内部有一个功能是将输出的几个参数写到上一个文件夹中名为array-bmax.txt的文件(107)中,由于这个程序需要并行执行,多个并行计算的结果都需要写入array-bmax.txt文件中,实际执行时发现写入文件时,只能写入最后一个计算出的结果,其他的结果都被覆盖掉了,请问这段代码应该如何修改,才能实现将并行输出的结果都写入文件array-bmax.txt中?
[Fortran] 纯文本查看 复制代码 05 | integer i , style , traj , files , n , j , du |
07 | real bmax , Et , RMAX , RBAR , S |
10 | character ( 10 ) :: opinion |
11 | character ( 80 ) :: inp_name |
14 | call ReadInputFile ( inp_name , style , traj , files , n , j , Et , bmax , RMAX , RBAR , S ) |
16 | open ( 107 , file = '../array-bmax.txt' , status = 'old' , position = 'append' ) |
19 | open ( 105 , file = fsbatch ) |
24 | write ( 101 , '(a)' ) trim ( ftmp ) / / 'new/venus-E.e ./' |
26 | call init_random_seed ( ) |
29 | call random_number ( xseed ) |
30 | call writeinp ( i , xseed , style , traj , files , n , j , Et , bmax , inp_name , RMAX , RBAR , S ) |
33 | write ( 101 , '(a)' ) 'cp ./sbatch.sc ./' / / trim ( inp_name ) / / '-inpark' |
34 | write ( 101 , '(a)' ) 'cd ' / / trim ( inp_name ) / / '-inpark' |
35 | write ( 101 , '(a)' ) 'chmod +x sbatch.sc' |
36 | write ( 101 , '(a)' ) "sed -i 's/^.\{19\}/scancel /g' scancel.x" |
37 | write ( 101 , '(a)' ) 'chmod +x scancel.x' |
41 | call execute_command_line ( "chmod +x script.cp" ) |
42 | call execute_command_line ( "./script.cp" ) |
43 | call execute_command_line ( 'sleep 1s' ) |
44 | call execute_command_line ( "rm -r inp0* run0*" ) |
47 | open ( 106 , file = trim ( inp_name ) / / '-inpark/test-bmax' ) |
48 | write ( 106 , '(a,f3.1)' ) "(*.*)zzz---wait---" , bmax |
49 | call execute_command_line ( 'sleep 90s' ) |
51 | call testbmax ( inp_name , traj , du ) |
53 | call execute_command_line ( "rm -r sbatch.sc script.cp" ) |
57 | write ( 107 , '(f5.1,I3,I4,f5.1)' ) Et , n , j , bmax |
60 | elseif ( style == 0 ) then |
|
|