FrontISTR  5.8.0
Large-scale structural analysis program with finit element method
hecmw_dist_copy_c2f.c
Go to the documentation of this file.
1 /*****************************************************************************
2  * Copyright (c) 2019 FrontISTR Commons
3  * This software is released under the MIT License, see LICENSE.txt
4  *****************************************************************************/
5 
6 #include <stdio.h>
7 #include <stdlib.h>
8 #include <limits.h>
9 #include "hecmw_struct.h"
10 #include "hecmw_util.h"
11 #include "hecmw_dist_free.h"
12 #include "hecmw_io_get_mesh.h"
13 #include "hecmw_dist_copy_c2f.h"
14 
15 static struct hecmwST_local_mesh *mesh;
16 
17 /*-----------------------------------------------------------------------------
18  * Generic conversion utilities
19  */
20 static int convert_longlong_to_int_ary(const long long *src, int *dst,
21  size_t n, const char *name) {
22  size_t i;
23 
24  for (i = 0; i < n; i++) {
25  if (src[i] > INT_MAX || src[i] < INT_MIN) {
27  "mesh copy(C->Fortran): %s[%zu]=%lld exceeds INT range",
28  name ? name : "array", i, src[i]);
29  return -1;
30  }
31  dst[i] = (int)src[i];
32  }
33 
34  return 0;
35 }
36 
37 /*-----------------------------------------------------------------------------
38  * SetFunc
39  */
40 
41 static int set_hecmw_flag_adapt(void *dst) {
42  void *src;
43  int size;
44 
45  src = &mesh->hecmw_flag_adapt;
46  size = sizeof(mesh->hecmw_flag_adapt);
47  memcpy(dst, src, size);
48 
49  return 0;
50 }
51 
52 static int set_hecmw_flag_initcon(void *dst) {
53  void *src;
54  int size;
55 
56  src = &mesh->hecmw_flag_initcon;
57  size = sizeof(mesh->hecmw_flag_initcon);
58  memcpy(dst, src, size);
59 
60  return 0;
61 }
62 
63 static int set_hecmw_flag_parttype(void *dst) {
64  void *src;
65  int size;
66 
67  src = &mesh->hecmw_flag_parttype;
68  size = sizeof(mesh->hecmw_flag_parttype);
69  memcpy(dst, src, size);
70 
71  return 0;
72 }
73 
74 static int set_hecmw_flag_partdepth(void *dst) {
75  void *src;
76  int size;
77 
78  src = &mesh->hecmw_flag_partdepth;
79  size = sizeof(mesh->hecmw_flag_partdepth);
80  memcpy(dst, src, size);
81  return 0;
82 }
83 
84 static int set_hecmw_flag_version(void *dst) {
85  void *src;
86  int size;
87 
88  src = &mesh->hecmw_flag_version;
89  size = sizeof(mesh->hecmw_flag_version);
90  memcpy(dst, src, size);
91 
92  return 0;
93 }
94 
95 static int set_hecmw_flag_partcontact(void *dst) {
96  void *src;
97  int size;
98 
99  src = &mesh->hecmw_flag_partcontact;
100  size = sizeof(mesh->hecmw_flag_partcontact);
101  memcpy(dst, src, size);
102 
103  return 0;
104 }
105 
106 static int set_gridfile(void *dst) {
107  void *src;
108 
109  src = mesh->gridfile;
111 
112  return 0;
113 }
114 
115 static int set_hecmw_n_file(void *dst) {
116  void *src;
117  int size;
118 
119  src = &mesh->hecmw_n_file;
120  size = sizeof(mesh->hecmw_n_file);
121  memcpy(dst, src, size);
122 
123  return 0;
124 }
125 
126 static int set_files(void *dst) {
127  int i;
128 
129  if (mesh->hecmw_n_file <= 0) return 0;
130 
131  for (i = 0; i < mesh->hecmw_n_file; i++) {
132  char *dst_point = (char *)dst + HECMW_FILENAME_LEN * i;
133  char *src = mesh->files[i];
134  HECMW_strcpy_c2f(src, dst_point, HECMW_FILENAME_LEN);
135  }
136 
137  return 0;
138 }
139 
140 static int set_header(void *dst) {
141  void *src;
142 
143  src = mesh->header;
145 
146  return 0;
147 }
148 
149 static int set_zero_temp(void *dst) {
150  void *src;
151  int size;
152 
153  src = &mesh->zero_temp;
154  size = sizeof(mesh->zero_temp);
155  memcpy(dst, src, size);
156 
157  return 0;
158 }
159 
160 static int set_n_node(void *dst) {
161  void *src;
162  int size;
163 
164  src = &mesh->n_node;
165  size = sizeof(mesh->n_node);
166  memcpy(dst, src, size);
167 
168  return 0;
169 }
170 
171 static int set_n_node_gross(void *dst) {
172  void *src;
173  int size;
174 
175  src = &mesh->n_node_gross;
176  size = sizeof(mesh->n_node_gross);
177  memcpy(dst, src, size);
178 
179  return 0;
180 }
181 
182 static int set_nn_middle(void *dst) {
183  void *src;
184  int size;
185 
186  src = &mesh->nn_middle;
187  size = sizeof(mesh->nn_middle);
188  memcpy(dst, src, size);
189 
190  return 0;
191 }
192 
193 static int set_nn_internal(void *dst) {
194  void *src;
195  int size;
196 
197  src = &mesh->nn_internal;
198  size = sizeof(mesh->nn_internal);
199  memcpy(dst, src, size);
200 
201  return 0;
202 }
203 
204 static int set_node_internal_list(void *dst) {
205  void *src;
206  int size;
207 
208  if (mesh->nn_internal <= 0) return 0;
209 
210  src = mesh->node_internal_list;
211  size = sizeof(*mesh->node_internal_list) * mesh->nn_internal;
212  memcpy(dst, src, size);
213 
214  return 0;
215 }
216 
217 static int set_node_ID(void *dst) {
218  void *src;
219  int size;
220 
221  if (mesh->n_node_gross <= 0) return 0;
222 
223  src = mesh->node_ID;
224  size = sizeof(*mesh->node_ID) * mesh->n_node_gross * 2;
225  memcpy(dst, src, size);
226 
227  return 0;
228 }
229 
230 static int set_global_node_ID(void *dst) {
231  void *src;
232  int size;
233 
234  if (mesh->n_node_gross <= 0) return 0;
235 
236  src = mesh->global_node_ID;
237  size = sizeof(*mesh->global_node_ID) * mesh->n_node_gross;
238  memcpy(dst, src, size);
239 
240  return 0;
241 }
242 
243 static int set_node(void *dst) {
244  void *src;
245  int size;
246 
247  if (mesh->n_node_gross <= 0) return 0;
248 
249  src = mesh->node;
250  size = sizeof(*mesh->node) * mesh->n_node_gross * 3;
251  memcpy(dst, src, size);
252 
253  return 0;
254 }
255 
256 static int set_n_dof(void *dst) {
257  void *src;
258  int size;
259 
260  src = &mesh->n_dof;
261  size = sizeof(mesh->n_dof);
262  memcpy(dst, src, size);
263 
264  return 0;
265 }
266 
267 static int set_n_dof_grp(void *dst) {
268  void *src;
269  int size;
270 
271  src = &mesh->n_dof_grp;
272  size = sizeof(mesh->n_dof_grp);
273  memcpy(dst, src, size);
274 
275  return 0;
276 }
277 
278 static int set_n_dof_tot(void *dst) {
279  void *src;
280  int size;
281 
282  src = &mesh->n_dof_tot;
283  size = sizeof(mesh->n_dof_tot);
284  memcpy(dst, src, size);
285 
286  return 0;
287 }
288 
289 static int set_node_dof_index(void *dst) {
290  void *src;
291  int size;
292 
293  if (mesh->n_dof_grp <= 0) return 0;
294 
295  src = mesh->node_dof_index;
296  size = sizeof(*mesh->node_dof_index) * (mesh->n_dof_grp + 1);
297  memcpy(dst, src, size);
298 
299  return 0;
300 }
301 
302 static int set_node_dof_item(void *dst) {
303  void *src;
304  int size;
305 
306  if (mesh->n_dof_grp <= 0) return 0;
307 
308  src = mesh->node_dof_item;
309  size = sizeof(*mesh->node_dof_item) * mesh->n_dof_grp;
310  memcpy(dst, src, size);
311 
312  return 0;
313 }
314 
315 static int set_node_val_index(void *dst) {
316  void *src;
317  int size;
318 
319  if (mesh->n_node_gross <= 0) return 0;
320 
321  src = mesh->node_val_index;
322  size = sizeof(*mesh->node_val_index) * (mesh->n_node_gross + 1);
323  memcpy(dst, src, size);
324 
325  return 0;
326 }
327 
328 static int set_node_val_item(void *dst) {
329  void *src;
330  int size;
331 
332  if (mesh->n_node_gross <= 0) return 0;
333 
334  src = mesh->node_val_item;
335  size =
336  sizeof(*mesh->node_val_item) * mesh->node_val_index[mesh->n_node_gross];
337  memcpy(dst, src, size);
338 
339  return 0;
340 }
341 
342 static int set_node_init_val_index(void *dst) {
343  void *src;
344  int size;
345 
346  if (mesh->n_node_gross <= 0) return 0;
347 
348  src = mesh->node_init_val_index;
349  size = sizeof(*mesh->node_init_val_index) * (mesh->n_node_gross + 1);
350  memcpy(dst, src, size);
351 
352  return 0;
353 }
354 
355 static int set_node_init_val_item(void *dst) {
356  void *src;
357  int size;
358 
359  if (mesh->n_node_gross <= 0) return 0;
360 
361  src = mesh->node_init_val_item;
362  size = sizeof(*mesh->node_init_val_item) *
363  mesh->node_init_val_index[mesh->n_node_gross];
364  memcpy(dst, src, size);
365 
366  return 0;
367 }
368 
369 static int set_n_elem(void *dst) {
370  void *src;
371  int size;
372 
373  src = &mesh->n_elem;
374  size = sizeof(mesh->n_elem);
375  memcpy(dst, src, size);
376 
377  return 0;
378 }
379 
380 static int set_n_elem_gross(void *dst) {
381  void *src;
382  int size;
383 
384  src = &mesh->n_elem_gross;
385  size = sizeof(mesh->n_elem_gross);
386  memcpy(dst, src, size);
387 
388  return 0;
389 }
390 
391 static int set_ne_internal(void *dst) {
392  void *src;
393  int size;
394 
395  src = &mesh->ne_internal;
396  size = sizeof(mesh->ne_internal);
397  memcpy(dst, src, size);
398 
399  return 0;
400 }
401 
402 static int set_elem_internal_list(void *dst) {
403  void *src;
404  int size;
405 
406  if (mesh->ne_internal <= 0) return 0;
407 
408  src = mesh->elem_internal_list;
409  size = sizeof(*mesh->elem_internal_list) * mesh->ne_internal;
410  memcpy(dst, src, size);
411 
412  return 0;
413 }
414 
415 static int set_elem_ID(void *dst) {
416  void *src;
417  int size;
418 
419  if (mesh->n_elem_gross <= 0) return 0;
420 
421  src = mesh->elem_ID;
422  size = sizeof(*mesh->elem_ID) * mesh->n_elem_gross * 2;
423  memcpy(dst, src, size);
424 
425  return 0;
426 }
427 
428 static int set_global_elem_ID(void *dst) {
429  void *src;
430  int size;
431 
432  if (mesh->n_elem_gross <= 0) return 0;
433 
434  src = mesh->global_elem_ID;
435  size = sizeof(*mesh->global_elem_ID) * mesh->n_elem_gross;
436  memcpy(dst, src, size);
437 
438  return 0;
439 }
440 
441 static int set_elem_type(void *dst) {
442  void *src;
443  int size;
444 
445  if (mesh->n_elem_gross <= 0) return 0;
446 
447  src = mesh->elem_type;
448  size = sizeof(*mesh->elem_type) * mesh->n_elem_gross;
449  memcpy(dst, src, size);
450 
451  return 0;
452 }
453 
454 static int set_n_elem_type(void *dst) {
455  void *src;
456  int size;
457 
458  src = &mesh->n_elem_type;
459  size = sizeof(mesh->n_elem_type);
460  memcpy(dst, src, size);
461 
462  return 0;
463 }
464 
465 static int set_elem_type_index(void *dst) {
466  void *src;
467  int size;
468 
469  if (mesh->n_elem_type <= 0) return 0;
470 
471  src = mesh->elem_type_index;
472  size = sizeof(*mesh->elem_type_index) * (mesh->n_elem_type + 1);
473  memcpy(dst, src, size);
474 
475  return 0;
476 }
477 
478 static int set_elem_type_item(void *dst) {
479  void *src;
480  int size;
481 
482  if (mesh->n_elem_type <= 0) return 0;
483 
484  src = mesh->elem_type_item;
485  size = sizeof(*mesh->elem_type_item) * mesh->n_elem_type;
486  memcpy(dst, src, size);
487 
488  return 0;
489 }
490 
491 static int set_elem_node_index(void *dst) {
492  int *dst_int = (int *)dst;
493 
494  if (mesh->n_elem_gross <= 0) return 0;
495 
496  /* Convert long long array to int array with overflow check */
497  if (convert_longlong_to_int_ary(mesh->elem_node_index, dst_int,
498  mesh->n_elem_gross + 1,
499  "elem_node_index") != 0) {
500  return -1;
501  }
502 
503  return 0;
504 }
505 
506 static int set_elem_node_item(void *dst) {
507  void *src;
508  int size;
509 
510  if (mesh->n_elem_gross <= 0) return 0;
511 
512  src = mesh->elem_node_item;
513  size =
514  sizeof(*mesh->elem_node_item) * mesh->elem_node_index[mesh->n_elem_gross];
515  memcpy(dst, src, size);
516 
517  return 0;
518 }
519 
520 static int set_section_ID(void *dst) {
521  void *src;
522  int size;
523 
524  if (mesh->n_elem_gross <= 0) return 0;
525 
526  src = mesh->section_ID;
527  size = sizeof(*mesh->section_ID) * mesh->n_elem_gross;
528  memcpy(dst, src, size);
529 
530  return 0;
531 }
532 
533 static int set_n_elem_mat_ID(void *dst) {
534  void *src;
535  int size;
536 
537  src = &mesh->n_elem_mat_ID;
538  size = sizeof(mesh->n_elem_mat_ID);
539  memcpy(dst, src, size);
540 
541  return 0;
542 }
543 
544 static int set_elem_mat_ID_index(void *dst) {
545  void *src;
546  int size;
547 
548  if (mesh->n_elem_gross <= 0) return 0;
549 
550  src = mesh->elem_mat_ID_index;
551  size = sizeof(*mesh->elem_mat_ID_index) * (mesh->n_elem_gross + 1);
552  memcpy(dst, src, size);
553 
554  return 0;
555 }
556 
557 static int set_elem_mat_ID_item(void *dst) {
558  void *src;
559  int size;
560 
561  if (mesh->n_elem_gross <= 0) return 0;
562 
563  src = mesh->elem_mat_ID_item;
564  size = sizeof(*mesh->elem_mat_ID_item) *
565  mesh->elem_mat_ID_index[mesh->n_elem_gross];
566  memcpy(dst, src, size);
567 
568  return 0;
569 }
570 
571 static int set_elem_mat_int_index(void *dst) {
572  void *src;
573  int size;
574 
575  if (mesh->n_elem_mat_ID <= 0) return 0;
576 
577  src = mesh->elem_mat_int_index;
578  size = sizeof(*mesh->elem_mat_int_index) * (mesh->n_elem_mat_ID + 1);
579  memcpy(dst, src, size);
580 
581  return 0;
582 }
583 
584 static int set_elem_mat_int_val(void *dst) {
585  void *src;
586  int size;
587 
588  if (mesh->n_elem_mat_ID <= 0) return 0;
589 
590  src = mesh->elem_mat_ID_item;
591  size = sizeof(*mesh->elem_mat_int_val) *
592  mesh->elem_mat_int_index[mesh->n_elem_mat_ID];
593  memcpy(dst, src, size);
594 
595  return 0;
596 }
597 
598 static int set_elem_val_index(void *dst) {
599  void *src;
600  int size;
601 
602  if (mesh->n_elem_gross <= 0) return 0;
603 
604  src = mesh->elem_val_index;
605  size = sizeof(*mesh->elem_val_index) * (mesh->n_elem_gross + 1);
606  memcpy(dst, src, size);
607 
608  return 0;
609 }
610 
611 static int set_elem_val_item(void *dst) {
612  void *src;
613  int size;
614 
615  if (mesh->n_elem_gross <= 0) return 0;
616 
617  src = mesh->elem_val_item;
618  size =
619  sizeof(*mesh->elem_val_item) * mesh->elem_val_index[mesh->n_elem_gross];
620  memcpy(dst, src, size);
621 
622  return 0;
623 }
624 
625 static int set_zero(void *dst) {
626  void *src;
627  int size;
628 
629  src = &mesh->zero;
630  size = sizeof(mesh->zero);
631  memcpy(dst, src, size);
632 
633  return 0;
634 }
635 
636 static int set_HECMW_COMM(void *dst) {
637  HECMW_Fint comm;
638  void *src;
639  int size;
640 
641  comm = HECMW_Comm_c2f(mesh->HECMW_COMM);
642  src = &comm;
643  size = sizeof(comm);
644  memcpy(dst, src, size);
645 
646  return 0;
647 }
648 
649 static int set_PETOT(void *dst) {
650  void *src;
651  int size;
652 
653  src = &mesh->PETOT;
654  size = sizeof(mesh->PETOT);
655  memcpy(dst, src, size);
656 
657  return 0;
658 }
659 
660 static int set_PEsmpTOT(void *dst) {
661  void *src;
662  int size;
663 
664  src = &mesh->PEsmpTOT;
665  size = sizeof(mesh->PEsmpTOT);
666  memcpy(dst, src, size);
667 
668  return 0;
669 }
670 
671 static int set_my_rank(void *dst) {
672  void *src;
673  int size;
674 
675  src = &mesh->my_rank;
676  size = sizeof(mesh->my_rank);
677  memcpy(dst, src, size);
678 
679  return 0;
680 }
681 
682 static int set_errnof(void *dst) {
683  void *src;
684  int size;
685 
686  src = &mesh->errnof;
687  size = sizeof(mesh->errnof);
688  memcpy(dst, src, size);
689 
690  return 0;
691 }
692 
693 static int set_n_subdomain(void *dst) {
694  void *src;
695  int size;
696 
697  src = &mesh->n_subdomain;
698  size = sizeof(mesh->n_subdomain);
699  memcpy(dst, src, size);
700 
701  return 0;
702 }
703 
704 static int set_n_neighbor_pe(void *dst) {
705  void *src;
706  int size;
707 
708  src = &mesh->n_neighbor_pe;
709  size = sizeof(mesh->n_neighbor_pe);
710  memcpy(dst, src, size);
711 
712  return 0;
713 }
714 
715 static int set_neighbor_pe(void *dst) {
716  void *src;
717  int size;
718 
719  if (mesh->n_neighbor_pe <= 0) return 0;
720 
721  src = mesh->neighbor_pe;
722  size = sizeof(*mesh->neighbor_pe) * mesh->n_neighbor_pe;
723  memcpy(dst, src, size);
724 
725  return 0;
726 }
727 
728 static int set_import_index(void *dst) {
729  void *src;
730  int size;
731 
732  if (mesh->n_neighbor_pe <= 0) return 0;
733 
734  src = mesh->import_index;
735  size = sizeof(*mesh->import_index) * (mesh->n_neighbor_pe + 1);
736  memcpy(dst, src, size);
737 
738  return 0;
739 }
740 
741 static int set_import_item(void *dst) {
742  void *src;
743  int size;
744 
745  if (mesh->n_neighbor_pe <= 0) return 0;
746 
747  src = mesh->import_item;
748  size = sizeof(*mesh->import_item) * mesh->import_index[mesh->n_neighbor_pe];
749  memcpy(dst, src, size);
750 
751  return 0;
752 }
753 
754 static int set_export_index(void *dst) {
755  void *src;
756  int size;
757 
758  if (mesh->n_neighbor_pe <= 0) return 0;
759 
760  src = mesh->export_index;
761  size = sizeof(*mesh->export_index) * (mesh->n_neighbor_pe + 1);
762  memcpy(dst, src, size);
763 
764  return 0;
765 }
766 
767 static int set_export_item(void *dst) {
768  void *src;
769  int size;
770 
771  if (mesh->n_neighbor_pe <= 0) return 0;
772 
773  src = mesh->export_item;
774  size = sizeof(*mesh->export_item) * mesh->export_index[mesh->n_neighbor_pe];
775  memcpy(dst, src, size);
776 
777  return 0;
778 }
779 
780 static int set_shared_index(void *dst) {
781  void *src;
782  int size;
783 
784  if (mesh->n_neighbor_pe <= 0) return 0;
785 
786  src = mesh->shared_index;
787  size = sizeof(*mesh->shared_index) * (mesh->n_neighbor_pe + 1);
788  memcpy(dst, src, size);
789 
790  return 0;
791 }
792 
793 static int set_shared_item(void *dst) {
794  void *src;
795  int size;
796 
797  if (mesh->n_neighbor_pe <= 0) return 0;
798 
799  src = mesh->shared_item;
800  size = sizeof(*mesh->shared_item) * mesh->shared_index[mesh->n_neighbor_pe];
801  memcpy(dst, src, size);
802 
803  return 0;
804 }
805 
806 static int set_coarse_grid_level(void *dst) {
807  void *src;
808  int size;
809 
810  src = &mesh->coarse_grid_level;
811  size = sizeof(mesh->coarse_grid_level);
812  memcpy(dst, src, size);
813 
814  return 0;
815 }
816 
817 static int set_n_adapt(void *dst) {
818  void *src;
819  int size;
820 
821  src = &mesh->n_adapt;
822  size = sizeof(mesh->n_adapt);
823  memcpy(dst, src, size);
824 
825  return 0;
826 }
827 
828 static int set_when_i_was_refined_node(void *dst) {
829  void *src;
830  int size;
831 
832  if (mesh->n_node_gross <= 0) return 0;
833 
834  src = mesh->when_i_was_refined_node;
835  size = sizeof(*mesh->when_i_was_refined_node) * mesh->n_node_gross;
836  memcpy(dst, src, size);
837 
838  return 0;
839 }
840 
841 static int set_when_i_was_refined_elem(void *dst) {
842  void *src;
843  int size;
844 
845  if (mesh->n_elem_gross <= 0) return 0;
846 
847  src = mesh->when_i_was_refined_elem;
848  size = sizeof(*mesh->when_i_was_refined_elem) * mesh->n_elem_gross;
849  memcpy(dst, src, size);
850 
851  return 0;
852 }
853 
854 static int set_adapt_parent_type(void *dst) {
855  void *src;
856  int size;
857 
858  if (mesh->n_elem_gross <= 0) return 0;
859 
860  src = mesh->adapt_parent_type;
861  size = sizeof(*mesh->adapt_parent_type) * mesh->n_elem_gross;
862  memcpy(dst, src, size);
863 
864  return 0;
865 }
866 
867 static int set_adapt_type(void *dst) {
868  void *src;
869  int size;
870 
871  if (mesh->n_elem_gross <= 0) return 0;
872 
873  src = mesh->adapt_type;
874  size = sizeof(*mesh->adapt_type) * mesh->n_elem_gross;
875  memcpy(dst, src, size);
876 
877  return 0;
878 }
879 
880 static int set_adapt_level(void *dst) {
881  void *src;
882  int size;
883 
884  if (mesh->n_elem_gross <= 0) return 0;
885 
886  src = mesh->adapt_level;
887  size = sizeof(*mesh->adapt_level) * mesh->n_elem_gross;
888  memcpy(dst, src, size);
889 
890  return 0;
891 }
892 
893 static int set_adapt_parent(void *dst) {
894  void *src;
895  int size;
896 
897  if (mesh->n_elem_gross <= 0) return 0;
898 
899  src = mesh->adapt_parent;
900  size = sizeof(*mesh->adapt_parent) * mesh->n_elem_gross * 2;
901  memcpy(dst, src, size);
902 
903  return 0;
904 }
905 
906 static int set_adapt_children_index(void *dst) {
907  void *src;
908  int size;
909 
910  if (mesh->n_elem_gross <= 0) return 0;
911 
912  src = mesh->adapt_children_index;
913  size = sizeof(*mesh->adapt_children_index) * (mesh->n_elem_gross + 1);
914  memcpy(dst, src, size);
915 
916  return 0;
917 }
918 
919 static int set_adapt_children_item(void *dst) {
920  void *src;
921  int size;
922 
923  if (mesh->n_elem_gross <= 0) return 0;
924 
925  src = mesh->adapt_children_item;
926  size = sizeof(*mesh->adapt_children_item) *
927  mesh->adapt_children_index[mesh->n_elem_gross] * 2;
928  memcpy(dst, src, size);
929 
930  return 0;
931 }
932 
933 static int set_n_refine(void *dst) {
934  void *src;
935  int size;
936 
937  src = &mesh->n_refine;
938  size = sizeof(mesh->n_refine);
939  memcpy(dst, src, size);
940 
941  return 0;
942 }
943 
944 static int set_node_old2new(void *dst) {
945  void *src;
946  int size;
947 
948  if (mesh->n_node_gross <= 0) return 0;
949 
950  src = mesh->node_old2new;
951  size = sizeof(*mesh->node_old2new) * mesh->n_node_gross;
952  memcpy(dst, src, size);
953 
954  return 0;
955 }
956 
957 static int set_node_new2old(void *dst) {
958  void *src;
959  int size;
960 
961  if (mesh->n_node_gross <= 0) return 0;
962 
963  src = mesh->node_new2old;
964  size = sizeof(*mesh->node_new2old) * mesh->n_node_gross;
965  memcpy(dst, src, size);
966 
967  return 0;
968 }
969 
970 static int set_elem_old2new(void *dst) {
971  void *src;
972  int size;
973 
974  if (mesh->n_elem_gross <= 0) return 0;
975 
976  src = mesh->elem_old2new;
977  size = sizeof(*mesh->elem_old2new) * mesh->n_elem_gross;
978  memcpy(dst, src, size);
979 
980  return 0;
981 }
982 
983 static int set_elem_new2old(void *dst) {
984  void *src;
985  int size;
986 
987  if (mesh->n_elem_gross <= 0) return 0;
988 
989  src = mesh->elem_new2old;
990  size = sizeof(*mesh->elem_new2old) * mesh->n_elem_gross;
991  memcpy(dst, src, size);
992 
993  return 0;
994 }
995 
996 static int set_n_node_refine_hist(void *dst) {
997  void *src;
998  int size;
999 
1000  if (mesh->n_refine <= 0) return 0;
1001 
1002  src = mesh->n_node_refine_hist;
1003  size = sizeof(*mesh->n_node_refine_hist) * mesh->n_refine;
1004 
1005  memcpy(dst, src, size);
1006 
1007  return 0;
1008 }
1009 
1010 static int set_n_sect(void *dst) {
1011  void *src;
1012  int size;
1013  struct hecmwST_section *sect = mesh->section;
1014 
1015  src = &sect->n_sect;
1016  size = sizeof(sect->n_sect);
1017  memcpy(dst, src, size);
1018 
1019  return 0;
1020 }
1021 
1022 static int set_sect_type(void *dst) {
1023  void *src;
1024  int size;
1025  struct hecmwST_section *sect = mesh->section;
1026 
1027  if (sect->n_sect <= 0) return 0;
1028 
1029  src = sect->sect_type;
1030  size = sizeof(*sect->sect_type) * sect->n_sect;
1031  memcpy(dst, src, size);
1032 
1033  return 0;
1034 }
1035 
1036 static int set_sect_opt(void *dst) {
1037  void *src;
1038  int size;
1039  struct hecmwST_section *sect = mesh->section;
1040 
1041  if (sect->n_sect <= 0) return 0;
1042 
1043  src = sect->sect_opt;
1044  size = sizeof(*sect->sect_opt) * sect->n_sect;
1045  memcpy(dst, src, size);
1046 
1047  return 0;
1048 }
1049 
1050 static int set_sect_mat_ID_index(void *dst) {
1051  void *src;
1052  int size;
1053  struct hecmwST_section *sect = mesh->section;
1054 
1055  if (sect->n_sect <= 0) return 0;
1056 
1057  src = sect->sect_mat_ID_index;
1058  size = sizeof(*sect->sect_mat_ID_index) * (sect->n_sect + 1);
1059  memcpy(dst, src, size);
1060 
1061  return 0;
1062 }
1063 
1064 static int set_sect_mat_ID_item(void *dst) {
1065  void *src;
1066  int size;
1067  struct hecmwST_section *sect = mesh->section;
1068 
1069  if (sect->n_sect <= 0) return 0;
1070 
1071  src = sect->sect_mat_ID_item;
1072  size =
1073  sizeof(*sect->sect_mat_ID_item) * sect->sect_mat_ID_index[sect->n_sect];
1074  memcpy(dst, src, size);
1075 
1076  return 0;
1077 }
1078 
1079 static int set_sect_I_index(void *dst) {
1080  void *src;
1081  int size;
1082  struct hecmwST_section *sect = mesh->section;
1083 
1084  if (sect->n_sect <= 0) return 0;
1085 
1086  src = sect->sect_I_index;
1087  size = sizeof(*sect->sect_I_index) * (sect->n_sect + 1);
1088  memcpy(dst, src, size);
1089 
1090  return 0;
1091 }
1092 
1093 static int set_sect_I_item(void *dst) {
1094  void *src;
1095  int size;
1096  struct hecmwST_section *sect = mesh->section;
1097 
1098  if (sect->n_sect <= 0) return 0;
1099  if (sect->sect_I_item == NULL) return 0;
1100 
1101  src = sect->sect_I_item;
1102  size = sizeof(*sect->sect_I_item) * sect->sect_I_index[sect->n_sect];
1103  memcpy(dst, src, size);
1104 
1105  return 0;
1106 }
1107 
1108 static int set_sect_R_index(void *dst) {
1109  void *src;
1110  int size;
1111  struct hecmwST_section *sect = mesh->section;
1112 
1113  if (sect->n_sect <= 0) return 0;
1114 
1115  src = sect->sect_R_index;
1116  size = sizeof(*sect->sect_R_index) * (sect->n_sect + 1);
1117  memcpy(dst, src, size);
1118 
1119  return 0;
1120 }
1121 
1122 static int set_sect_R_item(void *dst) {
1123  void *src;
1124  int size;
1125  struct hecmwST_section *sect = mesh->section;
1126 
1127  if (sect->n_sect <= 0) return 0;
1128 
1129  src = sect->sect_R_item;
1130  size = sizeof(*sect->sect_R_item) * sect->sect_R_index[sect->n_sect];
1131  memcpy(dst, src, size);
1132 
1133  return 0;
1134 }
1135 
1136 static int set_n_mat(void *dst) {
1137  void *src;
1138  int size;
1139  struct hecmwST_material *mat = mesh->material;
1140 
1141  src = &mat->n_mat;
1142  size = sizeof(mat->n_mat);
1143  memcpy(dst, src, size);
1144 
1145  return 0;
1146 }
1147 
1148 static int set_n_mat_item(void *dst) {
1149  void *src;
1150  int size;
1151  struct hecmwST_material *mat = mesh->material;
1152 
1153  src = &mat->n_mat_item;
1154  size = sizeof(mat->n_mat_item);
1155  memcpy(dst, src, size);
1156 
1157  return 0;
1158 }
1159 
1160 static int set_n_mat_subitem(void *dst) {
1161  void *src;
1162  int size;
1163  struct hecmwST_material *mat = mesh->material;
1164 
1165  src = &mat->n_mat_subitem;
1166  size = sizeof(mat->n_mat_subitem);
1167  memcpy(dst, src, size);
1168 
1169  return 0;
1170 }
1171 
1172 static int set_n_mat_table(void *dst) {
1173  void *src;
1174  int size;
1175  struct hecmwST_material *mat = mesh->material;
1176 
1177  src = &mat->n_mat_table;
1178  size = sizeof(mat->n_mat_table);
1179  memcpy(dst, src, size);
1180 
1181  return 0;
1182 }
1183 
1184 static int set_mat_name(void *dst) {
1185  int i;
1186  struct hecmwST_material *mat = mesh->material;
1187 
1188  if (mat->n_mat <= 0) return 0;
1189 
1190  for (i = 0; i < mat->n_mat; i++) {
1191  char *dst_point = (char *)dst + HECMW_NAME_LEN * i;
1192  char *src = mat->mat_name[i];
1193  HECMW_strcpy_c2f(src, dst_point, HECMW_NAME_LEN);
1194  }
1195 
1196  return 0;
1197 }
1198 
1199 static int set_mat_item_index(void *dst) {
1200  void *src;
1201  int size;
1202  struct hecmwST_material *mat = mesh->material;
1203 
1204  if (mat->n_mat <= 0) return 0;
1205 
1206  src = mat->mat_item_index;
1207  size = sizeof(*mat->mat_item_index) * (mat->n_mat + 1);
1208  memcpy(dst, src, size);
1209 
1210  return 0;
1211 }
1212 
1213 static int set_mat_subitem_index(void *dst) {
1214  void *src;
1215  int size;
1216  struct hecmwST_material *mat = mesh->material;
1217 
1218  if (mat->n_mat_item <= 0) return 0;
1219 
1220  src = mat->mat_subitem_index;
1221  size = sizeof(*mat->mat_subitem_index) * (mat->n_mat_item + 1);
1222  memcpy(dst, src, size);
1223 
1224  return 0;
1225 }
1226 
1227 static int set_mat_table_index(void *dst) {
1228  void *src;
1229  int size;
1230  struct hecmwST_material *mat = mesh->material;
1231 
1232  if (mat->n_mat_subitem <= 0) return 0;
1233 
1234  src = mat->mat_table_index;
1235  size = sizeof(*mat->mat_table_index) * (mat->n_mat_subitem + 1);
1236  memcpy(dst, src, size);
1237 
1238  return 0;
1239 }
1240 
1241 static int set_mat_val(void *dst) {
1242  void *src;
1243  int size;
1244  struct hecmwST_material *mat = mesh->material;
1245 
1246  if (mat->n_mat <= 0) return 0;
1247 
1248  src = mat->mat_val;
1249  size = sizeof(*mat->mat_val) * mat->mat_table_index[mat->n_mat_subitem];
1250  memcpy(dst, src, size);
1251 
1252  return 0;
1253 }
1254 
1255 static int set_mat_temp(void *dst) {
1256  void *src;
1257  int size;
1258  struct hecmwST_material *mat = mesh->material;
1259 
1260  if (mat->n_mat <= 0) return 0;
1261 
1262  src = mat->mat_temp;
1263  size = sizeof(*mat->mat_temp) * mat->mat_table_index[mat->n_mat_subitem];
1264  memcpy(dst, src, size);
1265 
1266  return 0;
1267 }
1268 
1269 static int set_n_mpc(void *dst) {
1270  void *src;
1271  int size;
1272  struct hecmwST_mpc *mpc = mesh->mpc;
1273 
1274  src = &mpc->n_mpc;
1275  size = sizeof(mpc->n_mpc);
1276  memcpy(dst, src, size);
1277 
1278  return 0;
1279 }
1280 
1281 static int set_mpc_index(void *dst) {
1282  void *src;
1283  int size;
1284  struct hecmwST_mpc *mpc = mesh->mpc;
1285 
1286  if (mpc->n_mpc <= 0) return 0;
1287 
1288  src = mpc->mpc_index;
1289  size = sizeof(*mpc->mpc_index) * (mpc->n_mpc + 1);
1290  memcpy(dst, src, size);
1291 
1292  return 0;
1293 }
1294 
1295 static int set_mpc_item(void *dst) {
1296  void *src;
1297  int size;
1298  struct hecmwST_mpc *mpc = mesh->mpc;
1299 
1300  if (mpc->n_mpc <= 0) return 0;
1301 
1302  src = mpc->mpc_item;
1303  size = sizeof(*mpc->mpc_item) * mpc->mpc_index[mpc->n_mpc];
1304  memcpy(dst, src, size);
1305 
1306  return 0;
1307 }
1308 
1309 static int set_mpc_dof(void *dst) {
1310  void *src;
1311  int size;
1312  struct hecmwST_mpc *mpc = mesh->mpc;
1313 
1314  if (mpc->n_mpc <= 0) return 0;
1315 
1316  src = mpc->mpc_dof;
1317  size = sizeof(*mpc->mpc_dof) * mpc->mpc_index[mpc->n_mpc];
1318  memcpy(dst, src, size);
1319 
1320  return 0;
1321 }
1322 
1323 static int set_mpc_val(void *dst) {
1324  void *src;
1325  int size;
1326  struct hecmwST_mpc *mpc = mesh->mpc;
1327 
1328  if (mpc->n_mpc <= 0) return 0;
1329 
1330  src = mpc->mpc_val;
1331  size = sizeof(*mpc->mpc_val) * mpc->mpc_index[mpc->n_mpc];
1332  memcpy(dst, src, size);
1333 
1334  return 0;
1335 }
1336 
1337 static int set_mpc_const(void *dst) {
1338  void *src;
1339  int size;
1340  struct hecmwST_mpc *mpc = mesh->mpc;
1341 
1342  if (mpc->n_mpc <= 0) return 0;
1343 
1344  src = mpc->mpc_const;
1345  size = sizeof(*mpc->mpc_const) * mpc->n_mpc;
1346  memcpy(dst, src, size);
1347 
1348  return 0;
1349 }
1350 
1351 static int set_n_amp(void *dst) {
1352  void *src;
1353  int size;
1354  struct hecmwST_amplitude *amp = mesh->amp;
1355 
1356  src = &amp->n_amp;
1357  size = sizeof(amp->n_amp);
1358  memcpy(dst, src, size);
1359 
1360  return 0;
1361 }
1362 
1363 static int set_amp_name(void *dst) {
1364  int i;
1365  struct hecmwST_amplitude *amp = mesh->amp;
1366 
1367  if (amp->n_amp <= 0) return 0;
1368 
1369  for (i = 0; i < amp->n_amp; i++) {
1370  char *dst_point = (char *)dst + HECMW_NAME_LEN * i;
1371  char *src = amp->amp_name[i];
1372  HECMW_strcpy_c2f(src, dst_point, HECMW_NAME_LEN);
1373  }
1374 
1375  return 0;
1376 }
1377 
1378 static int set_amp_type_definition(void *dst) {
1379  void *src;
1380  int size;
1381  struct hecmwST_amplitude *amp = mesh->amp;
1382 
1383  if (amp->n_amp <= 0) return 0;
1384 
1385  src = amp->amp_type_definition;
1386  size = sizeof(*amp->amp_type_definition) * amp->n_amp;
1387  memcpy(dst, src, size);
1388 
1389  return 0;
1390 }
1391 
1392 static int set_amp_type_time(void *dst) {
1393  void *src;
1394  int size;
1395  struct hecmwST_amplitude *amp = mesh->amp;
1396 
1397  if (amp->n_amp <= 0) return 0;
1398 
1399  src = amp->amp_type_time;
1400  size = sizeof(*amp->amp_type_time) * amp->n_amp;
1401  memcpy(dst, src, size);
1402 
1403  return 0;
1404 }
1405 
1406 static int set_amp_type_value(void *dst) {
1407  void *src;
1408  int size;
1409  struct hecmwST_amplitude *amp = mesh->amp;
1410 
1411  if (amp->n_amp <= 0) return 0;
1412 
1413  src = amp->amp_type_value;
1414  size = sizeof(*amp->amp_type_value) * amp->n_amp;
1415  memcpy(dst, src, size);
1416 
1417  return 0;
1418 }
1419 
1420 static int set_amp_index(void *dst) {
1421  void *src;
1422  int size;
1423  struct hecmwST_amplitude *amp = mesh->amp;
1424 
1425  if (amp->n_amp <= 0) return 0;
1426 
1427  src = amp->amp_index;
1428  size = sizeof(*amp->amp_index) * (amp->n_amp + 1);
1429  memcpy(dst, src, size);
1430 
1431  return 0;
1432 }
1433 
1434 static int set_amp_val(void *dst) {
1435  void *src;
1436  int size;
1437  struct hecmwST_amplitude *amp = mesh->amp;
1438 
1439  if (amp->n_amp <= 0) return 0;
1440 
1441  src = amp->amp_val;
1442  size = sizeof(*amp->amp_val) * amp->amp_index[amp->n_amp];
1443  memcpy(dst, src, size);
1444 
1445  return 0;
1446 }
1447 
1448 static int set_amp_table(void *dst) {
1449  void *src;
1450  int size;
1451  struct hecmwST_amplitude *amp = mesh->amp;
1452 
1453  if (amp->n_amp <= 0) return 0;
1454 
1455  src = amp->amp_table;
1456  size = sizeof(*amp->amp_table) * amp->amp_index[amp->n_amp];
1457  memcpy(dst, src, size);
1458 
1459  return 0;
1460 }
1461 
1462 static int set_ngrp_n_grp(void *dst) {
1463  void *src;
1464  int size;
1465  struct hecmwST_node_grp *grp = mesh->node_group;
1466 
1467  src = &grp->n_grp;
1468  size = sizeof(grp->n_grp);
1469  memcpy(dst, src, size);
1470 
1471  return 0;
1472 }
1473 
1474 static int set_ngrp_n_bc(void *dst) {
1475  void *src;
1476  int size;
1477  struct hecmwST_node_grp *grp = mesh->node_group;
1478 
1479  src = &grp->n_bc;
1480  size = sizeof(grp->n_bc);
1481  memcpy(dst, src, size);
1482 
1483  return 0;
1484 }
1485 
1486 static int set_ngrp_grp_name(void *dst) {
1487  int i;
1488  struct hecmwST_node_grp *grp = mesh->node_group;
1489 
1490  if (grp->n_grp <= 0) return 0;
1491 
1492  for (i = 0; i < grp->n_grp; i++) {
1493  char *dst_point = (char *)dst + HECMW_NAME_LEN * i;
1494  char *src = grp->grp_name[i];
1495  HECMW_strcpy_c2f(src, dst_point, HECMW_NAME_LEN);
1496  }
1497 
1498  return 0;
1499 }
1500 
1501 static int set_ngrp_grp_index(void *dst) {
1502  void *src;
1503  int size;
1504  struct hecmwST_node_grp *grp = mesh->node_group;
1505 
1506  if (grp->n_grp <= 0) return 0;
1507 
1508  src = grp->grp_index;
1509  size = sizeof(*grp->grp_index) * (grp->n_grp + 1);
1510  memcpy(dst, src, size);
1511 
1512  return 0;
1513 }
1514 
1515 static int set_ngrp_grp_item(void *dst) {
1516  void *src;
1517  int size;
1518  struct hecmwST_node_grp *grp = mesh->node_group;
1519 
1520  if (grp->n_grp <= 0) return 0;
1521 
1522  src = grp->grp_item;
1523  size = sizeof(*grp->grp_item) * grp->grp_index[grp->n_grp];
1524  memcpy(dst, src, size);
1525 
1526  return 0;
1527 }
1528 
1529 static int set_ngrp_bc_grp_ID(void *dst) {
1530  void *src;
1531  int size;
1532  struct hecmwST_node_grp *grp = mesh->node_group;
1533 
1534  if (grp->n_bc <= 0) return 0;
1535 
1536  src = grp->bc_grp_ID;
1537  size = sizeof(*grp->bc_grp_ID) * grp->n_bc;
1538  memcpy(dst, src, size);
1539 
1540  return 0;
1541 }
1542 
1543 static int set_ngrp_bc_grp_type(void *dst) {
1544  void *src;
1545  int size;
1546  struct hecmwST_node_grp *grp = mesh->node_group;
1547 
1548  if (grp->n_bc <= 0) return 0;
1549 
1550  src = grp->bc_grp_type;
1551  size = sizeof(*grp->bc_grp_type) * grp->n_bc;
1552  memcpy(dst, src, size);
1553 
1554  return 0;
1555 }
1556 
1557 static int set_ngrp_bc_grp_index(void *dst) {
1558  void *src;
1559  int size;
1560  struct hecmwST_node_grp *grp = mesh->node_group;
1561 
1562  if (grp->n_bc <= 0) return 0;
1563 
1564  src = grp->bc_grp_index;
1565  size = sizeof(*grp->bc_grp_index) * grp->n_bc;
1566  memcpy(dst, src, size);
1567 
1568  return 0;
1569 }
1570 
1571 static int set_ngrp_bc_grp_dof(void *dst) {
1572  void *src;
1573  int size;
1574  struct hecmwST_node_grp *grp = mesh->node_group;
1575 
1576  if (grp->n_bc <= 0) return 0;
1577 
1578  src = grp->bc_grp_dof;
1579  size = sizeof(*grp->bc_grp_dof) * grp->n_bc;
1580  memcpy(dst, src, size);
1581 
1582  return 0;
1583 }
1584 
1585 static int set_ngrp_bc_grp_val(void *dst) {
1586  void *src;
1587  int size;
1588  struct hecmwST_node_grp *grp = mesh->node_group;
1589 
1590  if (grp->n_bc <= 0) return 0;
1591 
1592  src = grp->bc_grp_val;
1593  size = sizeof(*grp->bc_grp_val) * grp->n_bc;
1594  memcpy(dst, src, size);
1595 
1596  return 0;
1597 }
1598 
1599 static int set_egrp_n_grp(void *dst) {
1600  void *src;
1601  int size;
1602  struct hecmwST_elem_grp *grp = mesh->elem_group;
1603 
1604  src = &grp->n_grp;
1605  size = sizeof(grp->n_grp);
1606  memcpy(dst, src, size);
1607 
1608  return 0;
1609 }
1610 
1611 static int set_egrp_n_bc(void *dst) {
1612  void *src;
1613  int size;
1614  struct hecmwST_elem_grp *grp = mesh->elem_group;
1615 
1616  src = &grp->n_bc;
1617  size = sizeof(grp->n_bc);
1618  memcpy(dst, src, size);
1619 
1620  return 0;
1621 }
1622 
1623 static int set_egrp_grp_name(void *dst) {
1624  int i;
1625  struct hecmwST_elem_grp *grp = mesh->elem_group;
1626 
1627  if (grp->n_grp <= 0) return 0;
1628 
1629  for (i = 0; i < grp->n_grp; i++) {
1630  char *dst_point = (char *)dst + HECMW_NAME_LEN * i;
1631  char *src = grp->grp_name[i];
1632  HECMW_strcpy_c2f(src, dst_point, HECMW_NAME_LEN);
1633  }
1634 
1635  return 0;
1636 }
1637 
1638 static int set_egrp_grp_index(void *dst) {
1639  void *src;
1640  int size;
1641  struct hecmwST_elem_grp *grp = mesh->elem_group;
1642 
1643  if (grp->n_grp <= 0) return 0;
1644 
1645  src = grp->grp_index;
1646  size = sizeof(*grp->grp_index) * (grp->n_grp + 1);
1647  memcpy(dst, src, size);
1648 
1649  return 0;
1650 }
1651 
1652 static int set_egrp_grp_item(void *dst) {
1653  void *src;
1654  int size;
1655  struct hecmwST_elem_grp *grp = mesh->elem_group;
1656 
1657  if (grp->n_grp <= 0) return 0;
1658 
1659  src = grp->grp_item;
1660  size = sizeof(*grp->grp_item) * grp->grp_index[grp->n_grp];
1661  memcpy(dst, src, size);
1662 
1663  return 0;
1664 }
1665 
1666 static int set_egrp_bc_grp_ID(void *dst) {
1667  void *src;
1668  int size;
1669  struct hecmwST_elem_grp *grp = mesh->elem_group;
1670 
1671  if (grp->n_bc <= 0) return 0;
1672 
1673  src = grp->bc_grp_ID;
1674  size = sizeof(*grp->bc_grp_ID) * grp->n_bc;
1675  memcpy(dst, src, size);
1676 
1677  return 0;
1678 }
1679 
1680 static int set_egrp_bc_grp_type(void *dst) {
1681  void *src;
1682  int size;
1683  struct hecmwST_elem_grp *grp = mesh->elem_group;
1684 
1685  if (grp->n_bc <= 0) return 0;
1686 
1687  src = grp->bc_grp_type;
1688  size = sizeof(*grp->bc_grp_type) * grp->n_bc;
1689  memcpy(dst, src, size);
1690 
1691  return 0;
1692 }
1693 
1694 static int set_egrp_bc_grp_index(void *dst) {
1695  void *src;
1696  int size;
1697  struct hecmwST_elem_grp *grp = mesh->elem_group;
1698 
1699  if (grp->n_bc <= 0) return 0;
1700 
1701  src = grp->bc_grp_index;
1702  size = sizeof(*grp->bc_grp_index) * grp->n_bc;
1703  memcpy(dst, src, size);
1704 
1705  return 0;
1706 }
1707 
1708 static int set_egrp_bc_grp_val(void *dst) {
1709  void *src;
1710  int size;
1711  struct hecmwST_elem_grp *grp = mesh->elem_group;
1712 
1713  if (grp->n_bc <= 0) return 0;
1714 
1715  src = grp->bc_grp_val;
1716  size = sizeof(*grp->bc_grp_val) * grp->n_bc;
1717  memcpy(dst, src, size);
1718 
1719  return 0;
1720 }
1721 
1722 static int set_sgrp_n_grp(void *dst) {
1723  void *src;
1724  int size;
1725  struct hecmwST_surf_grp *grp = mesh->surf_group;
1726 
1727  src = &grp->n_grp;
1728  size = sizeof(grp->n_grp);
1729  memcpy(dst, src, size);
1730 
1731  return 0;
1732 }
1733 
1734 static int set_sgrp_n_bc(void *dst) {
1735  void *src;
1736  int size;
1737  struct hecmwST_surf_grp *grp = mesh->surf_group;
1738 
1739  src = &grp->n_bc;
1740  size = sizeof(grp->n_bc);
1741  memcpy(dst, src, size);
1742 
1743  return 0;
1744 }
1745 
1746 static int set_sgrp_grp_name(void *dst) {
1747  int i;
1748  struct hecmwST_surf_grp *grp = mesh->surf_group;
1749 
1750  if (grp->n_grp <= 0) return 0;
1751 
1752  for (i = 0; i < grp->n_grp; i++) {
1753  char *dst_point = (char *)dst + HECMW_NAME_LEN * i;
1754  char *src = grp->grp_name[i];
1755  HECMW_strcpy_c2f(src, dst_point, HECMW_NAME_LEN);
1756  }
1757 
1758  return 0;
1759 }
1760 
1761 static int set_sgrp_grp_index(void *dst) {
1762  void *src;
1763  int size;
1764  struct hecmwST_surf_grp *grp = mesh->surf_group;
1765 
1766  if (grp->n_grp <= 0) return 0;
1767 
1768  src = grp->grp_index;
1769  size = sizeof(*grp->grp_index) * (grp->n_grp + 1);
1770  memcpy(dst, src, size);
1771 
1772  return 0;
1773 }
1774 
1775 static int set_sgrp_grp_item(void *dst) {
1776  void *src;
1777  int size;
1778  struct hecmwST_surf_grp *grp = mesh->surf_group;
1779 
1780  if (grp->n_grp <= 0) return 0;
1781 
1782  src = grp->grp_item;
1783  size = sizeof(*grp->grp_item) * grp->grp_index[grp->n_grp] * 2;
1784  memcpy(dst, src, size);
1785 
1786  return 0;
1787 }
1788 
1789 static int set_sgrp_bc_grp_ID(void *dst) {
1790  void *src;
1791  int size;
1792  struct hecmwST_surf_grp *grp = mesh->surf_group;
1793 
1794  if (grp->n_bc <= 0) return 0;
1795 
1796  src = grp->bc_grp_ID;
1797  size = sizeof(*grp->bc_grp_ID) * grp->n_bc;
1798  memcpy(dst, src, size);
1799 
1800  return 0;
1801 }
1802 
1803 static int set_sgrp_bc_grp_type(void *dst) {
1804  void *src;
1805  int size;
1806  struct hecmwST_surf_grp *grp = mesh->surf_group;
1807 
1808  if (grp->n_bc <= 0) return 0;
1809 
1810  src = grp->bc_grp_type;
1811  size = sizeof(*grp->bc_grp_type) * grp->n_bc;
1812  memcpy(dst, src, size);
1813 
1814  return 0;
1815 }
1816 
1817 static int set_sgrp_bc_grp_index(void *dst) {
1818  void *src;
1819  int size;
1820  struct hecmwST_surf_grp *grp = mesh->surf_group;
1821 
1822  if (grp->n_bc <= 0) return 0;
1823 
1824  src = grp->bc_grp_index;
1825  size = sizeof(*grp->bc_grp_index) * grp->n_bc;
1826  memcpy(dst, src, size);
1827 
1828  return 0;
1829 }
1830 
1831 static int set_sgrp_bc_grp_val(void *dst) {
1832  void *src;
1833  int size;
1834  struct hecmwST_surf_grp *grp = mesh->surf_group;
1835 
1836  if (grp->n_bc <= 0) return 0;
1837 
1838  src = grp->bc_grp_val;
1839  size = sizeof(*grp->bc_grp_val) * grp->n_bc;
1840  memcpy(dst, src, size);
1841 
1842  return 0;
1843 }
1844 
1845 static int set_contact_pair_n_pair(void *dst) {
1846  void *src;
1847  int size;
1848  struct hecmwST_contact_pair *cpair = mesh->contact_pair;
1849 
1850  src = &cpair->n_pair;
1851  size = sizeof(cpair->n_pair);
1852  memcpy(dst, src, size);
1853 
1854  return 0;
1855 }
1856 
1857 static int set_contact_pair_name(void *dst) {
1858  int i;
1859  struct hecmwST_contact_pair *cpair = mesh->contact_pair;
1860 
1861  if (cpair->n_pair <= 0) return 0;
1862 
1863  for (i = 0; i < cpair->n_pair; i++) {
1864  char *dst_point = (char *)dst + HECMW_NAME_LEN * i;
1865  char *src = cpair->name[i];
1866  HECMW_strcpy_c2f(src, dst_point, HECMW_NAME_LEN);
1867  }
1868 
1869  return 0;
1870 }
1871 
1872 static int set_contact_pair_type(void *dst) {
1873  void *src;
1874  int size;
1875  struct hecmwST_contact_pair *cpair = mesh->contact_pair;
1876 
1877  if (cpair->n_pair <= 0) return 0;
1878 
1879  src = cpair->type;
1880  size = sizeof(*cpair->type) * (cpair->n_pair);
1881  memcpy(dst, src, size);
1882 
1883  return 0;
1884 }
1885 
1886 static int set_contact_pair_slave_grp_id(void *dst) {
1887  void *src;
1888  int size;
1889  struct hecmwST_contact_pair *cpair = mesh->contact_pair;
1890 
1891  if (cpair->n_pair <= 0) return 0;
1892 
1893  src = cpair->slave_grp_id;
1894  size = sizeof(*cpair->slave_grp_id) * (cpair->n_pair);
1895  memcpy(dst, src, size);
1896 
1897  return 0;
1898 }
1899 
1900 static int set_contact_pair_slave_orisgrp_id(void *dst) {
1901  void *src;
1902  int size;
1903  struct hecmwST_contact_pair *cpair = mesh->contact_pair;
1904 
1905  if (cpair->n_pair <= 0) return 0;
1906 
1907  src = cpair->slave_orisgrp_id;
1908  size = sizeof(*cpair->slave_orisgrp_id) * (cpair->n_pair);
1909  memcpy(dst, src, size);
1910 
1911  return 0;
1912 }
1913 
1914 static int set_contact_pair_master_grp_id(void *dst) {
1915  void *src;
1916  int size;
1917  struct hecmwST_contact_pair *cpair = mesh->contact_pair;
1918 
1919  if (cpair->n_pair <= 0) return 0;
1920 
1921  src = cpair->master_grp_id;
1922  size = sizeof(*cpair->master_grp_id) * (cpair->n_pair);
1923  memcpy(dst, src, size);
1924 
1925  return 0;
1926 }
1927 
1928 static int set_refine_origin_index(void *dst) {
1929  void *src;
1930  int size;
1931  struct hecmwST_refine_origin *reforg = mesh->refine_origin;
1932 
1933  src = reforg->index;
1934  size = sizeof(*reforg->index) * (mesh->n_refine + 1);
1935  memcpy(dst, src, size);
1936 
1937  return 0;
1938 }
1939 
1940 static int set_refine_origin_item_index(void *dst) {
1941  void *src;
1942  int size;
1943  struct hecmwST_refine_origin *reforg = mesh->refine_origin;
1944 
1945  src = reforg->item_index;
1946  size = sizeof(*reforg->item_index) * (reforg->index[mesh->n_refine] + 1);
1947  memcpy(dst, src, size);
1948 
1949  return 0;
1950 }
1951 
1952 static int set_refine_origin_item_item(void *dst) {
1953  void *src;
1954  int size;
1955  struct hecmwST_refine_origin *reforg = mesh->refine_origin;
1956 
1957  src = reforg->item_item;
1958  size = sizeof(*reforg->item_item) *
1959  (reforg->item_index[reforg->index[mesh->n_refine]]);
1960  memcpy(dst, src, size);
1961 
1962  return 0;
1963 }
1964 
1965 /*---------------------------------------------------------------------------*/
1966 
1967 static int is_alloc_node_internal_list(void) {
1968  return mesh->node_internal_list ? 1 : 0;
1969 }
1970 
1971 static int is_alloc_node_val_index(void) {
1972  return mesh->node_val_index ? 1 : 0;
1973 }
1974 
1975 static int is_alloc_node_val_item(void) { return mesh->node_val_item ? 1 : 0; }
1976 
1977 static int is_alloc_node_init_val_index(void) {
1978  return mesh->node_init_val_index ? 1 : 0;
1979 }
1980 
1981 static int is_alloc_node_init_val_item(void) {
1982  return mesh->node_init_val_item ? 1 : 0;
1983 }
1984 
1985 static int is_alloc_elem_internal_list(void) {
1986  return mesh->elem_internal_list ? 1 : 0;
1987 }
1988 
1989 static int is_alloc_elem_mat_int_index(void) {
1990  return mesh->elem_mat_int_index ? 1 : 0;
1991 }
1992 
1993 static int is_alloc_elem_mat_int_val(void) {
1994  return mesh->elem_mat_int_val ? 1 : 0;
1995 }
1996 
1997 static int is_alloc_elem_val_index(void) {
1998  return mesh->elem_val_index ? 1 : 0;
1999 }
2000 
2001 static int is_alloc_elem_val_item(void) { return mesh->elem_val_item ? 1 : 0; }
2002 
2003 static int is_alloc_node_old2new(void) { return mesh->node_old2new ? 1 : 0; }
2004 
2005 static int is_alloc_node_new2old(void) { return mesh->node_new2old ? 1 : 0; }
2006 
2007 static int is_alloc_elem_old2new(void) { return mesh->elem_old2new ? 1 : 0; }
2008 
2009 static int is_alloc_elem_new2old(void) { return mesh->elem_new2old ? 1 : 0; }
2010 
2011 static int is_alloc_n_node_refine_hist(void) {
2012  return mesh->n_node_refine_hist ? 1 : 0;
2013 }
2014 
2015 static int is_alloc_when_i_was_refined_node(void) {
2016  return mesh->when_i_was_refined_node ? 1 : 0;
2017 }
2018 
2019 static int is_alloc_when_i_was_refined_elem(void) {
2020  return mesh->when_i_was_refined_elem ? 1 : 0;
2021 }
2022 
2023 static int is_alloc_adapt_parent_type(void) {
2024  return mesh->adapt_parent_type ? 1 : 0;
2025 }
2026 
2027 static int is_alloc_adapt_type(void) { return mesh->adapt_type ? 1 : 0; }
2028 
2029 static int is_alloc_adapt_level(void) { return mesh->adapt_level ? 1 : 0; }
2030 
2031 static int is_alloc_adapt_parent(void) { return mesh->adapt_parent ? 1 : 0; }
2032 
2033 static int is_alloc_adapt_children_index(void) {
2034  return mesh->adapt_children_index ? 1 : 0;
2035 }
2036 
2037 static int is_alloc_adapt_children_item(void) {
2038  return mesh->adapt_children_item ? 1 : 0;
2039 }
2040 
2041 static int is_alloc_ngrp_bc_grp_ID(void) {
2042  return mesh->node_group->bc_grp_ID ? 1 : 0;
2043 }
2044 
2045 static int is_alloc_ngrp_bc_grp_type(void) {
2046  return mesh->node_group->bc_grp_type ? 1 : 0;
2047 }
2048 
2049 static int is_alloc_ngrp_bc_grp_index(void) {
2050  return mesh->node_group->bc_grp_index ? 1 : 0;
2051 }
2052 
2053 static int is_alloc_ngrp_bc_grp_dof(void) {
2054  return mesh->node_group->bc_grp_dof ? 1 : 0;
2055 }
2056 
2057 static int is_alloc_ngrp_bc_grp_val(void) {
2058  return mesh->node_group->bc_grp_val ? 1 : 0;
2059 }
2060 
2061 static int is_alloc_egrp_bc_grp_ID(void) {
2062  return mesh->elem_group->bc_grp_ID ? 1 : 0;
2063 }
2064 
2065 static int is_alloc_egrp_bc_grp_type(void) {
2066  return mesh->elem_group->bc_grp_type ? 1 : 0;
2067 }
2068 
2069 static int is_alloc_egrp_bc_grp_index(void) {
2070  return mesh->elem_group->bc_grp_index ? 1 : 0;
2071 }
2072 
2073 static int is_alloc_egrp_bc_grp_val(void) {
2074  return mesh->elem_group->bc_grp_val ? 1 : 0;
2075 }
2076 
2077 static int is_alloc_sgrp_bc_grp_ID(void) {
2078  return mesh->surf_group->bc_grp_ID ? 1 : 0;
2079 }
2080 
2081 static int is_alloc_sgrp_bc_grp_type(void) {
2082  return mesh->surf_group->bc_grp_type ? 1 : 0;
2083 }
2084 
2085 static int is_alloc_sgrp_bc_grp_index(void) {
2086  return mesh->surf_group->bc_grp_index ? 1 : 0;
2087 }
2088 
2089 static int is_alloc_sgrp_bc_grp_val(void) {
2090  return mesh->surf_group->bc_grp_val ? 1 : 0;
2091 }
2092 
2093 /*-----------------------------------------------------------------------------
2094  * SetFunc table
2095  */
2096 
2097 typedef int (*SetFunc)(void *);
2098 typedef int (*IsAllocatedFunc)(void);
2099 
2100 static struct func_table {
2101  char *struct_name;
2102  char *var_name;
2103  SetFunc set_func;
2104  IsAllocatedFunc is_allocated_func;
2105 } functions[] =
2106  {
2107  /* { Struct name, Variable name, memcpy function, check allocation
2108  function }*/
2109  {"hecmwST_local_mesh", "hecmw_flag_adapt", set_hecmw_flag_adapt, NULL},
2110  {"hecmwST_local_mesh", "hecmw_flag_initcon", set_hecmw_flag_initcon,
2111  NULL},
2112  {"hecmwST_local_mesh", "hecmw_flag_parttype", set_hecmw_flag_parttype,
2113  NULL},
2114  {"hecmwST_local_mesh", "hecmw_flag_partdepth", set_hecmw_flag_partdepth,
2115  NULL},
2116  {"hecmwST_local_mesh", "hecmw_flag_version", set_hecmw_flag_version,
2117  NULL},
2118  {"hecmwST_local_mesh", "hecmw_flag_partcontact",
2119  set_hecmw_flag_partcontact, NULL},
2120 
2121  {"hecmwST_local_mesh", "gridfile", set_gridfile, NULL},
2122  {"hecmwST_local_mesh", "hecmw_n_file", set_hecmw_n_file, NULL},
2123  {"hecmwST_local_mesh", "files", set_files, NULL},
2124  {"hecmwST_local_mesh", "header", set_header, NULL},
2125  {"hecmwST_local_mesh", "zero_temp", set_zero_temp, NULL},
2126 
2127  {"hecmwST_local_mesh", "n_node", set_n_node, NULL},
2128  {"hecmwST_local_mesh", "n_node_gross", set_n_node_gross, NULL},
2129  {"hecmwST_local_mesh", "nn_middle", set_nn_middle, NULL},
2130  {"hecmwST_local_mesh", "nn_internal", set_nn_internal, NULL},
2131  {"hecmwST_local_mesh", "node_internal_list", set_node_internal_list,
2132  is_alloc_node_internal_list},
2133  {"hecmwST_local_mesh", "node_ID", set_node_ID, NULL},
2134  {"hecmwST_local_mesh", "global_node_ID", set_global_node_ID, NULL},
2135  {"hecmwST_local_mesh", "node", set_node, NULL},
2136  {"hecmwST_local_mesh", "n_dof", set_n_dof, NULL},
2137  {"hecmwST_local_mesh", "n_dof_grp", set_n_dof_grp, NULL},
2138  {"hecmwST_local_mesh", "n_dof_tot", set_n_dof_tot, NULL},
2139  {"hecmwST_local_mesh", "node_dof_index", set_node_dof_index, NULL},
2140  {"hecmwST_local_mesh", "node_dof_item", set_node_dof_item, NULL},
2141  {"hecmwST_local_mesh", "node_val_index", set_node_val_index,
2142  is_alloc_node_val_index},
2143  {"hecmwST_local_mesh", "node_val_item", set_node_val_item,
2144  is_alloc_node_val_item},
2145  {"hecmwST_local_mesh", "node_init_val_index", set_node_init_val_index,
2146  is_alloc_node_init_val_index},
2147  {"hecmwST_local_mesh", "node_init_val_item", set_node_init_val_item,
2148  is_alloc_node_init_val_item},
2149  {"hecmwST_local_mesh", "n_elem", set_n_elem, NULL},
2150  {"hecmwST_local_mesh", "n_elem_gross", set_n_elem_gross, NULL},
2151  {"hecmwST_local_mesh", "ne_internal", set_ne_internal, NULL},
2152  {"hecmwST_local_mesh", "elem_internal_list", set_elem_internal_list,
2153  is_alloc_elem_internal_list},
2154  {"hecmwST_local_mesh", "elem_ID", set_elem_ID, NULL},
2155  {"hecmwST_local_mesh", "global_elem_ID", set_global_elem_ID, NULL},
2156  {"hecmwST_local_mesh", "elem_type", set_elem_type, NULL},
2157  {"hecmwST_local_mesh", "n_elem_type", set_n_elem_type, NULL},
2158  {"hecmwST_local_mesh", "elem_type_index", set_elem_type_index, NULL},
2159  {"hecmwST_local_mesh", "elem_type_item", set_elem_type_item, NULL},
2160  {"hecmwST_local_mesh", "elem_node_index", set_elem_node_index, NULL},
2161  {"hecmwST_local_mesh", "elem_node_item", set_elem_node_item, NULL},
2162  {"hecmwST_local_mesh", "section_ID", set_section_ID, NULL},
2163  {"hecmwST_local_mesh", "n_elem_mat_ID", set_n_elem_mat_ID, NULL},
2164  {"hecmwST_local_mesh", "elem_mat_ID_index", set_elem_mat_ID_index,
2165  NULL},
2166  {"hecmwST_local_mesh", "elem_mat_ID_item", set_elem_mat_ID_item, NULL},
2167  {"hecmwST_local_mesh", "elem_mat_int_index", set_elem_mat_int_index,
2168  is_alloc_elem_mat_int_index},
2169  {"hecmwST_local_mesh", "elem_mat_int_val", set_elem_mat_int_val,
2170  is_alloc_elem_mat_int_val},
2171  {"hecmwST_local_mesh", "elem_val_index", set_elem_val_index,
2172  is_alloc_elem_val_index},
2173  {"hecmwST_local_mesh", "elem_val_item", set_elem_val_item,
2174  is_alloc_elem_val_item},
2175 
2176  {"hecmwST_local_mesh", "zero", set_zero, NULL},
2177  {"hecmwST_local_mesh", "HECMW_COMM", set_HECMW_COMM, NULL},
2178  {"hecmwST_local_mesh", "PETOT", set_PETOT, NULL},
2179  {"hecmwST_local_mesh", "PEsmpTOT", set_PEsmpTOT, NULL},
2180  {"hecmwST_local_mesh", "my_rank", set_my_rank, NULL},
2181  {"hecmwST_local_mesh", "errnof", set_errnof, NULL},
2182  {"hecmwST_local_mesh", "n_subdomain", set_n_subdomain, NULL},
2183  {"hecmwST_local_mesh", "n_neighbor_pe", set_n_neighbor_pe, NULL},
2184  {"hecmwST_local_mesh", "neighbor_pe", set_neighbor_pe, NULL},
2185  {"hecmwST_local_mesh", "import_index", set_import_index, NULL},
2186  {"hecmwST_local_mesh", "import_item", set_import_item, NULL},
2187  {"hecmwST_local_mesh", "export_index", set_export_index, NULL},
2188  {"hecmwST_local_mesh", "export_item", set_export_item, NULL},
2189  {"hecmwST_local_mesh", "shared_index", set_shared_index, NULL},
2190  {"hecmwST_local_mesh", "shared_item", set_shared_item, NULL},
2191 
2192  {"hecmwST_local_mesh", "coarse_grid_level", set_coarse_grid_level,
2193  NULL},
2194  {"hecmwST_local_mesh", "n_adapt", set_n_adapt, NULL},
2195  {"hecmwST_local_mesh", "when_i_was_refined_node",
2196  set_when_i_was_refined_node, is_alloc_when_i_was_refined_node},
2197  {"hecmwST_local_mesh", "when_i_was_refined_elem",
2198  set_when_i_was_refined_elem, is_alloc_when_i_was_refined_elem},
2199  {"hecmwST_local_mesh", "adapt_parent_type", set_adapt_parent_type,
2200  is_alloc_adapt_parent_type},
2201  {"hecmwST_local_mesh", "adapt_type", set_adapt_type,
2202  is_alloc_adapt_type},
2203  {"hecmwST_local_mesh", "adapt_level", set_adapt_level,
2204  is_alloc_adapt_level},
2205  {"hecmwST_local_mesh", "adapt_parent", set_adapt_parent,
2206  is_alloc_adapt_parent},
2207  {"hecmwST_local_mesh", "adapt_children_index", set_adapt_children_index,
2208  is_alloc_adapt_children_index},
2209  {"hecmwST_local_mesh", "adapt_children_item", set_adapt_children_item,
2210  is_alloc_adapt_children_item},
2211 
2212  {"hecmwST_local_mesh", "n_refine", set_n_refine, NULL},
2213  {"hecmwST_local_mesh", "node_old2new", set_node_old2new,
2214  is_alloc_node_old2new},
2215  {"hecmwST_local_mesh", "node_new2old", set_node_new2old,
2216  is_alloc_node_new2old},
2217  {"hecmwST_local_mesh", "elem_old2new", set_elem_old2new,
2218  is_alloc_elem_old2new},
2219  {"hecmwST_local_mesh", "elem_new2old", set_elem_new2old,
2220  is_alloc_elem_new2old},
2221  {"hecmwST_local_mesh", "n_node_refine_hist", set_n_node_refine_hist,
2222  is_alloc_n_node_refine_hist},
2223 
2224  {"hecmwST_section", "n_sect", set_n_sect, NULL},
2225  {"hecmwST_section", "sect_type", set_sect_type, NULL},
2226  {"hecmwST_section", "sect_opt", set_sect_opt, NULL},
2227  {"hecmwST_section", "sect_mat_ID_index", set_sect_mat_ID_index, NULL},
2228  {"hecmwST_section", "sect_mat_ID_item", set_sect_mat_ID_item, NULL},
2229  {"hecmwST_section", "sect_I_index", set_sect_I_index, NULL},
2230  {"hecmwST_section", "sect_I_item", set_sect_I_item, NULL},
2231  {"hecmwST_section", "sect_R_index", set_sect_R_index, NULL},
2232  {"hecmwST_section", "sect_R_item", set_sect_R_item, NULL},
2233 
2234  {"hecmwST_material", "n_mat", set_n_mat, NULL},
2235  {"hecmwST_material", "n_mat_item", set_n_mat_item, NULL},
2236  {"hecmwST_material", "n_mat_subitem", set_n_mat_subitem, NULL},
2237  {"hecmwST_material", "n_mat_table", set_n_mat_table, NULL},
2238  {"hecmwST_material", "mat_name", set_mat_name, NULL},
2239  {"hecmwST_material", "mat_item_index", set_mat_item_index, NULL},
2240  {"hecmwST_material", "mat_subitem_index", set_mat_subitem_index, NULL},
2241  {"hecmwST_material", "mat_table_index", set_mat_table_index, NULL},
2242  {"hecmwST_material", "mat_val", set_mat_val, NULL},
2243  {"hecmwST_material", "mat_temp", set_mat_temp, NULL},
2244 
2245  {"hecmwST_mpc", "n_mpc", set_n_mpc, NULL},
2246  {"hecmwST_mpc", "mpc_index", set_mpc_index, NULL},
2247  {"hecmwST_mpc", "mpc_item", set_mpc_item, NULL},
2248  {"hecmwST_mpc", "mpc_dof", set_mpc_dof, NULL},
2249  {"hecmwST_mpc", "mpc_val", set_mpc_val, NULL},
2250  {"hecmwST_mpc", "mpc_const", set_mpc_const, NULL},
2251 
2252  {"hecmwST_amplitude", "n_amp", set_n_amp, NULL},
2253  {"hecmwST_amplitude", "amp_name", set_amp_name, NULL},
2254  {"hecmwST_amplitude", "amp_type_definition", set_amp_type_definition,
2255  NULL},
2256  {"hecmwST_amplitude", "amp_type_time", set_amp_type_time, NULL},
2257  {"hecmwST_amplitude", "amp_type_value", set_amp_type_value, NULL},
2258  {"hecmwST_amplitude", "amp_index", set_amp_index, NULL},
2259  {"hecmwST_amplitude", "amp_val", set_amp_val, NULL},
2260  {"hecmwST_amplitude", "amp_table", set_amp_table, NULL},
2261 
2262  {"hecmwST_node_grp", "n_grp", set_ngrp_n_grp, NULL},
2263  {"hecmwST_node_grp", "grp_name", set_ngrp_grp_name, NULL},
2264  {"hecmwST_node_grp", "grp_index", set_ngrp_grp_index, NULL},
2265  {"hecmwST_node_grp", "grp_item", set_ngrp_grp_item, NULL},
2266  {"hecmwST_node_grp", "n_bc", set_ngrp_n_bc, NULL},
2267  {"hecmwST_node_grp", "bc_grp_ID", set_ngrp_bc_grp_ID,
2268  is_alloc_ngrp_bc_grp_ID},
2269  {"hecmwST_node_grp", "bc_grp_type", set_ngrp_bc_grp_type,
2270  is_alloc_ngrp_bc_grp_type},
2271  {"hecmwST_node_grp", "bc_grp_index", set_ngrp_bc_grp_index,
2272  is_alloc_ngrp_bc_grp_index},
2273  {"hecmwST_node_grp", "bc_grp_dof", set_ngrp_bc_grp_dof,
2274  is_alloc_ngrp_bc_grp_dof},
2275  {"hecmwST_node_grp", "bc_grp_val", set_ngrp_bc_grp_val,
2276  is_alloc_ngrp_bc_grp_val},
2277 
2278  {"hecmwST_elem_grp", "n_grp", set_egrp_n_grp, NULL},
2279  {"hecmwST_elem_grp", "grp_name", set_egrp_grp_name, NULL},
2280  {"hecmwST_elem_grp", "grp_index", set_egrp_grp_index, NULL},
2281  {"hecmwST_elem_grp", "grp_item", set_egrp_grp_item, NULL},
2282  {"hecmwST_elem_grp", "n_bc", set_egrp_n_bc, NULL},
2283  {"hecmwST_elem_grp", "bc_grp_ID", set_egrp_bc_grp_ID,
2284  is_alloc_egrp_bc_grp_ID},
2285  {"hecmwST_elem_grp", "bc_grp_type", set_egrp_bc_grp_type,
2286  is_alloc_egrp_bc_grp_type},
2287  {"hecmwST_elem_grp", "bc_grp_index", set_egrp_bc_grp_index,
2288  is_alloc_egrp_bc_grp_index},
2289  {"hecmwST_elem_grp", "bc_grp_val", set_egrp_bc_grp_val,
2290  is_alloc_egrp_bc_grp_val},
2291 
2292  {"hecmwST_surf_grp", "n_grp", set_sgrp_n_grp, NULL},
2293  {"hecmwST_surf_grp", "grp_name", set_sgrp_grp_name, NULL},
2294  {"hecmwST_surf_grp", "grp_index", set_sgrp_grp_index, NULL},
2295  {"hecmwST_surf_grp", "grp_item", set_sgrp_grp_item, NULL},
2296  {"hecmwST_surf_grp", "n_bc", set_sgrp_n_bc, NULL},
2297  {"hecmwST_surf_grp", "bc_grp_ID", set_sgrp_bc_grp_ID,
2298  is_alloc_sgrp_bc_grp_ID},
2299  {"hecmwST_surf_grp", "bc_grp_type", set_sgrp_bc_grp_type,
2300  is_alloc_sgrp_bc_grp_type},
2301  {"hecmwST_surf_grp", "bc_grp_index", set_sgrp_bc_grp_index,
2302  is_alloc_sgrp_bc_grp_index},
2303  {"hecmwST_surf_grp", "bc_grp_val", set_sgrp_bc_grp_val,
2304  is_alloc_sgrp_bc_grp_val},
2305 
2306  {"hecmwST_contact_pair", "n_pair", set_contact_pair_n_pair, NULL},
2307  {"hecmwST_contact_pair", "name", set_contact_pair_name, NULL},
2308  {"hecmwST_contact_pair", "type", set_contact_pair_type, NULL},
2309  {"hecmwST_contact_pair", "slave_grp_id", set_contact_pair_slave_grp_id,
2310  NULL},
2311  {"hecmwST_contact_pair", "slave_orisgrp_id", set_contact_pair_slave_orisgrp_id,
2312  NULL},
2313  {"hecmwST_contact_pair", "master_grp_id",
2314  set_contact_pair_master_grp_id, NULL},
2315  {"hecmwST_refine_origin", "index", set_refine_origin_index, NULL},
2316  {"hecmwST_refine_origin", "item_index", set_refine_origin_item_index,
2317  NULL},
2318  {"hecmwST_refine_origin", "item_item", set_refine_origin_item_item,
2319  NULL},
2320 };
2321 
2322 static const int NFUNC = sizeof(functions) / sizeof(functions[0]);
2323 
2324 static IsAllocatedFunc get_is_allocated_func(char *struct_name,
2325  char *var_name) {
2326  int i;
2327 
2328  for (i = 0; i < NFUNC; i++) {
2329  if (strcmp(functions[i].struct_name, struct_name) == 0 &&
2330  strcmp(functions[i].var_name, var_name) == 0) {
2331  return functions[i].is_allocated_func;
2332  }
2333  }
2334  return NULL;
2335 }
2336 
2337 static SetFunc get_set_func(char *struct_name, char *var_name) {
2338  int i;
2339 
2340  for (i = 0; i < NFUNC; i++) {
2341  if (strcmp(functions[i].struct_name, struct_name) == 0 &&
2342  strcmp(functions[i].var_name, var_name) == 0) {
2343  return functions[i].set_func;
2344  }
2345  }
2346  return NULL;
2347 }
2348 
2349 /*----------------------------------------------------------------------------*/
2350 
2352  mesh = local_mesh;
2353  return 0;
2354 }
2355 
2357  mesh = NULL;
2358  return 0;
2359 }
2360 
2361 /*----------------------------------------------------------------------------*/
2362 /*----------------------------------------------------------------------------*/
2363 
2364 void hecmw_dist_copy_c2f_isalloc_if(char *struct_name, char *var_name,
2365  int *is_allocated, int *err, int len_struct,
2366  int len_var) {
2367  IsAllocatedFunc func;
2368  char sname[HECMW_NAME_LEN + 1];
2369  char vname[HECMW_NAME_LEN + 1];
2370 
2371  *err = 1;
2372 
2373  if (mesh == NULL) {
2375  "mesh copy(C->Fortran): confirm allocation : 'mesh' has "
2376  "not initialized yet");
2377  return;
2378  }
2379  if (struct_name == NULL) {
2382  "mesh copy(C->Fortran): confirm allocation: 'struct_name' is NULL");
2383  return;
2384  }
2385  if (var_name == NULL) {
2388  "mesh copy(C->Fortran): confirm allocation: 'var_name' is NULL");
2389  return;
2390  }
2391  if (is_allocated == NULL) {
2394  "mesh copy(C->Fortran): confirm allocation: 'is_allocated' is NULL");
2395  return;
2396  }
2397 
2398  if (HECMW_strcpy_f2c_r(struct_name, len_struct, sname, sizeof(sname)) ==
2399  NULL) {
2400  return;
2401  }
2402  if (HECMW_strcpy_f2c_r(var_name, len_var, vname, sizeof(vname)) == NULL) {
2403  return;
2404  }
2405 
2406  func = get_is_allocated_func(sname, vname);
2407  if (func == NULL) {
2409  "HECMW_mesh_is_allocated(): IsAllocatedFunc not found");
2410  return;
2411  }
2412 
2413  if ((*func)()) {
2414  *is_allocated = 1;
2415  } else {
2416  *is_allocated = 0;
2417  }
2418 
2419  *err = 0; /* no error */
2420 }
2421 
2422 /*----------------------------------------------------------------------------*/
2423 
2424 void hecmw_dist_copy_c2f_set_if(char *struct_name, char *var_name, void *dst,
2425  int *err, int len_struct, int len_var) {
2426  SetFunc func;
2427  char sname[HECMW_NAME_LEN + 1];
2428  char vname[HECMW_NAME_LEN + 1];
2429 
2430  *err = 1;
2431 
2432  if (mesh == NULL) {
2434  "mesh copy(C->Fortran): 'mesh' has not initialized yet");
2435  return;
2436  }
2437  if (struct_name == NULL) {
2438  HECMW_set_error(HECMW_ALL_E0101, "mesh copy(C->Fortran): 'sname' is NULL");
2439  return;
2440  }
2441  if (var_name == NULL) {
2442  HECMW_set_error(HECMW_ALL_E0101, "mesh copy(C->Fotran): 'vname' is NULL");
2443  return;
2444  }
2445  if (dst == NULL) {
2446  HECMW_set_error(HECMW_ALL_E0101, "mesh copy(C->Fortran): 'dst' is NULL");
2447  return;
2448  }
2449 
2450  if (HECMW_strcpy_f2c_r(struct_name, len_struct, sname, sizeof(sname)) ==
2451  NULL) {
2452  return;
2453  }
2454  if (HECMW_strcpy_f2c_r(var_name, len_var, vname, sizeof(vname)) == NULL) {
2455  return;
2456  }
2457 
2458  func = get_set_func(sname, vname);
2459  if (func == NULL) {
2461  "mesh copy(C->Fortran): SetFunc not found");
2462  return;
2463  }
2464 
2465  if ((*func)(dst)) {
2466  return;
2467  }
2468 
2469  *err = 0; /* no error */
2470 }
HECMW_Fint HECMW_Comm_c2f(HECMW_Comm comm)
Definition: hecmw_comm.c:715
#define HECMW_FILENAME_LEN
Definition: hecmw_config.h:72
MPI_Fint HECMW_Fint
Definition: hecmw_config.h:42
#define HECMW_HEADER_LEN
Definition: hecmw_config.h:68
#define HECMW_NAME_LEN
Definition: hecmw_config.h:70
int HECMW_dist_copy_c2f_init(struct hecmwST_local_mesh *local_mesh)
void hecmw_dist_copy_c2f_isalloc_if(char *struct_name, char *var_name, int *is_allocated, int *err, int len_struct, int len_var)
int(* IsAllocatedFunc)(void)
int HECMW_dist_copy_c2f_finalize(void)
int(* SetFunc)(void *)
void hecmw_dist_copy_c2f_set_if(char *struct_name, char *var_name, void *dst, int *err, int len_struct, int len_var)
int HECMW_set_error(int errorno, const char *fmt,...)
Definition: hecmw_error.c:37
#define NULL
int HECMW_strcpy_c2f(const char *cstr, char *fstr, int flen)
Definition: hecmw_lib_fc.c:72
char * HECMW_strcpy_f2c_r(const char *fstr, int flen, char *buf, int bufsize)
Definition: hecmw_lib_fc.c:45
#define HECMW_ALL_E0101
Definition: hecmw_msgno.h:8
#define HECMW_ALL_E0102
Definition: hecmw_msgno.h:9
int * amp_type_definition
Definition: hecmw_struct.h:61
double * amp_table
Definition: hecmw_struct.h:72
double * bc_grp_val
Definition: hecmw_struct.h:103
struct hecmwST_section * section
Definition: hecmw_struct.h:245
double * elem_val_item
Definition: hecmw_struct.h:205
double * elem_mat_int_val
Definition: hecmw_struct.h:203
struct hecmwST_amplitude * amp
Definition: hecmw_struct.h:248
struct hecmwST_material * material
Definition: hecmw_struct.h:246
struct hecmwST_refine_origin * refine_origin
Definition: hecmw_struct.h:253
double * node_val_item
Definition: hecmw_struct.h:178
struct hecmwST_mpc * mpc
Definition: hecmw_struct.h:247
struct hecmwST_node_grp * node_group
Definition: hecmw_struct.h:249
double * node_init_val_item
Definition: hecmw_struct.h:181
struct hecmwST_contact_pair * contact_pair
Definition: hecmw_struct.h:252
struct hecmwST_surf_grp * surf_group
Definition: hecmw_struct.h:251
long long * elem_node_index
Definition: hecmw_struct.h:195
char gridfile[HECMW_FILENAME_LEN+1]
Definition: hecmw_struct.h:154
char header[HECMW_HEADER_LEN+1]
Definition: hecmw_struct.h:157
HECMW_Comm HECMW_COMM
Definition: hecmw_struct.h:209
struct hecmwST_elem_grp * elem_group
Definition: hecmw_struct.h:250
int * when_i_was_refined_node
Definition: hecmw_struct.h:227
int * when_i_was_refined_elem
Definition: hecmw_struct.h:228
int * mat_subitem_index
Definition: hecmw_struct.h:42
double * mat_val
Definition: hecmw_struct.h:44
double * mat_temp
Definition: hecmw_struct.h:45
int * mpc_dof
Definition: hecmw_struct.h:52
double * mpc_val
Definition: hecmw_struct.h:53
double * mpc_const
Definition: hecmw_struct.h:54
int * mpc_index
Definition: hecmw_struct.h:50
int * mpc_item
Definition: hecmw_struct.h:51
double * bc_grp_val
Definition: hecmw_struct.h:89
double * sect_R_item
Definition: hecmw_struct.h:32
int * sect_mat_ID_index
Definition: hecmw_struct.h:27
int * sect_mat_ID_item
Definition: hecmw_struct.h:28
double * bc_grp_val
Definition: hecmw_struct.h:118