YAC 3.13.0
Yet Another Coupler
Loading...
Searching...
No Matches
weight_file_common.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 <string.h>
6#include <math.h>
7#include <netcdf.h>
8
9#include "tests.h"
10#include "weight_file_common.h"
11#include "io_utils.h"
12#include "utils_common.h"
14
15void write_weight_file(char const * file_name, int const * src_id,
16 int const * tgt_id, double const * weights,
17 unsigned num_links,
18 enum yac_location const * src_locations,
19 unsigned num_src_fields,
20 int const * num_links_per_src_field,
21 int * tgt_id_fixed, unsigned num_fixed_tgt,
22 double * fixed_values,
23 int * num_tgt_per_fixed_value,
24 unsigned num_fixed_values,
25 enum yac_location tgt_location,
26 char const * src_grid_name,
27 char const * tgt_grid_name) {
28
29 int ncid;
30
31 // create file
32 yac_nc_create(file_name, NC_CLOBBER, &ncid);
33
34 int dim_weight_id[6];
35
36 // define dimensions
37 if (num_links > 0) {
38 YAC_HANDLE_ERROR(nc_def_dim(ncid, "num_links", num_links, &dim_weight_id[0]));
39 YAC_HANDLE_ERROR(nc_def_dim(ncid, "num_wgts", 1, &dim_weight_id[1]));
40 }
42 nc_def_dim(ncid, "num_src_fields", num_src_fields, &dim_weight_id[2]));
44 nc_def_dim(ncid, "max_loc_str_len", YAC_MAX_LOC_STR_LEN, &dim_weight_id[3]));
45 if (num_fixed_values > 0) {
47 nc_def_dim(ncid, "num_fixed_values", num_fixed_values, &dim_weight_id[4]));
49 nc_def_dim(ncid, "num_fixed_dst", num_fixed_tgt, &dim_weight_id[5]));
50 }
51
52 int var_src_add_id, var_dst_add_id, var_weight_id, var_num_links_id,
53 src_var_locs_id, tgt_var_loc_id, var_fixed_values_id,
54 var_num_dst_per_fixed_value_id, var_dst_add_fixed_id;
55
56 // define variables
57 if (num_links > 0) {
59 nc_def_var(
60 ncid, "src_address", NC_INT, 1, dim_weight_id, &var_src_add_id));
62 nc_def_var(
63 ncid, "dst_address", NC_INT, 1, dim_weight_id, &var_dst_add_id));
65 nc_def_var(
66 ncid, "remap_matrix", NC_DOUBLE, 2, dim_weight_id, &var_weight_id));
68 nc_def_var(
69 ncid, "num_links_per_src_field", NC_INT, 1, dim_weight_id + 2,
70 &var_num_links_id));
71 }
73 nc_def_var(
74 ncid, "src_locations", NC_CHAR, 2, &dim_weight_id[2], &src_var_locs_id));
76 nc_def_var(
77 ncid, "dst_location", NC_CHAR, 1, &dim_weight_id[3], &tgt_var_loc_id));
78 if (num_fixed_values > 0) {
80 nc_def_var(
81 ncid, "fixed_values", NC_DOUBLE, 1, &dim_weight_id[4],
82 &var_fixed_values_id));
84 nc_def_var(
85 ncid, "num_dst_per_fixed_value", NC_INT, 1, &dim_weight_id[4],
86 &var_num_dst_per_fixed_value_id));
88 nc_def_var(
89 ncid, "dst_address_fixed", NC_INT, 1, &dim_weight_id[5],
90 &var_dst_add_fixed_id));
91 }
92
93 // put attributes
94 YAC_HANDLE_ERROR(nc_put_att_text(ncid, NC_GLOBAL, "version",
97 YAC_HANDLE_ERROR(nc_put_att_text(ncid, NC_GLOBAL, "src_grid_name",
99 YAC_HANDLE_ERROR(nc_put_att_text(ncid, NC_GLOBAL, "dst_grid_name",
100 strlen(tgt_grid_name), tgt_grid_name));
101 {
102 char const * str_logical[2] = {"FALSE", "TRUE"};
103 YAC_HANDLE_ERROR(nc_put_att_text(ncid, NC_GLOBAL, "contains_fixed_dst",
104 strlen(str_logical[num_fixed_values > 0]),
105 str_logical[num_fixed_values > 0]));
106 YAC_HANDLE_ERROR(nc_put_att_text(ncid, NC_GLOBAL, "contains_links",
107 strlen(str_logical[num_links > 0]),
108 str_logical[num_links > 0]));
109 }
110
111 // end definition
112 YAC_HANDLE_ERROR(nc_enddef(ncid));
113
114 // write mapping data
115
116 if (num_links > 0) {
117 int * src_address = xmalloc(num_links * sizeof(*src_address));
118 int * tgt_address = xmalloc(num_links * sizeof(*tgt_address));
119
120 for (unsigned i = 0; i < num_links; i++) {
121 src_address[i] = src_id[i] + 1;
122 tgt_address[i] = tgt_id[i] + 1;
123 }
124
125 YAC_HANDLE_ERROR(nc_put_var_int(ncid, var_src_add_id, src_address));
126 YAC_HANDLE_ERROR(nc_put_var_int(ncid, var_dst_add_id, tgt_address));
127
128 free(src_address);
129 free(tgt_address);
130
131 YAC_HANDLE_ERROR(nc_put_var_double(ncid, var_weight_id, weights));
133 nc_put_var_int(ncid, var_num_links_id, num_links_per_src_field));
134 }
135
136 for (unsigned i = 0; i < num_src_fields; ++i) {
137 char const * loc_str = yac_loc2str(src_locations[i]);
138 size_t str_start[2] = {i, 0};
139 size_t str_count[2] = {1, strlen(loc_str)};
141 nc_put_vara_text(ncid, src_var_locs_id, str_start, str_count, loc_str));
142 }
143
144 {
145 char const * loc_str = yac_loc2str(tgt_location);
146 size_t str_start[1] = {0};
147 size_t str_count[1] = {strlen(loc_str)};
149 nc_put_vara_text(ncid, tgt_var_loc_id, str_start, str_count, loc_str));
150 }
151
152 if (num_fixed_values > 0) {
153
154 int * tgt_address_fixed =
155 xmalloc(num_fixed_tgt * sizeof(*tgt_address_fixed));
156 for (unsigned i = 0; i < num_fixed_tgt; i++)
157 tgt_address_fixed[i] = tgt_id_fixed[i] + 1;
158
159 YAC_HANDLE_ERROR(nc_put_var_int(ncid, var_dst_add_fixed_id, tgt_address_fixed));
160 YAC_HANDLE_ERROR(nc_put_var_double(ncid, var_fixed_values_id, fixed_values));
161 YAC_HANDLE_ERROR(nc_put_var_int(ncid, var_num_dst_per_fixed_value_id,
162 num_tgt_per_fixed_value));
163
164 free(tgt_address_fixed);
165 }
166
167 YAC_HANDLE_ERROR(nc_close(ncid));
168}
169
170void write_cdo_weight_file(char const * file_name, int const * src_id,
171 int const * tgt_id, double const * weights,
172 unsigned num_links,
173 char const * src_grid_name,
174 char const * tgt_grid_name) {
175
176 int ncid;
177
178 // create file
179 yac_nc_create(file_name, NC_CLOBBER, &ncid);
180
181 int dim_weight_id[6];
182
183 // define dimensions
184 YAC_HANDLE_ERROR(nc_def_dim(ncid, "num_links", num_links, &dim_weight_id[0]));
185 YAC_HANDLE_ERROR(nc_def_dim(ncid, "num_wgts", 1, &dim_weight_id[1]));
186
187 int var_src_add_id, var_dst_add_id, var_weight_id;
188
189 // define variables
191 nc_def_var(
192 ncid, "src_address", NC_INT, 1, dim_weight_id, &var_src_add_id));
194 nc_def_var(
195 ncid, "dst_address", NC_INT, 1, dim_weight_id, &var_dst_add_id));
197 nc_def_var(
198 ncid, "remap_matrix", NC_DOUBLE, 2, dim_weight_id, &var_weight_id));
199
200 // put attributes
201 char const title[] = "CDO remapping";
202 YAC_HANDLE_ERROR(nc_put_att_text(ncid, NC_GLOBAL, "title",
203 strlen(title), title));
204 YAC_HANDLE_ERROR(nc_put_att_text(ncid, NC_GLOBAL, "source_grid",
205 strlen(src_grid_name), src_grid_name));
206 YAC_HANDLE_ERROR(nc_put_att_text(ncid, NC_GLOBAL, "dest_grid",
207 strlen(tgt_grid_name), tgt_grid_name));
208
209 // end definition
210 YAC_HANDLE_ERROR(nc_enddef(ncid));
211
212 // write mapping data
213
214 int * src_address = xmalloc(num_links * sizeof(*src_address));
215 int * tgt_address = xmalloc(num_links * sizeof(*tgt_address));
216
217 for (unsigned i = 0; i < num_links; i++) {
218 src_address[i] = src_id[i] + 1;
219 tgt_address[i] = tgt_id[i] + 1;
220 }
221
222 YAC_HANDLE_ERROR(nc_put_var_int(ncid, var_src_add_id, src_address));
223 YAC_HANDLE_ERROR(nc_put_var_int(ncid, var_dst_add_id, tgt_address));
224
225 free(src_address);
226 free(tgt_address);
227
228 YAC_HANDLE_ERROR(nc_put_var_double(ncid, var_weight_id, weights));
229
230 YAC_HANDLE_ERROR(nc_close(ncid));
231}
232
233void check_weight_file(char const * file_name, int const * ref_src_address,
234 int const * ref_tgt_address, double const * ref_weights,
235 unsigned ref_num_links,
236 enum yac_location const * ref_src_locations,
237 unsigned ref_num_src_fields,
238 int const * ref_num_links_per_src_field,
239 int const * ref_tgt_address_fixed,
240 double const * ref_fixed_values,
241 int const * ref_num_tgt_per_fixed_value,
242 unsigned ref_num_fixed_values,
243 enum yac_location ref_tgt_location,
244 char const * ref_src_grid_name,
245 char const * ref_tgt_grid_name) {
246
247 int ncid;
248
249 // open file
250 yac_nc_open(file_name, NC_NOWRITE, &ncid);
251
252 int dimid, var_id;
253 size_t num_wgts;
254 yac_nc_inq_dimid(ncid, "num_wgts", &dimid);
255 YAC_HANDLE_ERROR(nc_inq_dimlen(ncid, dimid, &num_wgts));
257 num_wgts == 1, "ERROR(check_weight_file): test only supports num_wgts == 1")
258
259 // global attributes
260 size_t str_version_len;
261 char * str_version;
262 var_id = NC_GLOBAL;
263 YAC_HANDLE_ERROR(nc_inq_attlen(ncid, var_id, "version", &str_version_len));
264 str_version = xmalloc(str_version_len + 1);
265 str_version[str_version_len] = '\0';
266 YAC_HANDLE_ERROR(nc_get_att_text(ncid, var_id, "version", str_version));
267
268 size_t str_fixed_len;
269 char * str_fixed;
271 nc_inq_attlen(ncid, var_id, "contains_fixed_dst", &str_fixed_len));
272 str_fixed = xmalloc(str_fixed_len + 1);
273 str_fixed[str_fixed_len] = '\0';
274 YAC_HANDLE_ERROR(nc_get_att_text(ncid, var_id, "contains_fixed_dst", str_fixed));
275
276 unsigned contains_fixed_dst =
277 ((strlen("TRUE") == str_fixed_len) &&
278 !strncmp("TRUE", str_fixed, str_fixed_len));
280 contains_fixed_dst ||
281 ((strlen("FALSE") == str_fixed_len) &&
282 !strncmp("FALSE", str_fixed, str_fixed_len)),
283 "ERROR(check_weight_file): invalid global attribute contains_fixed_dst")
284
286 size_t src_grid_name_len = 0, tgt_grid_name_len = 0;
287 var_id = NC_GLOBAL;
288 YAC_HANDLE_ERROR(nc_inq_attlen(ncid, var_id, "src_grid_name", &src_grid_name_len));
289 src_grid_name = xmalloc(src_grid_name_len + 1);
290 src_grid_name[src_grid_name_len] = '\0';
291 YAC_HANDLE_ERROR(nc_get_att_text(ncid, var_id, "src_grid_name", src_grid_name));
292
293 YAC_HANDLE_ERROR(nc_inq_attlen(ncid, var_id, "dst_grid_name", &tgt_grid_name_len));
294 tgt_grid_name = xmalloc(tgt_grid_name_len + 1);
295 tgt_grid_name[tgt_grid_name_len] = '\0';
296 YAC_HANDLE_ERROR(nc_get_att_text(ncid, var_id, "dst_grid_name", tgt_grid_name));
297
298 size_t str_link_len;
299 char * str_link;
300 var_id = NC_GLOBAL;
301 YAC_HANDLE_ERROR(nc_inq_attlen(ncid, var_id, "contains_links", &str_link_len));
302 str_link = xmalloc(str_link_len + 1);
303 str_link[str_link_len] = '\0';
304 YAC_HANDLE_ERROR(nc_get_att_text(ncid, var_id, "contains_links", str_link));
305
306 unsigned contains_links =
307 (strlen("TRUE") == str_link_len) &&
308 !strncmp("TRUE", str_link, str_link_len);
310 contains_links ||
311 ((strlen("FALSE") == str_link_len) &&
312 !strncmp("FALSE", str_link, str_link_len)),
313 "ERROR(check_weight_file): invalid global attribute contains_links")
314 free(str_link);
315
316 // get number of links from file
317 size_t num_links = 0;
318 if (contains_links) {
319 yac_nc_inq_dimid(ncid, "num_links", &dimid);
320 YAC_HANDLE_ERROR(nc_inq_dimlen(ncid, dimid, &num_links));
321 YAC_ASSERT(num_links != 0, "ERROR(check_weight_file): no links defined")
322 }
323 if (ref_num_links != num_links)
324 PUT_ERR("wrong number of links in weight file\n");
325
326 // get number of source fields from file
327 size_t num_src_fields = 0;
328 if (contains_links) {
329 yac_nc_inq_dimid(ncid, "num_src_fields", &dimid);
330 YAC_HANDLE_ERROR(nc_inq_dimlen(ncid, dimid, &num_src_fields));
332 num_src_fields != 0, "ERROR(check_weight_file): no source fields")
333 if (ref_num_src_fields != num_src_fields)
334 PUT_ERR("wrong number of source fields in weight file\n");
335 }
336
337 // get max location string length from file
338 size_t max_loc_str_len;
339 yac_nc_inq_dimid(ncid, "max_loc_str_len", &dimid);
340 YAC_HANDLE_ERROR(nc_inq_dimlen(ncid, dimid, &max_loc_str_len));
342 max_loc_str_len == YAC_MAX_LOC_STR_LEN,
343 "ERROR(check_weight_file): wrong max location string length")
344
345 size_t num_fixed_values = 0;
346 size_t num_fixed_tgt = 0;
347 if (contains_fixed_dst) {
348
349 // get number of fixed values
350 yac_nc_inq_dimid(ncid, "num_fixed_values", &dimid);
351 YAC_HANDLE_ERROR(nc_inq_dimlen(ncid, dimid, &num_fixed_values));
352
353 // get number for fixed target points
354 yac_nc_inq_dimid(ncid, "num_fixed_dst", &dimid);
355 YAC_HANDLE_ERROR(nc_inq_dimlen(ncid, dimid, &num_fixed_tgt));
356 }
357
358 int * src_address = xmalloc(num_links * sizeof(*src_address));
359 int * tgt_address = xmalloc(num_links * sizeof(*tgt_address));
360 double * weights = xmalloc(num_links * sizeof(*weights));
361 int * num_links_per_src_field =
362 xmalloc(num_src_fields * sizeof(*num_links_per_src_field));
363 enum yac_location * src_locations =
364 xmalloc(num_src_fields * sizeof(*src_locations));
365 enum yac_location tgt_location;
366 double * fixed_values = xmalloc(num_fixed_values * sizeof(*fixed_values));
367 int * num_tgt_per_fixed_value =
368 xmalloc(num_fixed_values * sizeof(*num_tgt_per_fixed_value));
369 int * tgt_address_fixed = xmalloc(num_fixed_tgt * sizeof(*tgt_address_fixed));
370
371 // read data
372 if (contains_links) {
373 yac_nc_inq_varid(ncid, "src_address", &var_id);
374 YAC_HANDLE_ERROR(nc_get_var_int(ncid, var_id, src_address));
375
376 yac_nc_inq_varid(ncid, "dst_address", &var_id);
377 YAC_HANDLE_ERROR(nc_get_var_int(ncid, var_id, tgt_address));
378
379 yac_nc_inq_varid(ncid, "remap_matrix", &var_id);
380 YAC_HANDLE_ERROR(nc_get_var_double(ncid, var_id, weights));
381
382 yac_nc_inq_varid(ncid, "num_links_per_src_field", &var_id);
383 YAC_HANDLE_ERROR(nc_get_var_int(ncid, var_id, num_links_per_src_field));
384 }
385
386 yac_nc_inq_varid(ncid, "src_locations", &var_id);
387 for (unsigned i = 0; i < num_src_fields; ++i) {
388 char loc_str[YAC_MAX_LOC_STR_LEN];
389 size_t str_start[2] = {i, 0};
390 size_t str_count[2] = {1, YAC_MAX_LOC_STR_LEN};
391 YAC_HANDLE_ERROR(nc_get_vara_text(ncid, var_id, str_start, str_count, loc_str));
392 src_locations[i] = yac_str2loc(loc_str);
393 }
394
395 yac_nc_inq_varid(ncid, "dst_location", &var_id);
396 {
397 char loc_str[YAC_MAX_LOC_STR_LEN];
398 YAC_HANDLE_ERROR(nc_get_var_text(ncid, var_id, loc_str));
399 tgt_location = yac_str2loc(loc_str);
400 }
401
402 if (contains_fixed_dst) {
403
404 yac_nc_inq_varid(ncid, "fixed_values", &var_id);
405 YAC_HANDLE_ERROR(nc_get_var_double(ncid, var_id, fixed_values));
406
407 yac_nc_inq_varid(ncid, "num_dst_per_fixed_value", &var_id);
408 YAC_HANDLE_ERROR(nc_get_var_int(ncid, var_id, num_tgt_per_fixed_value));
409
410 yac_nc_inq_varid(ncid, "dst_address_fixed", &var_id);
411 YAC_HANDLE_ERROR(nc_get_var_int(ncid, var_id, tgt_address_fixed));
412 }
413
414 // check data
415 if ((strlen(YAC_WEIGHT_FILE_VERSION_STRING) != str_version_len) ||
416 strncmp(YAC_WEIGHT_FILE_VERSION_STRING, str_version, str_version_len))
417 PUT_ERR("wrong version string\n");
418 if ((strlen(ref_src_grid_name) != src_grid_name_len) ||
419 strncmp(ref_src_grid_name, src_grid_name, src_grid_name_len))
420 PUT_ERR("wrong src_grid_name\n");
421 if ((strlen(ref_tgt_grid_name) != tgt_grid_name_len) ||
422 strncmp(ref_tgt_grid_name, tgt_grid_name, tgt_grid_name_len))
423 PUT_ERR("wrong tgt_grid_name\n");
424
425 if (contains_links != (ref_num_links > 0)) {
426 PUT_ERR("file contains links, but reference data does not\n");
427 } else if (contains_links) {
428 for (unsigned i = 0; i < MIN(num_links, ref_num_links); ++i)
429 if (ref_src_address[i] != src_address[i] - 1)
430 PUT_ERR("wrong src_address\n");
431 if ((strlen(ref_src_grid_name) != src_grid_name_len) ||
432 strncmp(ref_src_grid_name, src_grid_name, src_grid_name_len))
433 PUT_ERR("wrong src_grid_name\n");
434 for (unsigned i = 0; i < MIN(num_links, ref_num_links); ++i)
435 if (ref_tgt_address[i] != tgt_address[i] - 1)
436 PUT_ERR("wrong tgt_address\n");
437 if ((strlen(ref_tgt_grid_name) != tgt_grid_name_len) ||
438 strncmp(ref_tgt_grid_name, tgt_grid_name, tgt_grid_name_len))
439 PUT_ERR("wrong src_grid_name\n");
440 for (unsigned i = 0; i < MIN(num_links, ref_num_links); ++i)
441 if (fabs(ref_weights[i] - weights[i]) > 1e-10)
442 PUT_ERR("wrong weight\n");
443 for (unsigned i = 0; i < MIN(num_src_fields, ref_num_src_fields); ++i)
444 if (ref_num_links_per_src_field[i] != num_links_per_src_field[i])
445 PUT_ERR("wrong number of links per source field\n");
446 }
447 for (unsigned i = 0; i < MIN(num_src_fields, ref_num_src_fields); ++i)
448 if (ref_src_locations[i] != src_locations[i])
449 PUT_ERR("wrong source location\n");
450 if (ref_tgt_location != tgt_location) PUT_ERR("wrong target location\n");
451
452 if (contains_fixed_dst != (ref_num_fixed_values > 0)) {
453 PUT_ERR("file contains fixed target data, but reference data does not\n");
454 } else if (contains_fixed_dst) {
455 if (ref_num_fixed_values != num_fixed_values) {
456 PUT_ERR("wrong number of fixed values\n");
457 } else {
458 unsigned * used_flag = xcalloc(num_fixed_values, sizeof(*used_flag));
459 unsigned match_count = 0;
460 for (unsigned i = 0, ref_offset = 0; i < ref_num_fixed_values;
461 ref_offset += ref_num_tgt_per_fixed_value[i++]) {
462 for (unsigned j = 0, offset = 0; j < num_fixed_values;
463 offset += num_tgt_per_fixed_value[j++]) {
464 if ((!used_flag[j]) &&
465 !(fabs(ref_fixed_values[i] - fixed_values[j]) > 0.0) &&
466 (ref_num_tgt_per_fixed_value[i] == num_tgt_per_fixed_value[j])) {
467
468 for (int k = 0; k < num_tgt_per_fixed_value[j]; ++k) {
469 if (ref_tgt_address_fixed[ref_offset + k] !=
470 tgt_address_fixed[offset + k] - 1)
471 PUT_ERR("wrong fixed target address\n");
472 }
473
474 used_flag[j] = 1;
475 match_count++;
476 break;
477 }
478 }
479 }
480 if (match_count != ref_num_fixed_values)
481 PUT_ERR("wrong fixed values data");
482 free(used_flag);
483 }
484 }
485
486 // clean up
487 free(str_version);
488 free(fixed_values);
489 free(num_tgt_per_fixed_value);
490 free(tgt_address_fixed);
491 free(src_grid_name);
492 free(tgt_grid_name);
493 free(src_address);
494 free(tgt_address);
495 free(weights);
496 free(num_links_per_src_field);
497 free(src_locations);
498 free(str_fixed);
499
500 // close file
501 YAC_HANDLE_ERROR(nc_close(ncid));
502}
char const * file_name
#define YAC_ASSERT(exp, msg)
#define YAC_WEIGHT_FILE_VERSION_STRING
void yac_nc_create(const char *path, int cmode, int *ncidp)
Definition io_utils.c:367
void yac_nc_inq_varid(int ncid, char const *name, int *varidp)
Definition io_utils.c:411
void yac_nc_open(const char *path, int omode, int *ncidp)
Definition io_utils.c:350
void yac_nc_inq_dimid(int ncid, char const *name, int *dimidp)
Definition io_utils.c:385
enum yac_location yac_str2loc(char const *location_str)
Definition location.c:22
char const * yac_loc2str(enum yac_location location)
Definition location.c:33
yac_location
Definition location.h:12
#define YAC_MAX_LOC_STR_LEN
Definition location.h:10
#define xcalloc(nmemb, size)
Definition ppm_xfuncs.h:64
#define xmalloc(size)
Definition ppm_xfuncs.h:66
char * str_logical[2]
char const src_grid_name[]
char const tgt_grid_name[]
unsigned ref_num_links
int const * ref_tgt_address_fixed
unsigned ref_num_fixed_values
int ref_src_address[4 *36]
double ref_weights[4 *36]
int const * ref_num_tgt_per_fixed_value
double const * ref_fixed_values
int ref_tgt_address[4 *36]
#define PUT_ERR(string)
Definition tests.h:10
#define MIN(a, b)
Definition toy_common.h:29
#define YAC_HANDLE_ERROR(exp)
Definition toy_output.c:13
void write_cdo_weight_file(char const *file_name, int const *src_id, int const *tgt_id, double const *weights, unsigned num_links, char const *src_grid_name, char const *tgt_grid_name)
void check_weight_file(char const *file_name, int const *ref_src_address, int const *ref_tgt_address, double const *ref_weights, unsigned ref_num_links, enum yac_location const *ref_src_locations, unsigned ref_num_src_fields, int const *ref_num_links_per_src_field, int const *ref_tgt_address_fixed, double const *ref_fixed_values, int const *ref_num_tgt_per_fixed_value, unsigned ref_num_fixed_values, enum yac_location ref_tgt_location, char const *ref_src_grid_name, char const *ref_tgt_grid_name)
void write_weight_file(char const *file_name, int const *src_id, int const *tgt_id, double const *weights, unsigned num_links, enum yac_location const *src_locations, unsigned num_src_fields, int const *num_links_per_src_field, int *tgt_id_fixed, unsigned num_fixed_tgt, double *fixed_values, int *num_tgt_per_fixed_value, unsigned num_fixed_values, enum yac_location tgt_location, char const *src_grid_name, char const *tgt_grid_name)