[Fortran] 纯文本查看 复制代码
program Compute
implicit none
integer,parameter::M=1,N=2
real,dimension(:,:),allocatable::C1
integer i,j,k,m1,n1,a1,a2,ETL(M*N,5)
real aa(4,4)
allocate(C1((M+1)*(N+1),(M+1)*(N+1)))
open(unit=15,file='storett3',access='sequential',action='write')
open(unit=14,file='storeaa3',access='sequential',action='write')
data aa/4,2,1,2,2,4,2,1,1,2,4,2,2,1,2,4/
k=0
do j=1,M
do i=1,N
k=k+1
ETL(k,1)=k
m1=mod(i,N)
if(m1==0) then
n1=j*(N+1)-1
else
n1=(j-1)*(N+1)+m1
end if
ETL(k,2)=n1
ETL(k,3)=n1+1
ETL(k,4)=n1+N+2
ETL(k,5)=n1+N+1
end do
end do
do k=1,M*N
do i=1,4
do j=1,4
a1=ETL(k,i+1)
a2=ETL(k,j+1)
C1(a1,a2)=C1(a1,a2)+aa(i,j)
end do
end do
end do
write(14,"(<4>('',f,''))")((aa(i,j),i=1,4),j=1,4)
write(15,"(<6>('',f,''))")((C1(i,j),i=1,6),j=1,6)
end