Skip to content
Snippets Groups Projects
Commit 7ae1a0af authored by Moritz Hanke's avatar Moritz Hanke
Browse files

refactoring of test_def_points.inc

parent 632d39c0
No related branches found
No related tags found
No related merge requests found
......@@ -19,96 +19,86 @@ program test_def_points
INTEGER, PARAMETER :: dp = SELECTED_REAL_KIND(15, 307) !< double precision
INTEGER, PARAMETER :: wp = TEST_PRECISION !< selected working precision
REAL(wp), PARAMETER :: YAC_RAD = 0.017453292519943295769_wp ! M_PI / 180
integer :: comp_id
integer :: grid_id
integer :: point_id
integer :: location
integer, parameter :: nbr_points = 2
integer, parameter :: nbr_vertices = 6
integer, parameter :: nbr_cells = 2
integer, parameter :: nbr_vertices_per_cell = 4
integer :: cell_to_vertex(nbr_vertices_per_cell,nbr_cells)
integer, parameter :: nbr_vertices(2) = (/3,3/)
integer, parameter :: nbr_cells(2) = (/2,2/)
integer, parameter :: cyclic(2) = (/0,0/)
real(wp) :: x_vertices(nbr_vertices)
real(wp) :: y_vertices(nbr_vertices)
real(wp), parameter :: x_vertices(3) = real((/-1.0, 0.0, 1.0/), wp) * YAC_RAD
real(wp), parameter :: y_vertices(3) = real((/-1.0, 0.0, 1.0/), wp) * YAC_RAD
real(wp) :: x_points(nbr_points)
real(wp) :: y_points(nbr_points)
real(wp), parameter :: x_cells(2) = real((/-0.5, 0.5/), wp) * YAC_RAD
real(wp), parameter :: y_cells(2) = real((/-0.5, 0.5/), wp) * YAC_RAD
call yac_finit ( )
! set up dummy component
call yac_fdef_comp ( "ICON-ocean", comp_id )
call yac_fdef_comp ( "dummy-comp", comp_id )
print *, ' def_comp returned comp_id ', comp_id
call test ( comp_id /= -99 )
! uniform unstructured grid
! 1-------2
! | |
! | 1 |
! | |
! 3-------4
! | |
! | 2 |
! | |
! 5-------6
x_vertices(1) = -0.5; y_vertices(1) = 1.0
x_vertices(2) = 0.5; y_vertices(2) = 1.0
x_vertices(3) = -0.5; y_vertices(3) = 0.0
x_vertices(4) = 0.5; y_vertices(4) = 0.0
x_vertices(5) = -0.5; y_vertices(5) = -1.0
x_vertices(6) = 0.5; y_vertices(6) = -1.0
cell_to_vertex(1,1) = 1
cell_to_vertex(2,1) = 3
cell_to_vertex(3,1) = 4
cell_to_vertex(4,1) = 2
cell_to_vertex(1,2) = 3
cell_to_vertex(2,2) = 5
cell_to_vertex(3,2) = 6
cell_to_vertex(4,2) = 4
! regular 2d grid
! 7-------8-------9
! | | |
! | 3 | 4 |
! | | |
! 4-------5-------6
! | | |
! | 1 | 2 |
! | | |
! 1-------2-------3
grid_id = -99
call yac_fdef_grid ( 'grid1', &
nbr_vertices, &
nbr_cells, &
nbr_vertices_per_cell, &
x_vertices, &
y_vertices, &
cell_to_vertex, &
call yac_fdef_grid ( 'reg2d_grid', &
nbr_vertices, &
cyclic, &
x_vertices, &
y_vertices, &
grid_id )
print *, ' def_grid returned grid_id ', grid_id
call test ( grid_id /= -99 )
call test(grid_id /= -99)
call test(yac_fget_grid_size(yac_location_cell, grid_id) == 4)
call test(yac_fget_grid_size(yac_location_corner, grid_id) == 9)
call test(yac_fget_grid_size(yac_location_edge, grid_id) == 12)
call start_test("def_points")
location = YAC_LOCATION_CELL ! one point per cell
x_points(1) = 0.0
y_points(1) = 0.5
x_points(2) = 0.0
y_points(2) = -0.5
point_id = -99
call yac_fdef_points ( grid_id, &
nbr_points, &
location, &
x_points, &
y_points, &
! regular 2d points
call yac_fdef_points ( grid_id, &
nbr_vertices, &
yac_location_corner, &
x_vertices, &
y_vertices, &
point_id )
print *, ' def_points returned point_id ', point_id
call test ( point_id /= -99 )
call test(point_id /= -99)
call test(yac_fget_points_size(point_id) == product(nbr_vertices))
! uniform unstructed 2d points
call yac_fdef_points ( grid_id, &
nbr_cells, &
yac_location_cell, &
reshape( &
(/-0.5_wp, 0.5_wp, -0.5_wp, 0.5_wp/), &
nbr_cells), &
reshape( &
(/-0.5_wp, -0.5_wp, 0.5_wp, 0.5_wp/), &
nbr_cells), point_id )
call test(point_id /= -99)
call test(yac_fget_points_size(point_id) == product(nbr_cells))
call test ( 2 == yac_fget_points_size( point_id ))
call yac_ffinalize ( )
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment