Skip to content

Commit 34eaa18

Browse files
committedMay 31, 2021
Use optional arguments to pass null pointers to METIS
1 parent 582c7dc commit 34eaa18

File tree

4 files changed

+1014
-204
lines changed

4 files changed

+1014
-204
lines changed
 

‎README.md

+5
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,8 @@ compiler, and building requires a C compiler. If building with a modified
88
(64-bit) version of METIS, the [SWIG-Fortran
99
tool](https://github.com/swig-fortran/swig) is required to regenerate the
1010
bindings.
11+
12+
This library is primarily a proof of concept, a demonstration of rapidly adding
13+
Fortran bindings to an external library. For a better-documented library in
14+
high-level Fortran, see the unaffiliated [Fmetis
15+
project](https://github.com/ivan-pi/fmetis).

‎include/formetis_utils.i

+9-4
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
%enddef
2222

2323
// Apply array maps to pointers
24-
%typemap(ftype, in="$typemap(bindc, $1_basetype), dimension(*), target") real_t*, idx_t*
24+
%typemap(ftype, in="$typemap(bindc, $1_basetype), dimension(*), target, optional") real_t*, idx_t*
2525
"$typemap(bindc, $1_basetype), dimension(*)";
2626
%typemap(imtype, in="type(C_PTR), value") real_t*, idx_t*
2727
"type(C_PTR)";
@@ -32,10 +32,15 @@
3232
}
3333
%typemap(out) real_t*, idx_t*
3434
"$result = $1;"
35-
%typemap(fin) real_t*, idx_t*
36-
"$1 = c_loc($input)"
35+
%typemap(fin, noblock=1) real_t*, idx_t* {
36+
if (present($input)) then
37+
$1 = c_loc($input)
38+
else
39+
$1 = C_NULL_PTR
40+
endif
41+
}
3742
%typemap(fout) real_t*, idx_t*
38-
"call c_f_pointer($1, $result)"
43+
"call c_f_pointer($1, $result)";
3944

4045
// Apply array maps to pointers (bindc mode)
4146
%typemap(bindc, in="$typemap(bindc, $1_basetype), dimension(*), target") real_t* , idx_t*

‎src/formetis.f90

+445-89
Large diffs are not rendered by default.

‎src/forparmetis.f90

+555-111
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)
Please sign in to comment.