11 public preprocess,integrate
13 real(dp),
dimension(:),
allocatable :: rwork,
y 14 integer,
dimension(:),
allocatable :: iwork
15 real(dp) :: jac,tout,rtol,atol,t
16 integer :: iopt, istate, itask, itol, liw, lrw, nnz, lenrat, mf, neq
19 subroutine sub (neq, t, y, ydot)
21 integer,
intent(in) :: neq
22 real(dp),
intent(in) :: t
23 real(dp),
intent(in) ::
y(neq)
24 real(dp),
intent(out) :: ydot(neq)
28 procedure(sub),
pointer :: odesystem_ptr => null()
30 real(dp),
dimension(:),
allocatable :: yold
35 use in_out
, only: read_inputs
36 use phys_prop
, only: volume_balance
37 use model
, only: odesystem,set_initial_conditions,update_domain_size
39 write(*,*)
'wellcome to wall drainage.' 42 allocate(
y(neq),yold(neq))
43 call set_initial_conditions(
y)
45 call update_domain_size(t,
y)
46 call volume_balance(
y,vt,fs)
48 odesystem_ptr=>odesystem
54 allocate(rwork(int(20+(2+1._dp/lenrat)*nnz+(11+9._dp/lenrat)*neq)),&
66 end subroutine preprocess
74 use solve_nonlin
, only: hbrd
75 use in_out
, only: save_int_header,save_int_step,save_int_close
77 integer,
parameter :: n=1
79 real (dp),
dimension(n) :: x,fvec,diag
81 call save_int_step(
y,t)
88 call hbrd(drain_residual,n,x,fvec,epsilon(
ae_tol),
ae_tol,info,diag)
90 print*,
'Flux not found.' 91 print*,
'Hbrd returned info = ',info
94 call save_int_step(
y,t)
96 print*,
'gel point reached' 102 deallocate(
y,yold,rwork,iwork)
103 write(*,*)
'program exited normally.' 104 end subroutine integrate
110 subroutine drain_residual(n,x,fvec,iflag)
111 use model
, only: q,update_domain_size
112 use phys_prop
, only: volume_balance,rb
113 integer,
intent(in) :: n
114 integer,
intent(inout) :: iflag
115 real(dp),
dimension(n),
intent(in) :: x
116 real(dp),
dimension(n),
intent(out) :: fvec
122 call dlsodes (odesystem_ptr, neq,
y, t, tout, itol, rtol, atol, itask, &
123 istate, iopt, rwork, lrw, iwork, liw, jac, mf)
124 call update_domain_size(t,
y)
125 call volume_balance(
y,vt,fs)
126 fvec(1)=sqrt((vt-vt0)**2)
128 end subroutine drain_residual
130 end module integration
integer meshpoints
number of discretization points in space
real(dp), dimension(:), allocatable y
state variables
real(dp) int_reltol
relative tolerance of integrator
integer int_method
type of integration method (see MF in ODEPACK)
real(dp) ae_tol
tolerance of algebraic equation solver
real(dp) timestep
timestep
integer its
number of outer integration outer time steps
real(dp) int_abstol
absolute tolerance of integrator
namespace with global variables
real(dp) initialtime
starting time
integer maxts
maximum inner time steps between t and t+h