10#include "test_macros.inc"
12#define YAC_RAD (0.01745329251994329576923690768489d0) ! M_PI / 180
19 use,
intrinsic :: iso_c_binding, only : c_null_char
23 INTEGER :: rank, global_size, ierror
24 INTEGER,
PARAMETER :: n_cells(2) = (/32, 16/)
25 INTEGER,
PARAMETER :: n_corners(2) = (/33, 17/)
26 INTEGER,
PARAMETER :: cyclic(2) = (/0, 0/)
27 DOUBLE PRECISION,
PARAMETER :: delta_lon=1., delta_lat=1.
28 DOUBLE PRECISION,
ALLOCATABLE :: data(:,:)
29 DOUBLE PRECISION,
ALLOCATABLE :: cell_lon(:), cell_lat(:), corner_lon(:), corner_lat(:)
30 INTEGER :: i, comp_id, grid_id, points_id, info, timestep_counter
31 INTEGER :: field_1, field_2, field_3, field_4
32 CHARACTER(len=YAC_MAX_CHARLEN),
PARAMETER :: &
33 weight_file_name =
"test_dynamic_config.nc"
34 CHARACTER(len=YAC_MAX_CHARLEN),
PARAMETER :: &
35 weight_file_name_dummy =
"test_dynamic_config_dummy.nc"
36 CHARACTER(len=YAC_MAX_CHARLEN),
PARAMETER :: &
37 test_config_filename_yaml =
"test_dynamic_config.yaml"
38 CHARACTER(len=YAC_MAX_CHARLEN),
PARAMETER :: &
39 test_config_filename_json =
"test_dynamic_config.json"
40 CHARACTER(len=YAC_MAX_CHARLEN),
PARAMETER :: &
41 grid_output_filename =
"test_dynamic_config_grids.nc"
45 SUBROUTINE c_unlink ( path ) bind ( c, name='unlink' )
46 use,
INTRINSIC :: iso_c_binding, only : c_char
47 CHARACTER(KIND=c_char),
DIMENSION(*) :: path
48 END SUBROUTINE c_unlink
52 CALL mpi_comm_rank(mpi_comm_world, rank, ierror)
53 CALL mpi_comm_size(mpi_comm_world, global_size, ierror)
55 IF (global_size /= 4)
THEN
56 WRITE ( * , * )
"Wrong number of processes (should be 4)"
60 ALLOCATE(
data(n_cells(1), n_cells(2)))
61 ALLOCATE(corner_lon(n_corners(1)), corner_lat(n_corners(2)))
62 ALLOCATE(cell_lon(n_cells(1)), cell_lat(n_cells(2)))
64 DO i = 1, n_corners(1)
65 corner_lon(i) = (dble(i-1)*delta_lon-180.)*yac_rad
67 DO i = 1, n_corners(2)
68 corner_lat(i) = (dble(i-1)*delta_lat-90.)*yac_rad
71 cell_lon(i) = ((dble(i)-0.5)*delta_lon-180.)*yac_rad
74 cell_lat(i) = ((dble(i)-0.5)*delta_lat-90.)*yac_rad
77 IF (rank == 0)
CALL gen_weight_file()
81 IF ( modulo(rank, 2) .eq. 0 )
THEN
88 INQUIRE(file=test_config_filename_yaml, exist=
file_exists)
90 INQUIRE(file=test_config_filename_json, exist=
file_exists)
92 INQUIRE(file=grid_output_filename, exist=
file_exists)
94 CALL c_unlink(trim(grid_output_filename) // c_null_char)
95 CALL c_unlink(trim(test_config_filename_json) // c_null_char)
96 CALL c_unlink(trim(test_config_filename_yaml) // c_null_char)
97 CALL c_unlink(trim(weight_file_name) // c_null_char)
98 CALL c_unlink(trim(weight_file_name_dummy) // c_null_char)
101 DEALLOCATE(
data, cell_lon, cell_lat, corner_lon, corner_lat)
103 IF (timestep_counter .NE. 11) stop 2
105 CALL mpi_finalize(ierror)
109 SUBROUTINE gen_weight_file()
112 INTEGER :: grid_id_out, grid_id_in
113 INTEGER :: point_id_in, point_id_out
114 INTEGER :: field_id_in, field_id_out
115 INTEGER :: interp_stack
120 yac_id,
"2000-01-01T00:00:00",
"2000-01-01T00:00:10")
123 & corner_lon, corner_lat, grid_id_out)
125 & corner_lon, corner_lat, grid_id_in)
127 & cell_lon, cell_lat, point_id_out)
129 & cell_lon, cell_lat, point_id_in)
132 "out", comp_id, [point_id_out], 1, 1,
"1", &
135 "in", comp_id, [point_id_in], 1, 1,
"1", &
142 "comp",
"grid1",
"out", &
143 "comp",
"grid2",
"in", &
146 src_lag = 0, tgt_lag = 0, &
147 weight_file = weight_file_name, &
149 scale_factor = 1.0d0, scale_summand = 0.0d0, &
150 yaxt_exchanger_name =
"irecv_send", &
151 collection_indices = (/0/), &
152 use_raw_exchange = .false.)
157 END SUBROUTINE gen_weight_file
159 SUBROUTINE comp1_main()
163 INTEGER :: field_out, avg_interp
180 & corner_lon, corner_lat, grid_id)
182 & cell_lon, cell_lat, points_id)
200 "comp2",
"grid2",
"4", &
201 "comp1",
"grid1",
"D", &
204 src_lag = 0, tgt_lag = 0, &
205 weight_file = weight_file_name_dummy, mapping_side = 1, &
206 scale_factor = 1.0d0, scale_summand = 0.0d0, &
207 yaxt_exchanger_name =
"irecv_isend", &
208 collection_indices = (/0/), &
222 timestep_counter = timestep_counter + 1
224 CALL yac_fput(field_1,
SIZE(data), 1, 1, reshape(
data, [
SIZE(data), 1, 1]), info, ierror)
227 CALL yac_fput(field_2,
SIZE(data), 1, 1, reshape(
data, [
SIZE(data), 1, 1]), info, ierror)
229 CALL yac_fput(field_3,
SIZE(data), 1, 1, reshape(
data, [
SIZE(data), 1, 1]), info, ierror)
231 CALL yac_fget(field_4,
SIZE(data), 1,
data, info, ierror)
232 IF ((
data(1,1) - 40.) > 1e-14) stop 1
234 CALL yac_fput(field_out,
SIZE(data), 1, 1, reshape(
data, [
SIZE(data), 1, 1]), info, ierror)
240 END SUBROUTINE comp1_main
242 SUBROUTINE comp2_main()
244 INTEGER :: yac_id, avg_interp, i, field_in(15)
245 CHARACTER (LEN=:),
ALLOCATABLE :: config
256 & corner_lon, corner_lat, grid_id)
258 & cell_lon, cell_lat, points_id)
279 "comp1",
"grid1",
"A", &
280 "comp2",
"grid2",
"1", &
284 "comp1",
"grid1",
"B", &
285 "comp2",
"grid2",
"2", &
289 "comp1",
"grid1",
"C", &
290 "comp2",
"grid2",
"3", &
297 field_in(1) = gen_field_avg(yac_id)
298 field_in(2) = gen_field_ncc(yac_id)
299 field_in(3) = gen_field_nnn(yac_id)
300 field_in(4) = gen_field_dnn(yac_id)
301 field_in(5) = gen_field_rbf(yac_id)
302 field_in(6) = gen_field_rbf_opts(yac_id)
303 field_in(7) = gen_field_conserv(yac_id)
304 field_in(8) = gen_field_spmap_yac(yac_id)
305 field_in(9) = gen_field_spmap_file(yac_id)
306 field_in(10) = gen_field_spmap_ext(yac_id)
307 field_in(11) = gen_field_hcsbb(yac_id)
308 field_in(12) = gen_field_user_file(yac_id)
309 field_in(13) = gen_field_user_file_opts(yac_id)
310 field_in(14) = gen_field_fixed(yac_id)
311 field_in(15) = gen_field_creep(yac_id)
318 timestep_counter = timestep_counter + 1
320 CALL yac_fget(field_1,
SIZE(data), 1,
data, info, ierror)
322 IF ((
data(1,1) - 42.) > 1e-14) stop 1
324 CALL yac_fget(field_2,
SIZE(data), 1,
data, info, ierror)
325 IF ((
data(1,1) - 43.) > 1e-14) stop 1
327 CALL yac_fget(field_3,
SIZE(data), 1,
data, info, ierror)
328 IF ((
data(1,1) - 44.) > 1e-14) stop 1
330 CALL yac_fput(field_4,
SIZE(data), 1, 1, reshape(
data, [
SIZE(data), 1, 1]), info, ierror)
331 DO i = 1,
SIZE(field_in)
332 CALL yac_fget(field_in(i),
SIZE(data), 1,
data, info, ierror)
339 END SUBROUTINE comp2_main
341 FUNCTION gen_field(yac_id, field_name, interp_stack)
RESULT(field_id)
342 INTEGER,
INTENT(IN) :: yac_id
343 CHARACTER(len=*),
INTENT(IN) :: field_name
344 INTEGER,
INTENT(IN) :: interp_stack
348 field_name, comp_id, [points_id], 1, 1,
"1", &
351 yac_id,
"comp1",
"grid1",
"OUT",
"comp2",
"grid2", field_name, &
355 END FUNCTION gen_field
357 FUNCTION gen_field_avg(yac_id)
358 INTEGER,
INTENT(IN) :: yac_id
359 INTEGER :: gen_field_avg
360 INTEGER :: interp_stack
364 gen_field_avg = gen_field(yac_id,
"avg", interp_stack)
365 END FUNCTION gen_field_avg
367 FUNCTION gen_field_ncc(yac_id)
368 INTEGER,
INTENT(IN) :: yac_id
369 INTEGER :: gen_field_ncc
370 INTEGER :: interp_stack
374 gen_field_ncc = gen_field(yac_id,
"ncc", interp_stack)
375 END FUNCTION gen_field_ncc
377 FUNCTION gen_field_nnn(yac_id)
378 INTEGER,
INTENT(IN) :: yac_id
379 INTEGER :: gen_field_nnn
380 INTEGER :: interp_stack
384 gen_field_nnn = gen_field(yac_id,
"nnn", interp_stack)
385 END FUNCTION gen_field_nnn
387 FUNCTION gen_field_dnn(yac_id)
388 INTEGER,
INTENT(IN) :: yac_id
389 INTEGER :: gen_field_dnn
390 INTEGER :: interp_stack
394 gen_field_dnn = gen_field(yac_id,
"dnn", interp_stack)
395 END FUNCTION gen_field_dnn
397 FUNCTION gen_field_rbf(yac_id)
398 INTEGER,
INTENT(IN) :: yac_id
399 INTEGER :: gen_field_rbf
400 INTEGER :: interp_stack
403 gen_field_rbf = gen_field(yac_id,
"rbf", interp_stack)
404 END FUNCTION gen_field_rbf
406 FUNCTION gen_field_rbf_opts(yac_id)
410 INTEGER,
INTENT(IN) :: yac_id
411 INTEGER :: gen_field_rbf_opts
412 INTEGER :: interp_stack
419 gen_field_rbf_opts = gen_field(yac_id,
"rbf_opts", interp_stack)
420 END FUNCTION gen_field_rbf_opts
422 FUNCTION gen_field_conserv(yac_id)
423 INTEGER,
INTENT(IN) :: yac_id
424 INTEGER :: gen_field_conserv
425 INTEGER :: interp_stack
429 gen_field_conserv = gen_field(yac_id,
"conserv", interp_stack)
430 END FUNCTION gen_field_conserv
432 FUNCTION gen_field_spmap_yac(yac_id)
433 INTEGER,
INTENT(IN) :: yac_id
434 INTEGER :: gen_field_spmap_yac
435 INTEGER :: interp_stack
439 1.0d0,
"" // c_null_char,
"" // c_null_char, 0, &
440 1.0d0,
"" // c_null_char,
"" // c_null_char, 0)
441 gen_field_spmap_yac = gen_field(yac_id,
"spmap_yac", interp_stack)
442 END FUNCTION gen_field_spmap_yac
444 FUNCTION gen_field_spmap_file(yac_id)
445 INTEGER,
INTENT(IN) :: yac_id
446 INTEGER :: gen_field_spmap_file
447 INTEGER :: interp_stack
451 0.0d0,
"area.nc" // c_null_char,
"src_cell_area" // c_null_char, 0, &
452 0.0d0,
"area.nc" // c_null_char,
"tgt_cell_area" // c_null_char, 0)
453 gen_field_spmap_file = gen_field(yac_id,
"spmap_file", interp_stack)
454 END FUNCTION gen_field_spmap_file
456 FUNCTION gen_field_spmap_ext(yac_id)
457 INTEGER,
INTENT(IN) :: yac_id
458 INTEGER :: gen_field_spmap_ext
459 INTEGER :: interp_stack
460 INTEGER :: spmap_overwrite_config_ids(2)
462 0.0d0, 0.0d0, 1.0d0, spmap_overwrite_config_ids(1), &
463 spread_distance = 0.5d0)
465 0.0d0, 1.5d0, 1.0d0, spmap_overwrite_config_ids(2), &
470 1.0d0,
"" // c_null_char,
"" // c_null_char, 0, &
471 1.0d0,
"" // c_null_char,
"" // c_null_char, 0, &
472 spmap_overwrite_config_ids = spmap_overwrite_config_ids)
473 gen_field_spmap_ext = gen_field(yac_id,
"spmap_ext", interp_stack)
475 spmap_overwrite_config_ids(2))
477 spmap_overwrite_config_ids(1))
478 END FUNCTION gen_field_spmap_ext
480 FUNCTION gen_field_hcsbb(yac_id)
481 INTEGER,
INTENT(IN) :: yac_id
482 INTEGER :: gen_field_hcsbb
483 INTEGER :: interp_stack
486 gen_field_hcsbb = gen_field(yac_id,
"hcsbb", interp_stack)
487 END FUNCTION gen_field_hcsbb
489 FUNCTION gen_field_user_file(yac_id)
490 INTEGER,
INTENT(IN) :: yac_id
491 INTEGER :: gen_field_user_file
492 INTEGER :: interp_stack
495 interp_stack, weight_file_name)
496 gen_field_user_file = gen_field(yac_id,
"user_file", interp_stack)
497 END FUNCTION gen_field_user_file
499 FUNCTION gen_field_user_file_opts(yac_id)
501 INTEGER,
INTENT(IN) :: yac_id
502 INTEGER :: gen_field_user_file_opts
503 INTEGER :: interp_stack
506 interp_stack, weight_file_name, &
509 gen_field_user_file_opts = gen_field(yac_id,
"user_file_opts", interp_stack)
510 END FUNCTION gen_field_user_file_opts
512 FUNCTION gen_field_fixed(yac_id)
513 INTEGER,
INTENT(IN) :: yac_id
514 INTEGER :: gen_field_fixed
515 INTEGER :: interp_stack
518 interp_stack, -1.0d0)
519 gen_field_fixed = gen_field(yac_id,
"fixed", interp_stack)
520 END FUNCTION gen_field_fixed
522 FUNCTION gen_field_creep(yac_id)
523 INTEGER,
INTENT(IN) :: yac_id
524 INTEGER :: gen_field_creep
525 INTEGER :: interp_stack
529 gen_field_creep = gen_field(yac_id,
"creep", interp_stack)
530 END FUNCTION gen_field_creep
534 USE mpi,
ONLY : mpi_abort, mpi_comm_world
539 CALL test ( .false. )
542 CALL mpi_abort ( mpi_comm_world, 999, ierror )
Fortran interface for definition of a couple.
Fortran interface for the definition of time parameters.
Fortran interface for the definition of coupling fields using default masks.
Fortran interface for the definition of grids.
Fortran interface for the definition of points.
Fortran interface for invoking the end of the definition phase.
Fortran interface for the coupler termination.
Fortran interfaces for the definition of an interpolation stack.
Fortran interface for receiving coupling fields.
Fortran interface for the coupler initialisation.
Fortran interface for the component definition.
Fortran interface for sending coupling fields.
Fortran interface for the writing of configuration files.
Fortran interface for enabling/disabling of coordinate checks.
Fortran interface for enabling/disabling of coordinates mismatch fatality.
Fortran interface for the writing of grid files.
Fortran interface for invoking the end of the definition phase.
subroutine, public stop_test()
subroutine, public exit_tests()
integer(kind=c_size_t), parameter yac_interp_rbf_n_default_f
real(kind=c_double), parameter yac_interp_rbf_scale_default_f
real(kind=c_double), parameter yac_interp_rbf_max_search_distance_default_f
@ yac_action_put_for_restart
last valid put
@ yac_action_get_for_restart
last valid get
@ yac_config_output_format_json
@ yac_config_output_format_yaml
@ yac_proleptic_gregorian
integer yac_yaml_emitter_default_f
Flag paramters for emitting of coupling configurations.
@ yac_dnn_search_distance_fixed
@ yac_file_missing_cont
continue on missing file
@ yac_wgt_on_existing_overwrite
@ yac_file_success_stop
prevents following interpolation method from computating further weights
@ yac_reduction_time_accumulate
@ yac_reduction_time_none
@ yac_config_output_sync_loc_sync_def
@ yac_config_output_sync_loc_enddef
static int file_exists(char const *path)
subroutine yac_fget_interp_stack_config(interp_stack_config_id)
subroutine yac_fadd_interp_stack_config_fixed(interp_stack_config_id, val)
subroutine yac_fadd_interp_stack_config_creep(interp_stack_config_id, creep_distance)