YAC 3.13.0
Yet Another Coupler
Loading...
Searching...
No Matches
test_fortran_api.F90
Go to the documentation of this file.
1! Copyright (c) 2024 The YAC Authors
2!
3! SPDX-License-Identifier: BSD-3-Clause
4
5#include "test_macros.inc"
6
11
12#define NOP(x) associate( x => x ); end associate
13
14PROGRAM main
15
16 use, INTRINSIC :: iso_c_binding
17 USE utest
18 USE yac_core
19 USE mpi
20
21 IMPLICIT NONE
22
23 INTERFACE
24
25 SUBROUTINE c_free ( ptr ) bind ( c, name='free' )
26
27 use, INTRINSIC :: iso_c_binding, only : c_ptr
28
29 TYPE ( c_ptr ), INTENT(IN), VALUE :: ptr
30
31 END SUBROUTINE c_free
32
33 END INTERFACE
34
35 INTEGER :: ierror
36
37 REAL(kind=c_double), PARAMETER :: &
38 yac_rad = 0.017453292519943295769_c_double ! M_PI / 180
39
40 TYPE(c_ptr) :: basic_grid_empty
41 TYPE(c_ptr) :: basic_grid_reg_2d
42 TYPE(c_ptr) :: basic_grid_reg_2d_deg
43 TYPE(c_ptr) :: basic_grid_curve_2d
44 TYPE(c_ptr) :: basic_grid_curve_2d_deg
45 TYPE(c_ptr) :: basic_grid_unstruct
46 TYPE(c_ptr) :: basic_grid_unstruct_deg
47 TYPE(c_ptr) :: basic_grid_unstruct_ll
48 TYPE(c_ptr) :: basic_grid_unstruct_ll_deg
49 TYPE(c_ptr) :: basic_grid_unstruct_edge
50 TYPE(c_ptr) :: basic_grid_unstruct_edge_deg
51 TYPE(c_ptr) :: basic_grid_unstruct_edge_ll
52 TYPE(c_ptr) :: basic_grid_unstruct_edge_ll_deg
53 TYPE(c_ptr) :: basic_grid_cloud
54 TYPE(c_ptr) :: basic_grid_cloud_deg
55 TYPE(c_ptr) :: basic_grid_reg_2d_rot
56 TYPE(c_ptr) :: basic_grid_reg_2d_rot_deg
57 INTEGER(kind=c_size_t) :: num_cells
58 INTEGER(kind=c_size_t) :: num_corners
59 INTEGER(kind=c_size_t) :: num_edges
60 REAL(kind=c_double), ALLOCATABLE :: cell_areas(:)
61
62 REAL(kind=c_double) :: &
63 cell_coords(3) = (/1.0_c_double, 0.0_c_double, 0.0_c_double/)
64 INTEGER(kind=c_int) :: cell_mask(1) = (/1_c_int/)
65 INTEGER(kind=c_size_t) :: cell_coord_idx, cell_coord_ll_idx
66 INTEGER(kind=c_size_t) :: cell_mask_idx, cell_mask_ll_idx
67
68 TYPE(c_ptr) :: grid_pair
69 TYPE(c_ptr) :: interp_grid
70 TYPE(c_ptr) :: interp_stack_config
71 TYPE(c_ptr) :: interp_stack_config_cpy
72
73 ! data types required to generate extended spmap configuration
74 TYPE(c_ptr) :: scale_config
75 TYPE(c_ptr) :: spmap_config
76 TYPE(c_ptr) :: src_point_selection
77 TYPE(c_ptr) :: source_cell_area_config, target_cell_area_config
78 TYPE(c_ptr) :: overwrite_spmap_config
79 TYPE(c_ptr) :: overwrite_config
80 TYPE(c_ptr), TARGET :: overwrite_configs(2)
81
82 INTEGER(kind=c_int) :: compare_value, test_value
83 LOGICAL :: ltest_value
84
85 INTEGER, TARGET :: do_search_call_count
86 INTEGER, TARGET :: constructor_call_count
87 TYPE(c_ptr) :: interp_method
88 TYPE(c_ptr) :: interp_weights
89 TYPE(c_ptr) :: collection_selection
90 TYPE(c_ptr) :: interpolation_gen_config
91 TYPE(c_ptr) :: interpolation_gen_config_copy
92 TYPE(c_ptr) :: interpolation
93 TYPE(c_ptr) :: interpolation_frac
94 TYPE(c_ptr) :: interpolation_ext
95
96 REAL(kind=c_double), TARGET :: src_cell_data(1)
97 TYPE(c_ptr), TARGET :: src_field_(1)
98 TYPE(c_ptr), TARGET :: src_field_collection(1)
99 REAL(kind=c_double), TARGET :: src_frac_mask(1)
100 TYPE(c_ptr), TARGET :: src_frac_mask_(1)
101 TYPE(c_ptr), TARGET :: src_frac_mask_collection(1)
102 REAL(kind=c_double), TARGET :: tgt_cell_data(1)
103 TYPE(c_ptr), TARGET :: tgt_field_collection(1)
104
105 INTERFACE
106 SUBROUTINE c_unlink ( path ) bind ( c, name='unlink' )
107 use, INTRINSIC :: iso_c_binding, only : c_char
108 CHARACTER(KIND=c_char), DIMENSION(*) :: path
109 END SUBROUTINE c_unlink
110 END INTERFACE
111
112 ! ===================================================================
113
114 CALL start_test('fortran_api')
115
116 CALL yac_mpi_init_c()
117 CALL yac_yaxt_init_c(mpi_comm_world)
118
119 CALL test(yac_mpi_is_initialised_c() /= 0_c_int)
120
121 ! empty grids
122 basic_grid_empty = &
123 yac_basic_grid_empty_new_c("empty_grid" // c_null_char)
124 num_cells = &
126 basic_grid_empty, int(yac_loc_cell, c_int))
127 CALL test(num_cells == 0_c_int)
128
129 ! regular 2d grid (rad coords)
130 basic_grid_reg_2d = &
132 "reg_2d_grid" // c_null_char, &
133 (/2_c_size_t, 2_c_size_t/), (/0_c_int, 0_c_int/), &
134 (/-0.1_c_double, 0.1_c_double/), (/-0.1_c_double, 0.1_c_double/))
135 num_corners = &
137 basic_grid_reg_2d, int(yac_loc_corner, c_int))
138 CALL test(num_corners == 4_c_int)
139
140 ALLOCATE( &
141 cell_areas( &
142 int( &
144 basic_grid_reg_2d, int(yac_loc_cell, c_int)))))
145 cell_areas(:) = -1.0_c_double
146 CALL yac_basic_grid_compute_cell_areas_c(basic_grid_reg_2d, cell_areas)
147 CALL test(all(cell_areas(:) /= -1.0_c_double))
148 DEALLOCATE(cell_areas)
149
150 ! regular 2d grid (deg coords)
151 basic_grid_reg_2d_deg = &
153 "reg_2d_grid_deg" // c_null_char, &
154 (/2_c_size_t, 2_c_size_t/), (/0_c_int, 0_c_int/), &
155 (/-0.1_c_double, 0.1_c_double/), (/-0.1_c_double, 0.1_c_double/))
156 num_corners = &
158 basic_grid_reg_2d_deg, int(yac_loc_corner, c_int))
159 CALL test(num_corners == 4_c_int)
160
161 ! curvilinear 2d grid (rad coords)
162 basic_grid_curve_2d = &
164 "curve_2d_grid" // c_null_char, &
165 (/2_c_size_t, 2_c_size_t/), (/0_c_int, 0_c_int/), &
166 (/-0.1_c_double, 0.1_c_double, -0.1_c_double, 0.1_c_double/), &
167 (/-0.1_c_double, -0.1_c_double, 0.1_c_double, 0.1_c_double/))
168 num_edges = &
170 basic_grid_curve_2d, int(yac_loc_edge, c_int))
171 CALL test(num_edges == 4_c_int)
172
173 ! curvilinear 2d grid (deg coords)
174 basic_grid_curve_2d_deg = &
176 "curve_2d_grid_deg" // c_null_char, &
177 (/2_c_size_t, 2_c_size_t/), (/0_c_int, 0_c_int/), &
178 (/-0.1_c_double, 0.1_c_double, -0.1_c_double, 0.1_c_double/), &
179 (/-0.1_c_double, -0.1_c_double, 0.1_c_double, 0.1_c_double/))
180 num_edges = &
182 basic_grid_curve_2d_deg, int(yac_loc_edge, c_int))
183 CALL test(num_edges == 4_c_int)
184
185 ! unstructured grid (rad coords)
186 basic_grid_unstruct = &
188 "unstruct_grid" // c_null_char, &
189 4_c_size_t, 1_c_size_t, (/4_c_int/), &
190 (/-0.1_c_double, 0.1_c_double, 0.1_c_double, -0.1_c_double/), &
191 (/-0.1_c_double, -0.1_c_double, 0.1_c_double, 0.1_c_double/), &
192 (/0_c_int, 1_c_int, 2_c_int, 3_c_int/))
193 num_edges = &
195 basic_grid_unstruct, int(yac_loc_edge, c_int))
196 CALL test(num_edges == 4_c_int)
197
198 ! unstructured grid (deg coords)
199 basic_grid_unstruct_deg = &
201 "unstruct_grid_deg" // c_null_char, &
202 4_c_size_t, 1_c_size_t, (/4_c_int/), &
203 (/-0.1_c_double, 0.1_c_double, 0.1_c_double, -0.1_c_double/), &
204 (/-0.1_c_double, -0.1_c_double, 0.1_c_double, 0.1_c_double/), &
205 (/0_c_int, 1_c_int, 2_c_int, 3_c_int/))
206 num_edges = &
208 basic_grid_unstruct_deg, int(yac_loc_edge, c_int))
209 CALL test(num_edges == 4_c_int)
210
211 ! unstructured grid (rad coords)
212 basic_grid_unstruct_ll = &
214 "unstruct_grid_ll" // c_null_char, &
215 4_c_size_t, 1_c_size_t, (/4_c_int/), &
216 (/-0.1_c_double, 0.1_c_double, 0.1_c_double, -0.1_c_double/), &
217 (/-0.1_c_double, -0.1_c_double, 0.1_c_double, 0.1_c_double/), &
218 (/0_c_int, 1_c_int, 2_c_int, 3_c_int/))
219 num_edges = &
221 basic_grid_unstruct_ll, int(yac_loc_edge, c_int))
222 CALL test(num_edges == 4_c_int)
223
224 ! unstructured grid (deg coords)
225 basic_grid_unstruct_ll_deg = &
227 "unstruct_grid_ll_deg" // c_null_char, &
228 4_c_size_t, 1_c_size_t, (/4_c_int/), &
229 (/-0.1_c_double, 0.1_c_double, 0.1_c_double, -0.1_c_double/), &
230 (/-0.1_c_double, -0.1_c_double, 0.1_c_double, 0.1_c_double/), &
231 (/0_c_int, 1_c_int, 2_c_int, 3_c_int/))
232 num_edges = &
234 basic_grid_unstruct_ll_deg, int(yac_loc_edge, c_int))
235 CALL test(num_edges == 4_c_int)
236
237 ! unstructured grid (rad coords)
238 basic_grid_unstruct_edge = &
240 "unstruct_edge_grid" // c_null_char, &
241 4_c_size_t, 1_c_size_t, 4_c_size_t, (/4_c_int/), &
242 (/-0.1_c_double, 0.1_c_double, 0.1_c_double, -0.1_c_double/), &
243 (/-0.1_c_double, -0.1_c_double, 0.1_c_double, 0.1_c_double/), &
244 (/0_c_int, 1_c_int, 2_c_int, 3_c_int/), &
245 (/0_c_int, 1_c_int, 1_c_int, 2_c_int, &
246 2_c_int, 3_c_int, 3_c_int, 0_c_int/))
247 num_edges = &
249 basic_grid_unstruct_edge, int(yac_loc_edge, c_int))
250 CALL test(num_edges == 4_c_int)
251
252 ! unstructured grid (deg coords)
253 basic_grid_unstruct_edge_deg = &
255 "unstruct_grid_edge_deg" // c_null_char, &
256 4_c_size_t, 1_c_size_t, 4_c_size_t, (/4_c_int/), &
257 (/-0.1_c_double, 0.1_c_double, 0.1_c_double, -0.1_c_double/), &
258 (/-0.1_c_double, -0.1_c_double, 0.1_c_double, 0.1_c_double/), &
259 (/0_c_int, 1_c_int, 2_c_int, 3_c_int/), &
260 (/0_c_int, 1_c_int, 1_c_int, 2_c_int, &
261 2_c_int, 3_c_int, 3_c_int, 0_c_int/))
262 num_edges = &
264 basic_grid_unstruct_edge_deg, int(yac_loc_edge, c_int))
265 CALL test(num_edges == 4_c_int)
266
267 ! unstructured grid (rad coords)
268 basic_grid_unstruct_edge_ll = &
270 "unstruct_grid_edge_ll" // c_null_char, &
271 4_c_size_t, 1_c_size_t, 4_c_size_t, (/4_c_int/), &
272 (/-0.1_c_double, 0.1_c_double, 0.1_c_double, -0.1_c_double/), &
273 (/-0.1_c_double, -0.1_c_double, 0.1_c_double, 0.1_c_double/), &
274 (/0_c_int, 1_c_int, 2_c_int, 3_c_int/), &
275 (/0_c_int, 1_c_int, 1_c_int, 2_c_int, &
276 2_c_int, 3_c_int, 3_c_int, 0_c_int/))
277 num_edges = &
279 basic_grid_unstruct_edge_ll, int(yac_loc_edge, c_int))
280 CALL test(num_edges == 4_c_int)
281
282 ! unstructured grid (deg coords)
283 basic_grid_unstruct_edge_ll_deg = &
285 "unstruct_grid_edge_ll_deg" // c_null_char, &
286 4_c_size_t, 1_c_size_t, 4_c_size_t, (/4_c_int/), &
287 (/-0.1_c_double, 0.1_c_double, 0.1_c_double, -0.1_c_double/), &
288 (/-0.1_c_double, -0.1_c_double, 0.1_c_double, 0.1_c_double/), &
289 (/0_c_int, 1_c_int, 2_c_int, 3_c_int/), &
290 (/0_c_int, 1_c_int, 1_c_int, 2_c_int, &
291 2_c_int, 3_c_int, 3_c_int, 0_c_int/))
292 num_edges = &
294 basic_grid_unstruct_edge_ll_deg, int(yac_loc_edge, c_int))
295 CALL test(num_edges == 4_c_int)
296
297 ! cloud grid (rad coords)
298 basic_grid_cloud = &
300 "cloud_grid" // c_null_char, 4_c_size_t, &
301 (/-0.1_c_double, 0.1_c_double, 0.1_c_double, -0.1_c_double/), &
302 (/-0.1_c_double, -0.1_c_double, 0.1_c_double, 0.1_c_double/))
303 num_cells = &
305 basic_grid_cloud, int(yac_loc_cell, c_int))
306 num_corners = &
308 basic_grid_cloud, int(yac_loc_corner, c_int))
309 num_edges = &
311 basic_grid_cloud, int(yac_loc_edge, c_int))
312 CALL test(num_cells == 0_c_int)
313 CALL test(num_corners == 4_c_int)
314 CALL test(num_edges == 0_c_int)
315
316 ! cloud grid (deg coords)
317 basic_grid_cloud_deg = &
319 "cloud_grid" // c_null_char, 4_c_size_t, &
320 (/-0.1_c_double, 0.1_c_double, 0.1_c_double, -0.1_c_double/), &
321 (/-0.1_c_double, -0.1_c_double, 0.1_c_double, 0.1_c_double/))
322 num_cells = &
324 basic_grid_cloud_deg, int(yac_loc_cell, c_int))
325 num_corners = &
327 basic_grid_cloud_deg, int(yac_loc_corner, c_int))
328 num_edges = &
330 basic_grid_cloud_deg, int(yac_loc_edge, c_int))
331 CALL test(num_cells == 0_c_int)
332 CALL test(num_corners == 4_c_int)
333 CALL test(num_edges == 0_c_int)
334
335 ! rotated regular 2d grid (rad coords)
336 basic_grid_reg_2d_rot = &
338 "reg_2d_grid_deg" // c_null_char, &
339 (/2_c_size_t, 2_c_size_t/), (/0_c_int, 0_c_int/), &
340 (/-0.5_c_double, 0.5_c_double/) * yac_rad, &
341 (/-0.5_c_double, 0.5_c_double/) * yac_rad, &
342 180.0_c_double * yac_rad, 45.0_c_double * yac_rad)
343 num_corners = &
345 basic_grid_reg_2d_rot, int(yac_loc_corner, c_int))
346 CALL test(num_corners == 4_c_int)
347
348 ! rotated regular 2d grid (deg coords)
349 basic_grid_reg_2d_rot_deg = &
351 "reg_2d_grid_deg" // c_null_char, &
352 (/2_c_size_t, 2_c_size_t/), (/0_c_int, 0_c_int/), &
353 (/-0.5_c_double, 0.5_c_double/), &
354 (/-0.5_c_double, 0.5_c_double/), &
355 180.0_c_double, 45.0_c_double)
356 num_corners = &
358 basic_grid_reg_2d_rot_deg, int(yac_loc_corner, c_int))
359 CALL test(num_corners == 4_c_int)
360
361 ! adding field coordinates and masks
362 cell_coord_idx = &
364 basic_grid_unstruct, yac_loc_cell, cell_coords, 1_c_size_t)
365 cell_coord_ll_idx = &
367 basic_grid_unstruct_ll, yac_loc_cell, cell_coords, 1_c_size_t)
368 cell_mask_idx = &
370 basic_grid_unstruct, yac_loc_cell, cell_mask, 1_c_size_t, &
371 "cell_mask" // c_null_char)
372 cell_mask_ll_idx = &
374 basic_grid_unstruct_ll, yac_loc_cell, cell_mask, 1_c_size_t, &
375 "cell_mask_ll" // c_null_char)
376
377 ! distributed grid
378 grid_pair = &
380 basic_grid_unstruct, basic_grid_unstruct_ll, mpi_comm_world)
381
382 ! interpolation grid
383 interp_grid = &
385 grid_pair, "unstruct_grid" // c_null_char, &
386 "unstruct_grid_ll" // c_null_char, &
387 1_c_size_t, (/yac_loc_cell/), (/cell_coord_idx/), (/cell_mask_idx/), &
388 yac_loc_cell, cell_coord_ll_idx, cell_mask_ll_idx)
389
390 ! interpolation check
392 c_funloc(constructor_callback), c_loc(constructor_call_count), &
393 "constructor_callback" // c_null_char)
395 c_funloc(do_search_callback), c_loc(do_search_call_count), &
396 "do_search_callback" // c_null_char)
397
398 ! setup structures for extended spmap configuration
399 source_cell_area_config = &
402 target_cell_area_config = &
404 "area.nc", "cell_areas", yac_interp_spmap_min_global_id_default_f)
405 scale_config = &
408 source_cell_area_config, target_cell_area_config)
409 src_point_selection = &
411 0.0_c_double, 0.0_c_double, 0.1_c_double)
412 spmap_config = &
417 scale_config)
418 overwrite_spmap_config = &
420 0.1_c_double, &
423 scale_config)
424 overwrite_config = &
426 src_point_selection, overwrite_spmap_config)
427 overwrite_configs = (/overwrite_config, c_null_ptr/)
428
429 ! interpolation stack configuration
430 constructor_call_count = 0
431 do_search_call_count = 0
432 interp_stack_config = yac_interp_stack_config_new_c()
434 interp_stack_config, "constructor_callback" // c_null_char, &
435 "do_search_callback" // c_null_char)
437 interp_stack_config, yac_interp_nnn_weighted_default_f, &
440 interp_stack_config_cpy = &
441 yac_interp_stack_config_copy_c(interp_stack_config)
443 interp_stack_config, yac_interp_avg_weight_type_default_f, &
446 interp_stack_config, yac_interp_ncc_weight_type_default_f, &
449 interp_stack_config, yac_interp_nnn_weighted_default_f, &
453 interp_stack_config, yac_interp_rbf_n_default_f, &
457 interp_stack_config, yac_interp_conserv_order_default_f, &
462 interp_stack_config, yac_interp_spmap_spread_distance_default_f, &
472 interp_stack_config, yac_interp_spmap_config_default_f, &
475 interp_stack_config, spmap_config, c_loc(overwrite_configs(1)))
476 CALL yac_interp_stack_config_add_hcsbb_c(interp_stack_config)
478 interp_stack_config, "test_fortran_api_weights.nc" // c_null_char, &
482 interp_stack_config, -1.0_c_double)
484 interp_stack_config, yac_interp_creep_distance_default_f)
486 interp_stack_config, yac_interp_check_constructor_key_default_f, &
488
489 ! clean up data structures for extended spmap configuration
490 CALL yac_spmap_overwrite_config_delete_c(overwrite_config)
491 CALL yac_interp_spmap_config_delete_c(overwrite_spmap_config)
492 CALL yac_point_selection_delete_c(src_point_selection)
493 CALL yac_interp_spmap_config_delete_c(spmap_config)
494 CALL yac_spmap_scale_config_delete_c(scale_config);
495 CALL yac_spmap_cell_area_config_delete_c(target_cell_area_config)
496 CALL yac_spmap_cell_area_config_delete_c(source_cell_area_config)
497
498 compare_value = &
500 interp_stack_config, interp_stack_config_cpy)
501 CALL test(compare_value /= 0_c_int)
502
503 ! interpolation method stack
504 CALL test(constructor_call_count == 0)
505 interp_method = &
506 yac_interp_stack_config_generate_c(interp_stack_config_cpy)
507 CALL test(constructor_call_count == 1)
508
509 ! interpolation method
510 CALL test(do_search_call_count == 0)
511 interp_weights = &
514 interp_weights, "test_fortran_api_weights.nc" // c_null_char, &
515 "unstruct_grid" // c_null_char, "unstruct_grid_ll" // c_null_char, &
516 0_c_size_t, 0_c_size_t, int(yac_weight_file_overwrite, c_int))
517 CALL test(do_search_call_count == 1)
518
519 ! interpolation
520 interpolation = &
522 interp_weights, yac_mapping_on_src, 1_c_size_t, &
524 1.0_c_double, 0.0_c_double, c_null_char, 1_c_int, 1_c_int)
525 interpolation_frac = &
527 interp_weights, yac_mapping_on_src, 1_c_size_t, &
528 0.0_c_double, 1.0_c_double, 0.0_c_double, c_null_char, 1_c_int, 1_c_int)
529 ltest_value = &
532 CALL test(ltest_value)
533
534 ! collection selection (without explicit indices)
535 collection_selection = &
537 CALL yac_collection_selection_delete_c(collection_selection)
538
539 ! collection selection (with explicit indices)
540 collection_selection = &
541 yac_collection_selection_new_c(1_c_size_t, (/0_c_size_t/))
542
543 ! interpolation generation configuration
544 interpolation_gen_config = yac_interpolation_gen_config_new_c()
546 interpolation_gen_config, yac_mapping_on_tgt)
548 interpolation_gen_config, 1_c_size_t)
550 interpolation_gen_config, collection_selection)
552 interpolation_gen_config, 1.0_c_double)
554 interpolation_gen_config, 2.0_c_double)
556 interpolation_gen_config, 2.0_c_double)
558 interpolation_gen_config, "" // c_null_char)
559 interpolation_gen_config_copy = &
560 yac_interpolation_gen_config_copy_c(interpolation_gen_config)
561
562 ! interpolation with extended configuration
563 interpolation_ext = &
565 interp_weights, interpolation_gen_config, 1_c_int, 1_c_int)
566
567 src_field_(1) = c_loc(src_cell_data(1))
568 src_field_collection(1) = c_loc(src_field_(1))
569 src_frac_mask_(1) = c_loc(src_frac_mask)
570 src_frac_mask_collection(1) = c_loc(src_frac_mask_(1))
571 tgt_field_collection(1) = c_loc(tgt_cell_data(1))
572 src_cell_data(1) = 1.0_c_double
573 src_frac_mask(1) = 0.0_c_double
574
575 tgt_cell_data(1) = -1.0_c_double
577 interpolation, c_loc(src_field_collection), c_loc(tgt_field_collection))
578 CALL test(tgt_cell_data(1) == src_cell_data(1))
579
580 tgt_cell_data(1) = -1.0_c_double
582 interpolation_frac, c_loc(src_field_collection), &
583 c_loc(src_frac_mask_collection), c_loc(tgt_field_collection))
584 CALL test(tgt_cell_data(1) == 0.0_c_double)
585
586 tgt_cell_data(1) = -1.0_c_double
587 test_value = yac_interpolation_execute_put_test_c(interpolation)
588 CALL test(test_value == 1_c_int)
590 interpolation, c_loc(src_field_collection))
592 interpolation, c_loc(tgt_field_collection))
593 CALL test(tgt_cell_data(1) == src_cell_data(1))
594
595 tgt_cell_data(1) = -1.0_c_double
597 interpolation_frac, c_loc(tgt_field_collection))
598 test_value = yac_interpolation_execute_get_test_c(interpolation_frac)
599 CALL test(test_value == 0_c_int)
600 CALL mpi_barrier(mpi_comm_world, ierror)
602 interpolation_frac, c_loc(src_field_collection), &
603 c_loc(src_frac_mask_collection))
604 CALL yac_interpolation_execute_wait_c(interpolation_frac)
605 CALL test(tgt_cell_data(1) == 0.0_c_double)
606 tgt_cell_data(1) = -1.0_c_double
607
608 ! cleanup
609 CALL yac_interpolation_delete_c(interpolation_ext)
610 CALL yac_interpolation_delete_c(interpolation_frac)
611 CALL yac_interpolation_delete_c(interpolation)
612 CALL yac_interpolation_gen_config_delete_c(interpolation_gen_config)
613 CALL yac_interpolation_gen_config_delete_c(interpolation_gen_config_copy)
614 CALL yac_collection_selection_delete_c(collection_selection)
615 CALL c_unlink("test_fortran_api_weights.nc" // c_null_char)
616 CALL yac_interp_weights_delete_c(interp_weights)
618 CALL c_free(interp_method)
619 CALL yac_interp_stack_config_delete_c(interp_stack_config_cpy)
620 CALL yac_interp_stack_config_delete_c(interp_stack_config)
622 CALL yac_interp_grid_delete_c(interp_grid)
623 CALL yac_dist_grid_pair_delete_c(grid_pair)
624 CALL yac_basic_grid_delete_c(basic_grid_reg_2d_rot_deg)
625 CALL yac_basic_grid_delete_c(basic_grid_reg_2d_rot)
626 CALL yac_basic_grid_delete_c(basic_grid_cloud_deg)
627 CALL yac_basic_grid_delete_c(basic_grid_cloud)
628 CALL yac_basic_grid_delete_c(basic_grid_unstruct_edge_ll_deg)
629 CALL yac_basic_grid_delete_c(basic_grid_unstruct_edge_ll)
630 CALL yac_basic_grid_delete_c(basic_grid_unstruct_edge_deg)
631 CALL yac_basic_grid_delete_c(basic_grid_unstruct_edge)
632 CALL yac_basic_grid_delete_c(basic_grid_unstruct_ll_deg)
633 CALL yac_basic_grid_delete_c(basic_grid_unstruct_ll)
634 CALL yac_basic_grid_delete_c(basic_grid_unstruct_deg)
635 CALL yac_basic_grid_delete_c(basic_grid_unstruct)
636 CALL yac_basic_grid_delete_c(basic_grid_curve_2d_deg)
637 CALL yac_basic_grid_delete_c(basic_grid_curve_2d)
638 CALL yac_basic_grid_delete_c(basic_grid_reg_2d_deg)
639 CALL yac_basic_grid_delete_c(basic_grid_reg_2d)
640 CALL yac_basic_grid_delete_c(basic_grid_empty)
641
642 CALL yac_mpi_cleanup_c()
643 CALL yac_mpi_finalize_c()
644
645 CALL stop_test
646 CALL exit_tests
647
648CONTAINS
649
650 SUBROUTINE constructor_callback(user_data) BIND(C)
651
652 TYPE(c_ptr), value :: user_data
653
654 INTEGER, POINTER :: constructor_call_count
655
656 CALL c_f_pointer(user_data, constructor_call_count)
657
658 constructor_call_count = constructor_call_count + 1
659
660 END SUBROUTINE constructor_callback
661
662 SUBROUTINE do_search_callback( &
663 global_ids, coordinates_xyz, count, user_data) BIND(C)
664
665 TYPE(c_ptr), value :: global_ids
666 TYPE(c_ptr), value :: coordinates_xyz
667 INTEGER(kind=c_size_t), value :: count
668 TYPE(c_ptr), value :: user_data
669
670 INTEGER, POINTER :: do_search_call_count
671
672 nop(global_ids)
673 nop(coordinates_xyz)
674 nop(count)
675
676 CALL c_f_pointer(user_data, do_search_call_count)
677
678 do_search_call_count = do_search_call_count + 1
679
680 END SUBROUTINE
681
682END PROGRAM main
static size_t do_search_callback(struct interp_method *method, struct yac_interp_grid *interp_grid, size_t *tgt_points, size_t count, struct yac_interp_weights *weights, int *interpolation_complete)
Definition utest.F90:5
subroutine, public start_test(name)
Definition utest.F90:20
subroutine, public stop_test()
Definition utest.F90:27
subroutine, public exit_tests()
Definition utest.F90:81
integer(kind=c_int), parameter yac_interp_ncc_partial_coverage_default_f
Definition yac_core.F90:111
character(kind=c_char, len= *), parameter yac_interp_spmap_varname_default_f
Definition yac_core.F90:144
type(c_ptr) function yac_collection_selection_new_c(collection_size, selection_indices)
@ yac_loc_cell
Definition yac_core.F90:33
@ yac_loc_edge
Definition yac_core.F90:35
@ yac_loc_corner
Definition yac_core.F90:34
integer(kind=c_int), parameter yac_interp_nnn_weighted_default_f
Definition yac_core.F90:126
integer(kind=c_int), parameter yac_interp_avg_partial_coverage_default_f
Definition yac_core.F90:107
real(kind=c_double), parameter yac_interp_nnn_max_search_distance_default_f
Definition yac_core.F90:128
@ yac_weight_file_overwrite
Definition yac_core.F90:45
integer(kind=c_int), parameter yac_interp_conserv_normalisation_default_f
Definition yac_core.F90:117
integer(kind=c_int), parameter yac_interp_avg_weight_type_default_f
Definition yac_core.F90:106
integer(kind=c_size_t), parameter yac_interp_rbf_n_default_f
Definition yac_core.F90:132
integer(kind=c_int), parameter yac_interp_file_on_missing_file_default_f
Definition yac_core.F90:154
real(kind=c_double), parameter yac_interp_rbf_scale_default_f
Definition yac_core.F90:134
integer(kind=c_int), parameter yac_interp_spmap_min_global_id_default_f
Definition yac_core.F90:145
integer(kind=c_int), parameter yac_interp_ncc_weight_type_default_f
Definition yac_core.F90:110
type(c_ptr), parameter yac_interp_spmap_overwrite_default_f
Definition yac_core.F90:147
integer(kind=c_int), parameter yac_interp_spmap_weighted_default_f
Definition yac_core.F90:140
integer(kind=c_int), parameter yac_interp_conserv_order_default_f
Definition yac_core.F90:114
character(kind=c_char, len= *), parameter yac_interp_spmap_filename_default_f
Definition yac_core.F90:143
real(kind=c_double), parameter yac_interp_spmap_spread_distance_default_f
Definition yac_core.F90:138
real(kind=c_double), parameter yac_interp_nnn_gauss_scale_default_f
Definition yac_core.F90:129
character(kind=c_char, len= *), parameter yac_interp_check_constructor_key_default_f
Definition yac_core.F90:150
integer(kind=c_int), parameter yac_interp_file_on_success_default_f
Definition yac_core.F90:155
integer(kind=c_int), parameter yac_interp_conserv_partial_coverage_default_f
Definition yac_core.F90:116
real(kind=c_double), parameter yac_interp_spmap_sphere_radius_default_f
Definition yac_core.F90:142
integer(kind=c_int), parameter yac_interp_conserv_enforced_conserv_default_f
Definition yac_core.F90:115
integer(kind=c_size_t), parameter yac_interp_nnn_n_default_f
Definition yac_core.F90:127
real(kind=c_double), parameter yac_interp_rbf_max_search_distance_default_f
Definition yac_core.F90:133
type(c_ptr), parameter yac_interp_spmap_config_default_f
Definition yac_core.F90:146
real(kind=c_double), parameter yac_interp_spmap_max_search_distance_default_f
Definition yac_core.F90:139
integer(kind=c_int), parameter yac_interp_creep_distance_default_f
Definition yac_core.F90:120
character(kind=c_char, len= *), parameter yac_interp_check_do_search_key_default_f
Definition yac_core.F90:151
integer(kind=c_int), parameter yac_interp_spmap_scale_type_default_f
Definition yac_core.F90:141
@ yac_mapping_on_src
Definition yac_core.F90:162
@ yac_mapping_on_tgt
Definition yac_core.F90:163