18 procedure,
nopass:: interpolate
19 procedure,
nopass:: derivative1
20 procedure,
nopass:: derivative2
22 integer,
save:: verbose=0
23 integer,
save:: order=3
24 integer,
save:: id_debug=0
30 SUBROUTINE init (self, nt)
35 namelist /time_slices_params/ verbose, order, id_debug
36 logical,
save:: first_time=.true.
38 call trace%begin (
'time_slices_t%init')
43 read (io_unit%input, time_slices_params, iostat=iostat)
44 order = min(order,nt-2)
45 write (io%output, time_slices_params)
46 write (io_unit%nml, time_slices_params)
59 SUBROUTINE interpolate (patch, mem, buffer)
62 real(kind=KindScalarVar),
dimension(:,:,:,:):: mem
63 real(kind=4),
dimension(:,:,:):: buffer
65 real(8):: times(patch%nt-1)
66 integer:: iit(patch%nt-1)
67 real(8),
dimension(order+1):: w
70 if (verbose > 0)
write(io_unit%log,*) patch%id,
'time_slices_t%interpolate' 71 call patch%timeslots (iit, times)
72 call lagrange%sequence_weights (patch%out_next, times, i1, i2, w, order)
73 call weighted_sum (patch, times, w, i1, i2, mem, buffer)
74 END SUBROUTINE interpolate
79 SUBROUTINE derivative1 (patch, mem, buffer)
82 real(kind=KindScalarVar),
dimension(:,:,:,:):: mem
83 real(kind=4),
dimension(:,:,:):: buffer
85 real(8):: times(patch%nt-1)
86 real(8),
dimension(order+1):: w
89 if (verbose > 0)
write(io_unit%log,*) patch%id,
'time_slices_t%derivative1' 90 times = patch%t(patch%iit(1:patch%nt-1))
91 call lagrange%deriv_sequence_weights (patch%out_next, times, i1, i2, w, order)
92 call weighted_sum (patch, times, w, i1, i2, mem, buffer)
93 END SUBROUTINE derivative1
98 SUBROUTINE derivative2 (patch, mem, buffer)
101 real(kind=KindScalarVar),
dimension(:,:,:,:):: mem
102 real(kind=4),
dimension(:,:,:):: buffer
104 real(8):: times(patch%nt-1)
105 real(8),
dimension(order+1):: w
108 if (verbose > 0)
write(io_unit%log,*) patch%id,
'time_slices_t%derivative2' 109 times = patch%t(patch%iit(1:patch%nt-1))
110 call lagrange%deriv2_sequence_weights (patch%out_next, times, i1, i2, w, order)
111 call weighted_sum (patch, times, w, i1, i2, mem, buffer)
112 END SUBROUTINE derivative2
117 SUBROUTINE weighted_sum (patch, times, w, i1, i2, mem, buffer)
119 real(8),
dimension(:):: times, w
121 real(kind=KindScalarVar),
dimension(:,:,:,:):: mem
122 real(kind=4),
dimension(:,:,:):: buffer
126 if (verbose>0 .or. patch%id==id_debug)
then 127 write (io_unit%output,
'(a,2i4,2x,10i4)')
'indices:', i1, i2, patch%iit(i1:i2)
128 write (io_unit%output,
'(a,f12.6,2x,10f14.6)')
' times:', patch%out_next, times(i1:i2)
129 write (io_unit%output,
'(a,f12.6,2x,10f14.3)')
'weights:', sum(w), w
133 buffer = buffer + w(1+i-i1)*mem(:,:,:,i)
135 END SUBROUTINE weighted_sum
Compute time derivative from a sequence of time slices, using Lagrange interpolation.
Template module for patches, which adds pointers to memory and mesh, and number of dimensions and var...
Module for Lagrange interpolation.