|
沙发
楼主 |
发表于 2023-9-12 15:43:05
|
只看该作者
program main
implicit none
integer,parameter:: nx=21,ny=4
real::er(nx,ny),ef(nx,ny),e(nx,ny)
integer i,j
call read_data("C:\Users\20455\Desktop\error\result.dat",er)
call read_data("C:\Users\20455\Desktop\error\Riemann.dat",ef)
do i=1,nx
do j=2,ny
e(i,j)= abs(er(i,j)-ef(i,j))
end do
end do
e(:,1)=er(:,1)
call write_data("C:\Users\20455\Desktop\error\error.dat",e)
end program main
subroutine read_data(filename,data)
implicit none
integer i,j
integer,parameter:: nx=21,ny=4
character*(*),intent(in)::filename
real,intent(out)::data(nx,ny)
open(10,file=filename)
do i=1,nx
do j=2,ny
read(10,*)(data(i,j))
end do
end do
close(10)
end subroutine read_data
subroutine write_data(filename,data)
implicit none
integer i,j
integer,parameter:: nx=21,ny=4
character*(*),intent(in)::filename
real,intent(in)::data(nx,ny)
open(10,file=filename)
do i=1,nx
do j=1,ny
write(10,*)(data(i,j))
end do
end do
close(10)
end subroutine write_data |
|