📄 hw001.f90
字号:
subroutine hwSchemeOne
! slove homework 001 with SchemeOne
integer,parameter :: maxLen=10000
real unZero(maxLen),unOne(maxLen)
real leftX,rightX,deltX,deltT,coeff
integer lenX
real :: time=0,timeEnd
integer :: i,k=0,gap=1
integer :: location=10 ! the location of saving file
call InputInitial(lenX,deltX,deltT,coeff,maxLen) ! input paremeter
print *,"Input the stopping time "
read *,timeEnd
print *, "****** Input success ! ******"
call InitialValue(unZero,lenX,deltX)
open(unit=location,file='NumericalSoultion.plt')
write(location,'(a,/,a)'),"title=hwSchemeOne","variables=x,v"
do while(time<timeEnd-1.e-8)
call SchemeOne(unOne,unZero,lenX,deltX,deltT,coeff)
time=time+deltT
unZero=unOne
k=k+1 ! record iterative time
if(real(k)/gap-k/gap==0) then ! record the solution every gap times
call fileOut(unOne,lenX,deltX,time,location)
print *,' the moment outputting value ',k
end if
end do
end subroutine hwSchemeOne
!=====================================================================================================
subroutine hwSchemeTwo
! slove homework 001 with SchemeTwo
integer,parameter :: maxLen=10000 !the maxest number of variables in x direction
real unZero(maxLen),unOne(maxLen)
real leftX,rightX,deltX,deltT,coeff
integer lenX
real :: time=0,timeEnd
integer :: i,k=0,gap=1 ! time step length of recording the result
integer :: location=10 ! the location of saving file
call InputInitial(lenX,deltX,deltT,coeff,maxLen) ! input paremeter
print *,"Input the stopping time "
read *,timeEnd
print *, "****** Input success ! ******"
call InitialValue(unZero,lenX,deltX)
open(unit=location,file='NumericalSoultion.plt')
write(location,'(a,/,a)'),"title=hwSchemeTwo","variables=x,v"
do while(time<timeEnd-1.e-8)
call SchemeTwo(unOne,unZero,lenX,deltX,deltT,coeff) ! call stencil
time=time+deltT
unZero=unOne
k=k+1 ! record iterative time
if(real(k)/gap-k/gap==0) then ! record the solution every gap times
call fileOut(unOne,lenX,deltX,time,location)
print *,' the moment outputting value ',k
end if
end do
end subroutine hwSchemeTwo
!=======================================================================================
subroutine hwSchemeThree
! slove homework 001 with SchemeThree
integer,parameter :: maxLen=10000 !the maxest number of variables in x direction
real unZero(maxLen),unOne(maxLen)
real leftX,rightX,deltX,deltT,coeff
integer lenX
real :: time=0,timeEnd
integer :: i,k=0,gap=1 ! time step length of recording the result
integer :: location=10 ! the location of saving file
call InputInitial(lenX,deltX,deltT,coeff,maxLen) ! input paremeter
print *," Input the stopping time "
read *,timeEnd
print *, " ****** Input success ! ****** "
call InitialValue(unZero,lenX,deltX)
open(unit=location,file='NumericalSoultion.plt')
write(location,'(a,/,a)'),"title=hwSchemeTwo","variables=x,v"
do while(time<timeEnd-1.e-8)
call SchemeThree(unOne,unZero,lenX,deltX,deltT,coeff) ! call stencil
time=time+deltT
unZero=unOne
k=k+1 ! record iterative time
if(real(k)/gap-k/gap==0) then ! record the solution every gap times
call fileOut(unOne,lenX,deltX,time,location)
print *,' the moment outputting value ',k
end if
end do
end subroutine hwSchemeThree
!=================================================================================
subroutine hwSchemeFour
! slove homework 001 with SchemeFour
integer,parameter :: maxLen=10000 !the maxest number of variables in x direction
real unZero(maxLen),unOne(maxLen)
real leftX,rightX,deltX,deltT,coeff
integer lenX
real :: time=0,timeEnd
integer :: i,k=0,gap=1 ! time step length of recording the result
integer :: location=10 ! the location of saving file
call InputInitial(lenX,deltX,deltT,coeff,maxLen) ! input paremeter
print *," Input the stopping time "
read *,timeEnd
print *, " ****** Input success ! ****** "
call InitialValue(unZero,lenX,deltX)
open(unit=location,file='NumericalSoultion.plt')
write(location,'(a,/,a)'),"title=hwSchemeTwo","variables=x,v"
do while(time<timeEnd-1.e-8)
call SchemeFour(unOne,unZero,lenX,deltX,deltT,coeff) ! call stencil
time=time+deltT
unZero=unOne
k=k+1 ! record iterative time
if(real(k)/gap-k/gap==0) then ! record the solution every gap times
call fileOut(unOne,lenX,deltX,time,location)
print *,' the moment outputting value ',k
end if
end do
end subroutine hwSchemeFour
!========================================================================================
subroutine hwSchemeFive
! slove homework 001 with SchemeFive
integer,parameter :: maxLen=10000 !the maxest number of variables in x direction
real unZero(maxLen),unOne(maxLen)
real leftX,rightX,deltX,deltT,coeff
integer lenX
real :: time=0,timeEnd
integer :: i,k=0,gap=1000 ! time step length of recording the result
integer :: location=10 ! the location of saving file
call InputInitial(lenX,deltX,deltT,coeff,maxLen) ! input paremeter
print *," Input the stopping time "
read *,timeEnd
print *, " ****** Input success ! ****** "
call InitialValue(unZero,lenX,deltX)
open(unit=location,file='NumericalSoultion.plt')
write(location,'(a,/,a)'),"title=hwSchemeFive","variables=x,v"
do while(time<timeEnd-1.e-8)
call SchemeFive(unOne,unZero,lenX,deltX,deltT,coeff) ! call stencil
time=time+deltT
unZero=unOne
k=k+1 ! record iterative time
if(real(k)/gap-k/gap==0) then ! record the solution every gap times
call fileOut(unOne,lenX,deltX,time,location)
print *,' the moment outputting value ',k
end if
end do
end subroutine hwSchemeFive
!============================================================================
subroutine hwSchemeSix
! slove homework 001
integer,parameter :: maxLen=10000 !the maxest number of variables in x direction
real unZero(0:maxLen),unOne(0:maxLen)
real leftX,rightX,deltX,deltT,coeff
integer lenX
real :: time=0,timeEnd
integer :: i,k=0,gap=1 ! time step length of recording the result
integer :: location=10 ! the location of saving file
call InputInitial(lenX,deltX,deltT,coeff,maxLen) ! input paremeter
print *," Input the stopping time "
read *,timeEnd
print *, " ****** Input success ! ****** "
call InitialValue(unZero,lenX,deltX)
open(unit=location,file='NumericalSoultion.plt')
write(location,'(a,/,a)'),"title=hwSchemeTwo","variables=x,v"
do while(time<timeEnd-1.e-7)
call SchemeSix(unOne,unZero,lenX,deltX,deltT,coeff,time) ! call stencil
time=time+deltT
unZero(0:lenX)=unOne(0:lenX)
k=k+1 ! record iterative time
if(real(k)/gap-k/gap==0) then ! record the solution every gap times
call fileOut(unOne,lenX,deltX,time,location)
print *,' the moment outputting value ',k
end if
end do
end subroutine hwSchemeSix
!============================================================================
subroutine hwSchemeSeven
! slove homework 001
integer,parameter :: maxLen=10000 !the maxest number of variables in x direction
real unZero(0:maxLen),unOne(0:maxLen)
real leftX,rightX,deltX,deltT,coeff
integer lenX
real :: time=0,timeEnd
integer :: i,k=0,gap=10000 ! time step length of recording the result
integer :: location=10 ! the location of saving file
call InputInitial(lenX,deltX,deltT,coeff,maxLen) ! input paremeter
print *," Input the stopping time "
read *,timeEnd
print *, " ****** Input success ! ****** "
call InitialValue(unZero,lenX,deltX)
open(unit=location,file='NumericalSoultion.plt')
write(location,'(a,/,a)'),"title=hwSchemeTwo","variables=x,v"
do while(time<timeEnd-1.e-7)
call SchemeSeven(unOne,unZero,lenX,deltX,deltT,coeff,time) ! call stencil
time=time+deltT
unZero(0:lenX)=unOne(0:lenX)
k=k+1 ! record iterative time
if(real(k)/gap-k/gap==0) then ! record the solution every gap times
call fileOut(unOne,lenX,deltX,time,location)
print *,' the moment outputting value ',k
end if
end do
end subroutine hwSchemeSeven
!===========================================================================================
subroutine hwSchemeEight
! slove homework 001
integer,parameter :: maxLen=10000 !the maxest number of variables in x direction
real unZero(0:maxLen),unOne(0:maxLen)
real leftX,rightX,deltX,deltT,coeff
integer lenX
real :: time=0,timeEnd
integer :: i,k=0,gap=10 ! time step length of recording the result
integer :: location=10 ! the location of saving file
call InputInitial(lenX,deltX,deltT,coeff,maxLen) ! input paremeter
print *," Input the stopping time "
read *,timeEnd
print *, " ****** Input success ! ****** "
call InitialValue(unZero,lenX,deltX)
open(unit=location,file='NumericalSoultion.plt')
write(location,'(a,/,a)'),"title=hwSchemeTwo","variables=x,v"
do while(time<timeEnd-1.e-7)
call SchemeEight(unOne,unZero,lenX,deltX,deltT,coeff,time) ! call stencil
time=time+deltT
unZero(0:lenX)=unOne(0:lenX)
k=k+1 ! record iterative time
if(real(k)/gap-k/gap==0) then ! record the solution every gap times
call fileOut(unOne,lenX,deltX,time,location)
print *,' the moment outputting value ',k
end if
end do
end subroutine hwSchemeEight
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -