[Fortran] 纯文本查看 复制代码
program attempt_initial_fai
dimension fai(300,300)
!open(101,file='E:\试验程序\one dimension random seed\test_fai.dat')
open(101,file='E:\试验程序\one dimension random seed\fai.dat')
call initial_data(fai(i,j))
write(101,20) ((fai(i,j),j=1,300),i=1,300)
20 FORMAT (1X,300D15.6)
!end do
end program attempt_initial_fai
subroutine initial_data(a(i,j))
open(1,file='E:\试验程序\one dimension random seed\data1.dat')
DO i=1,300
READ(1,'(300D15.6)') fai(:,i)
end do
do i=1,300
do j=1,300
a(i,j)=mod(a(i,j),1.0)
end do
end do
close(1)
return
end subroutine
[Fortran] 纯文本查看 复制代码
program attempt_initial_fai
Implicit None
Real :: fai(300,300)
open(101,file='E:\试验程序\one dimension random seed\fai.dat')
call initial_data(fai) !//去掉 i j
write(101,20) fai
20 FORMAT (1X,300D15.6)
end program attempt_initial_fai
subroutine initial_data(a) !//去掉 i j
Implicit None
Real :: a(300,300) !//要定义 a
integer :: i !//要定义 i
open(1,file='E:\试验程序\one dimension random seed\data1.dat')
Do i = 1 , 300
READ(1,*) a(:,i) !//此处读入 a,用表控读入即可
End do
a = mod( a , 1.0 ) !// 此处可以直接对 a 操作,无需循环
close(1)
end subroutine initial_data