Skip to content

Commit 582c7dc

Browse files
committed
Use high-level wrappers as subroutines
1 parent e9e2d26 commit 582c7dc

6 files changed

+983
-167
lines changed

include/formetis.i

+3-6
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,15 @@ extern const int formetis_version_patch;
3838
#include <metis.h>
3939
%}
4040

41-
// Directly bind all API functions
42-
%fortranbindc;
4341
// Use parameters rather than linked constants
4442
%fortranconst;
4543

46-
// Apply array maps to pointers
47-
%typemap(bindc, in="$typemap(bindc, $1_basetype), dimension(*), target") real_t* , idx_t*
48-
"$typemap(bindc, $1_basetype), dimension(*)";
49-
5044
// Remove METIS_ prefix from bindings
5145
%rename("%(strip:[METIS_])s") "";
5246

47+
// All "functions" are really subroutines with return values
48+
%fortransubroutine;
49+
5350
%include <metis.h>
5451

5552
/* -------------------------------------------------------------------------

include/formetis_utils.i

+21
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,24 @@
1919
*/
2020
%}
2121
%enddef
22+
23+
// Apply array maps to pointers
24+
%typemap(ftype, in="$typemap(bindc, $1_basetype), dimension(*), target") real_t*, idx_t*
25+
"$typemap(bindc, $1_basetype), dimension(*)";
26+
%typemap(imtype, in="type(C_PTR), value") real_t*, idx_t*
27+
"type(C_PTR)";
28+
%typemap(ctype) real_t*, idx_t*
29+
"$typemap(ctype, $*1_ltype)*";
30+
%typemap(in, noblock=1) real_t*, idx_t* {
31+
$1 = ($1_ltype)($input);
32+
}
33+
%typemap(out) real_t*, idx_t*
34+
"$result = $1;"
35+
%typemap(fin) real_t*, idx_t*
36+
"$1 = c_loc($input)"
37+
%typemap(fout) real_t*, idx_t*
38+
"call c_f_pointer($1, $result)"
39+
40+
// Apply array maps to pointers (bindc mode)
41+
%typemap(bindc, in="$typemap(bindc, $1_basetype), dimension(*), target") real_t* , idx_t*
42+
"$typemap(bindc, $1_basetype), dimension(*)";

include/forparmetis.i

+2-16
Original file line numberDiff line numberDiff line change
@@ -35,21 +35,7 @@
3535
// Remove ParMETIS_V3 prefix from bindings
3636
%rename("%(regex:/^ParMETIS(_V3)?(2)?_(.*)/\\3\\2/)s") "";
3737

38-
// Apply array maps to pointers
39-
%typemap(ftype, in="$typemap(bindc, $1_basetype), dimension(*), target") real_t*, idx_t*
40-
"$typemap(bindc, $1_basetype), dimension(*)";
41-
%typemap(imtype, in="type(C_PTR), value") real_t*, idx_t*
42-
"type(C_PTR)";
43-
%typemap(ctype) real_t*, idx_t*
44-
"$typemap(ctype, $*1_ltype)*";
45-
%typemap(in, noblock=1) real_t*, idx_t* {
46-
$1 = ($1_ltype)($input);
47-
}
48-
%typemap(out) real_t*, idx_t*
49-
"$result = $1;"
50-
%typemap(fin) real_t*, idx_t*
51-
"$1 = c_loc($input)"
52-
%typemap(fout) real_t*, idx_t*
53-
"call c_f_pointer($1, $result)"
38+
// All "functions" are really subroutines with return values
39+
%fortransubroutine;
5440

5541
%include <parmetis.h>

0 commit comments

Comments
 (0)