主题:[讨论]大家帮我看看我程序的错误,程序不大
program main
implicit none
real::E,A,L,stress(2,1),forces(2,1)
real::u(2,1)
real::k(2,2),kk(2,2)
integer::r,c,i,j
E=2.95E5
A=100
L=0.4
u(1,1)=0.03
u(2,1)=0.05
call func1(E,A,L)
save k
call func2(k)
call func3(kk,u,A )
stop
end program main
subroutine func1(E,A,L )
implicit none
integer r,c
real E,A,L,m
real k(2,2)
m=E*A/L
k=reshape((/m,-m,-m,m/),(/2,2/))
write(*,*)((k(r,c),r=1,2),c=1,2)
return
end subroutine
subroutine func2(k)
implicit none
integer r,c,i,j
real::k(2,2),kk(2,2)
kk(:,:)= 0
do i=1,2
do j=1,2
kk(i,j)=kk(i,j)+k(i,j)
end do
end do
write(*,*)((kk(r,c),r=1,2),c=1,2)
return
end subroutine
subroutine func3(kk,u,A)
implicit none
integer r,c
real::A
real::u(2,1)
real::kk(2,2)
real stress(2,1),forces(2,1)
stress=matmul(kk,u/A)
forces=matmul(kk,u)
write(*,*)(stress(r,1),r=1,2)
write(*,*)(forces(r,1),r=1,2)
return
end subroutine
implicit none
real::E,A,L,stress(2,1),forces(2,1)
real::u(2,1)
real::k(2,2),kk(2,2)
integer::r,c,i,j
E=2.95E5
A=100
L=0.4
u(1,1)=0.03
u(2,1)=0.05
call func1(E,A,L)
save k
call func2(k)
call func3(kk,u,A )
stop
end program main
subroutine func1(E,A,L )
implicit none
integer r,c
real E,A,L,m
real k(2,2)
m=E*A/L
k=reshape((/m,-m,-m,m/),(/2,2/))
write(*,*)((k(r,c),r=1,2),c=1,2)
return
end subroutine
subroutine func2(k)
implicit none
integer r,c,i,j
real::k(2,2),kk(2,2)
kk(:,:)= 0
do i=1,2
do j=1,2
kk(i,j)=kk(i,j)+k(i,j)
end do
end do
write(*,*)((kk(r,c),r=1,2),c=1,2)
return
end subroutine
subroutine func3(kk,u,A)
implicit none
integer r,c
real::A
real::u(2,1)
real::kk(2,2)
real stress(2,1),forces(2,1)
stress=matmul(kk,u/A)
forces=matmul(kk,u)
write(*,*)(stress(r,1),r=1,2)
write(*,*)(forces(r,1),r=1,2)
return
end subroutine