25 #include "sll_memory.h"
26 #include "sll_working_precision.h"
57 sll_real64,
dimension(:),
pointer :: eta_coords
58 sll_real64,
dimension(:),
pointer :: eta_coords_unit
59 sll_real64,
dimension(:),
pointer :: eta_coords_unit_back
60 sll_real64,
dimension(:),
pointer :: charac_feet
61 sll_real64,
dimension(:),
pointer :: charac_feet_i
62 sll_real64,
dimension(:),
pointer :: buf1d
63 sll_real64,
dimension(:),
pointer :: buf1d_out
70 procedure, pass(adv) :: initialize => &
72 procedure, pass(adv) :: advect_1d => &
74 procedure, pass(adv) :: advect_1d_constant => &
88 process_outside_point) &
93 sll_int32,
intent(in) :: npts
94 sll_real64,
intent(in),
optional :: eta_min
95 sll_real64,
intent(in),
optional :: eta_max
96 sll_real64,
dimension(:),
pointer,
optional :: eta_coords
97 sll_int32,
intent(in),
optional :: bc_type
102 sll_allocate(adv, ierr)
113 process_outside_point)
126 process_outside_point)
130 sll_int32,
intent(in) :: npts
131 sll_real64,
intent(in),
optional :: eta_min
132 sll_real64,
intent(in),
optional :: eta_max
133 sll_real64,
dimension(:),
pointer,
optional :: eta_coords
134 sll_int32,
intent(in),
optional :: bc_type
136 process_outside_point
139 sll_real64 :: delta_eta
144 sll_allocate(adv%eta_coords(npts), ierr)
145 sll_allocate(adv%eta_coords_unit(npts), ierr)
146 sll_allocate(adv%eta_coords_unit_back(npts), ierr)
147 sll_allocate(adv%buf1d(npts), ierr)
148 sll_allocate(adv%buf1d_out(npts), ierr)
150 sll_allocate(adv%charac_feet(npts), ierr)
151 sll_allocate(adv%charac_feet_i(npts), ierr)
153 if (
present(eta_min) .and.
present(eta_max))
then
154 if (
present(eta_coords))
then
155 print *,
'#provide either eta_coords or eta_min and eta_max'
156 print *,
'#and not both in subroutine initialize_BSL_1d_advector'
159 delta_eta = (eta_max - eta_min)/real(npts - 1, f64)
161 adv%eta_coords(i) = eta_min + real(i - 1, f64)*delta_eta
164 else if (
present(eta_coords))
then
165 if (
size(eta_coords) < npts)
then
166 print *,
'#bad size for eta_coords in initialize_BSL_1d_advector'
169 adv%eta_coords(1:npts) = eta_coords(1:npts)
172 print *,
'#Warning, we assume eta_min = 0._f64 eta_max = 1._f64'
173 delta_eta = 1._f64/real(npts - 1, f64)
175 adv%eta_coords(i) = real(i - 1, f64)*delta_eta
179 if (
present(process_outside_point))
then
180 adv%process_outside_point => process_outside_point
181 adv%bc_type = sll_p_user_defined
182 else if (.not. (
present(bc_type)))
then
183 print *,
'#provide boundary condition'
184 print *,
'#bc_type or process_outside_point function'
185 print *,
'#in initialize_CSL_1d_advector'
188 adv%bc_type = bc_type
189 select case (bc_type)
190 case (sll_p_periodic)
192 case (sll_p_set_to_limit)
195 print *,
'#bad value of boundary condition'
196 print *,
'#in initialize_CSL_1d_advector'
201 if ((
present(process_outside_point)) .and. (
present(bc_type)))
then
202 print *,
'#provide either process_outside_point or bc_type'
203 print *,
'#and not both'
204 print *,
'#in initialize_CSL_1d_advector'
208 adv%eta_coords_unit(1:npts) = &
209 (adv%eta_coords(1:npts) - adv%eta_coords(1)) &
210 /(adv%eta_coords(npts) - adv%eta_coords(1))
221 sll_real64,
dimension(:),
intent(in) :: a
222 sll_real64,
intent(in) :: dt
223 sll_real64,
dimension(:),
intent(in) :: input
224 sll_real64,
dimension(:),
intent(out) :: output
228 sll_real64 :: eta_min
229 sll_real64 :: eta_max
233 eta_min = adv%eta_coords(1)
234 eta_max = adv%eta_coords(npts)
236 call adv%charac%compute_characteristics( &
248 if ((adv%charac_feet(i) <= eta_min) .or. (adv%charac_feet(i) >= eta_max))
then
249 adv%charac_feet_i(i) = &
250 adv%process_outside_point(adv%charac_feet(i), eta_min, eta_max)
252 adv%charac_feet_i(i) = adv%charac_feet(i)
256 adv%buf1d(1:npts - 1) = input(1:npts - 1)
269 if (mean < 0.95)
then
270 print *,
'#mean value=', mean
300 call adv%interp%interpolate_array( &
308 adv%eta_coords_unit_back(1:npts) = &
309 (adv%charac_feet(1:npts) - adv%charac_feet(1)) &
310 /(adv%charac_feet(npts) - adv%charac_feet(1))
314 adv%eta_coords_unit, &
316 adv%eta_coords_unit_back, &
320 output(1:npts - 1) = adv%buf1d_out(1:npts - 1)
322 output(npts) = output(1)
333 sll_real64,
intent(in) :: a
334 sll_real64,
intent(in) :: dt
335 sll_real64,
dimension(:),
intent(in) :: input
336 sll_real64,
dimension(:),
intent(out) :: output
337 sll_real64,
dimension(:),
allocatable :: a1
342 sll_allocate(a1(adv%Npts), ierr)
346 call adv%charac%compute_characteristics( &
359 call adv%interp%interpolate_array( &
365 sll_deallocate_array(a1, ierr)
370 sll_real64,
dimension(:),
intent(inout) :: f
371 sll_real64,
dimension(:),
intent(in) :: node_positions
372 sll_int32,
intent(in):: n
373 sll_real64,
intent(out)::m
375 sll_real64::tmp, tmp2
380 m = m + f(i)*(node_positions(i + 1) - node_positions(i))
383 f(1) = (f(1) - m)*(node_positions(2) - node_positions(1))
387 f(i) = (f(i) - m)*(node_positions(i + 1) - node_positions(i))
389 f(i) = f(i - 1) + tmp
392 f(n + 1) = f(n) + tmp
401 node_positions_back, &
404 sll_real64,
dimension(:),
intent(inout) :: f
405 sll_real64,
dimension(:),
intent(in) :: node_positions
406 sll_real64,
dimension(:),
intent(in) :: node_positions_back
407 sll_int32,
intent(in):: n
408 sll_real64,
intent(in)::m
414 f(i) = f(i + 1) - f(i) + m*(node_positions_back(i + 1) - node_positions_back(i))
416 f(n) = tmp - f(n) + m*(node_positions_back(n + 1) - node_positions_back(n))
420 f(i) = f(i)/(node_positions(i + 1) - node_positions(i))
428 sll_deallocate(adv%eta_coords, ierr)
429 sll_deallocate(adv%eta_coords_unit, ierr)
430 sll_deallocate(adv%eta_coords_unit_back, ierr)
431 sll_deallocate(adv%charac_feet, ierr)
432 sll_deallocate(adv%charac_feet_i, ierr)
433 sll_deallocate(adv%buf1d, ierr)
434 sll_deallocate(adv%buf1d_out, ierr)
Abstract class for advection.
conservative semi-lagrangian 1d advection
type(csl_1d_advector) function, pointer, public sll_f_new_csl_1d_advector(interp, charac, Npts, eta_min, eta_max, eta_coords, bc_type, process_outside_point)
subroutine primitive_to_function_csl(f, node_positions, node_positions_back, N, M)
subroutine delete_csl_1d_advector(adv)
subroutine csl_advect_1d_constant(adv, A, dt, input, output)
subroutine function_to_primitive_csl(f, node_positions, N, M)
subroutine initialize_csl_1d_advector(adv, interp, charac, Npts, eta_min, eta_max, eta_coords, bc_type, process_outside_point)
subroutine csl_advect_1d(adv, A, dt, input, output)
Describe different boundary conditions.
Abstract class for characteristic derived type.
function, public sll_f_process_outside_point_set_to_limit(eta, eta_min, eta_max)
function, public sll_f_process_outside_point_periodic(eta, eta_min, eta_max)
Module for 1D interpolation and reconstruction.
Abstract class for 1D interpolation and reconstruction.