YAC 3.21.0
Yet Another Coupler
Loading...
Searching...
No Matches
test_read_exodus_parallel.c
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 <stdlib.h>
6#include <stdio.h>
7#include <string.h>
8#include <math.h>
9#include <unistd.h>
10
11#include "tests.h"
12#include "test_common.h"
13#include "read_icon_grid.h"
14#include "geometry.h"
15#include "grid2vtk.h"
16#include "io_utils.h"
17#include "read_exodus_grid.h"
18#include "grid_file_common.h"
19
20#include <mpi.h>
21#include <yaxt.h>
22
28int main(void) {
29
30 MPI_Init(NULL, NULL);
31 xt_initialize(MPI_COMM_WORLD);
32
33 int comm_size, comm_rank;
34
35 MPI_Comm_size(MPI_COMM_WORLD, &comm_size);
36 MPI_Comm_rank(MPI_COMM_WORLD, &comm_rank);
37
38 if ((comm_size != 4) && (comm_rank == 0)) {
39 fputs("wrong number of processes (has to be four)\n", stderr);
40 exit(EXIT_FAILURE);
41 }
42
43 {
44 char const filename[] = "test_read_exodus_parallel_grid.nc";
45 size_t num_lon = 271, num_lat = 181;
46 double lon_range[] = {-135.0, 135.0}, lat_range[] = {-90.0, 90.0};
47 if (comm_rank == 0)
48 utest_write_dummy_exodus_grid_file(
49 filename, num_lon, num_lat, lon_range, lat_range);
50
51 // ensure that the grid file exists
52 MPI_Barrier(MPI_COMM_WORLD);
53
54 {
55 int use_ll_edges = 0;
56 struct yac_basic_grid * exodus_grid =
58 filename, "exodus", use_ll_edges, MPI_COMM_WORLD);
59
60 size_t local_size =
62
63 if (local_size != ((num_lon - 1) * (num_lat - 1)) / 4)
64 PUT_ERR("ERROR in yac_read_exodus_basic_grid_parallel");
65
66 yac_basic_grid_delete(exodus_grid);
67 }
68
69 // ensure that all tests are completed
70 MPI_Barrier(MPI_COMM_WORLD);
71
72 if (comm_rank == 0) unlink(filename);
73 }
74
75 {
76 char const filename[] = "test_read_exodus_parallel_grid.nc";
77 size_t num_lon = 271, num_lat = 181;
78 double lon_range[] = {0.0, 10.0}, lat_range[] = {80.0, 90.0};
79 if (comm_rank == 0)
80 utest_write_dummy_exodus_grid_file(
81 filename, num_lon, num_lat, lon_range, lat_range);
82
83 // ensure that the grid file exists
84 MPI_Barrier(MPI_COMM_WORLD);
85
86 {
87 int use_ll_edges = 1;
88 struct yac_basic_grid * exodus_grid =
90 filename, "exodus", use_ll_edges, MPI_COMM_WORLD);
91
92 size_t local_size =
94
95 if (local_size != ((num_lon - 1) * (num_lat - 1)) / 4)
96 PUT_ERR("ERROR in yac_read_exodus_basic_grid_parallel");
97
98 yac_basic_grid_delete(exodus_grid);
99 }
100
101 // ensure that all tests are completed
102 MPI_Barrier(MPI_COMM_WORLD);
103
104 if (comm_rank == 0) unlink(filename);
105 }
106
107 xt_finalize();
108 MPI_Finalize();
109
110 return TEST_EXIT_CODE;
111}
size_t yac_basic_grid_get_data_size(struct yac_basic_grid *grid, enum yac_location location)
Definition basic_grid.c:145
void yac_basic_grid_delete(struct yac_basic_grid *grid)
Definition basic_grid.c:77
@ YAC_LOC_CELL
Definition location.h:14
struct yac_basic_grid * yac_read_exodus_basic_grid_parallel(char const *filename, char const *gridname, int use_ll_edges, MPI_Comm comm)
#define TEST_EXIT_CODE
Definition tests.h:15
#define PUT_ERR(string)
Definition tests.h:10