3 use fruit
, only : assert_equals, assert_not_equals, assert_true
20 integer,
dimension(3, 2) :: sizes
22 integer :: i,num_fields,max_y_point
24 call assert_equals(0,star_stencil%nfields,
"Test a stencil has been created")
25 current_state%global_grid%size(
z_index) = 2
27 current_state%local_grid%size(
y_index) = 3
28 current_state%local_grid%halo_size(
y_index) = 4
30 fields(num_fields)%ptr => current_state%u
31 sizes(num_fields,:) = (/ 2, 2 /)
33 allocate(interpolated_fields(0:num_fields))
34 allocate(interpolated_fields(num_fields)%data(current_state%global_grid%size(
z_index),&
36 max_y_point = (current_state%local_grid%size(
y_index)+ &
37 current_state%local_grid%halo_size(
y_index) *2)-1
39 interpolated_fields(num_fields)%active=.true.
40 star_stencil =
create_stencil(current_state%local_grid, fields, num_fields, 3, &
41 sizes,.true., .false.)
42 call assert_equals(max_y_point,star_stencil%max_y_point,
"Test max Y point within the stencil")
43 call assert_equals(-1,star_stencil%max_x_point,
"Test max X point within the stencil")
44 call assert_equals(num_fields+1,
size(interpolated_fields),
"Test size of interpolated_fields")
45 call assert_equals(num_fields,star_stencil%nfields,
"Test a stencil has been created")
53 integer,
dimension(3, 2) :: sizes
55 integer :: i,num_fields,max_y_point
56 logical,
dimension(3) :: interpolate_in_dimension
57 real(kind=DEFAULT_PRECISION) :: r_value
58 real(kind=DEFAULT_PRECISION) :: e_value
61 current_state%global_grid%size(
z_index) = 2
63 current_state%local_grid%size(
z_index)= 0
64 current_state%local_grid%size(
y_index) = 3
65 current_state%local_grid%halo_size(
y_index) = 4
67 fields(num_fields)%ptr => current_state%u
68 sizes(num_fields,:) = (/ 2, 2 /)
70 allocate(interpolated_fields(0:num_fields))
71 allocate(interpolated_fields(num_fields)%data(current_state%global_grid%size(
z_index),&
73 max_y_point = (current_state%local_grid%size(
y_index)+ &
74 current_state%local_grid%halo_size(
y_index) *2)-1
76 interpolated_fields(num_fields)%active=.true.
77 star_stencil =
create_stencil(current_state%local_grid, fields, num_fields, 3, &
78 sizes,.true., .false.)
79 e_value = 10_default_precision
80 star_stencil%interpolated_fields(1,1)%data(1,1,1) = e_value
83 star_stencil%fields(1), star_stencil%interpolated_fields(1,1)%data(:,1,1))
85 r_value = star_stencil%interpolated_fields(1,1)%data(1,1,1)
87 call assert_equals(e_value, r_value,
"Test")
96 use fruit
, only : init_fruit, run_test_case, fruit_summary
105 "Test the calculation of interpolated cell values")
A pointer to the prognostic field. This is so we can wrap prognostics up in an array and still refer ...
integer, parameter, public forward_stepping
Contains prognostic field definitions and functions.
A prognostic field which is assumed to be 3D.
subroutine, public interpolate_to_dual(local_grid, field, stencil, x, y, interpolated_fields, interpolation_id)
Interpolates the (vector) flow fields from the primal to dual grid based upon a specific field interp...
subroutine test_calculate_interpolated_cell_value
integer, parameter, public default_precision
MPI communication type which we use for the prognostic and calculation data.
integer, parameter, public z_index
Grid index parameters.
subroutine test_create_stencil
Information about the parallel aspects of the system.
Contains common definitions for the data and datatypes used by MONC.
The ModelState which represents the current state of a run.
logical function, dimension(3), public get_field_interpolation_index(field)
Retrieves the index(s) that require interpolation to go from the primal the dual grid.
subroutine calculate_interpolated_cell_value(local_grid, j, i, interpolate_in_dimension, field, column_stencil_values)
Calculates the interpolated values for each point in a column. The exact method of interpolation depe...
real(kind=default_precision) function, public random(idum)
returns a scalar random number, the initial seed idum must be negative usage: idum = -k !(set idum < ...
Defined the local grid, i.e. the grid held on this process after decomposition.
Performs the interpolation between the primal and dual grids via a stencil approach. For performance reasons, for each field we store the entirety of the y dimension and the number of x slices required by the stencil. Therefore a new interpolation is simply the calculation of one point and reuse of existing computed points (unless this is the first x or y.) The applicable interpolation stenciled data is copied out, with :,1,1 being the central point, minus and plus in each y and x dimension as determined by the stencil size. This is done so that the stencil size can easily be different for each flow field and this is the case with u (where we need u-2 in the X.)
program test_stencil_driver
Functionality to support the different types of grid and abstraction between global grids and local o...
Configuration for a specific stencil interpolation to perform.
subroutine, public free_stencil(stencil)
Frees up the memory allocated to a stencil.
The model state which represents the current state of a run.
integer, parameter, public y_index
integer, parameter, public x_index
type(grid_stencil_type) function, public create_stencil(local_grid, fields, nfields, interpolations_to_perform, sizes, xdim, ydim)
Creates a stencil configuration which will then be used for interpolation.