我写了一个简单的程序来生成一个输出文件,但是每次运行它,无论我给它什么单元号,编译器总是给出错误:
Fortran runtime error: Text file busy
这是程序:
program plottest
implicit none
integer :: z,k,m,j,i
double precision :: delta_Tem, deltax, deltaz, a
double precision, dimension(:,:), allocatable :: T_n, T_g_init
double precision, dimension(:), allocatable :: x
double precision, parameter :: pi = 3.141592653589793239d0
double precision, parameter :: T_hot = 300
double precision, parameter :: T_cold = 276
double precision, parameter :: D = 4 !height z (cm)
double precision, parameter :: L = 5 !length x (cm)
integer, parameter :: Nz = 9 !resolution in z
integer, parameter :: Nx = 6 !resolution in x
integer, parameter :: N = 10 !resolution in n
delta_Tem = T_hot-T_cold
deltaz = D/(Nz-1) !(cm)
deltax = L/(Nx-1) !(cm)
a = L/D
allocate(T_n(N,Nz))
allocate(T_g_init(Nx,Nz))
allocate(x(1:Nx))
z=0
T_n(1,1)=T_hot
do k=2,Nz
T_n(1,k) = T_hot-((k-1)*delta_Tem)
end do
z=0
T_n(2,1)=0
do k=1,Nz
do m=2,N
T_n(m,k) = T_n(1,k)*sin(pi*(k-1)*deltaz)
enddo
enddo
do j=1,Nx
x(j) = x(j)+deltax
enddo
do k=1,Nz
do j=1,Nx
do m=1,N
T_g_init(j,k)=T_g_init(j,k)+T_n(m,k)*cos(m*pi*x(j)/a)
enddo
enddo
enddo
open(unit = 15, file = "plottest")
do, i=1,n
do, j=1,k
write(15,"(F25.5)") T_g_init(i,j)
if (j==k) write(15,"(A1)") "X"
enddo
enddo
close(15)
deallocate(T_n)
deallocate(T_g_init)
deallocate(x)
end program plottest
据我所知,没有其他进程在运行,也没有打开其他文本文件。我难住了。