[Fortran] 纯文本查看 复制代码
PROGRAM BCI
IMPLICIT NONE
INTEGER::T1=10
INTEGER::T2=30
INTEGER::M,N
REAL::T(16,12)
REAL::TA(16,12)
REAL::ET(16,12)
REAL::LAN=0.53
REAL::ERR
CALL GRID
CALL START
OPEN(01,FILE='BCI.dat')
DO WHILE(ERR>0.00000001)
CALL SOLVER
END DO
PRINT*,' M N T'
DO M=1,16
DO N=1,12
PRINT*,M,N,T(M,N)
WRITE(01,*)M,N,T(M,N)
END DO
END DO
CONTAINS
SUBROUTINE GRID
INTEGER::T1=10
INTEGER::T2=30
INTEGER M,N
!REAL T(16,12)
DO N=1,7
T(6,N)=T1
END DO
DO M=7,16
T(M,7)=T1
END DO
DO N=1,12
T(1,N)=T2
END DO
DO M=2,16
T(M,12)=T2
END DO
END SUBROUTINE GRID
SUBROUTINE START
INTEGER M,N
!REAL T(16,12)
DO M=2,5
DO N=1,11
T(M,N)=10
END DO
END DO
DO M=6,16
DO N=8,11
T(M,N)=10
END DO
END DO
END SUBROUTINE START
SUBROUTINE SOLVER
INTEGER::T1=10
INTEGER::T2=30
INTEGER::M,N
!REAL::T(16,12)
!REAL::TA(16,12)
!REAL::ET(16,12)
!REAL::ERR
DO M=2,5
TA(M,1)=0.25*(2*T(M,2)+T(M-1,1)+T(M+1,1))
END DO
DO M=2,5
DO N=2,11
TA(M,N)=0.25*(T(M+1,N)+T(M-1,N)+T(M,N+1)+T(M,N-1))
END DO
END DO
DO M=6,15
DO N=8,11
TA(M,N)=0.25*(T(M+1,N)+T(M-1,N)+T(M,N+1)+T(M,N-1))
END DO
END DO
DO N=8,11
TA(16,N)=0.25*(2*T(15,N)+T(16,N-1)+T(16,N-1))
END DO
DO N=1,7
TA(6,N)=T1
END DO
DO M=7,16
TA(M,7)=T1
END DO
DO N=1,12
TA(1,N)=T2
END DO
DO M=2,16
TA(M,12)=T2
END DO
DO M=1,16
DO N=1,12
ET(M,N)=ABS(TA(M,N)-T(M,N))
END DO
END DO
ERR=MAXVAL(ET(1:16,1:12))
DO M=1,16
DO N=1,12
T(M,N)=TA(M,N)
END DO
END DO
END SUBROUTINE SOLVER
END PROGRAM BCI