Skip to content

Commit d88c95a

Browse files
authored
Merge pull request #140 from swig-fortran/size-integer
Fix fortran typemaps for arrays on PGI
2 parents 54b2fa1 + 97dcfda commit d88c95a

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

Lib/fortran/fortranstrings.swg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ subroutine %fortrantm(fin, char*)(finp, iminp, temp)
2727
i = len(finp) + 1
2828
temp(i) = C_NULL_CHAR ! C finp compatibility
2929
iminp%data = c_loc(temp)
30-
iminp%size = len(finp)
30+
iminp%size = len(finp, kind=C_SIZE_T)
3131
end subroutine
3232
}
3333

Lib/fortran/fundamental.swg

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,16 +168,17 @@ SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() {
168168
use, intrinsic :: ISO_C_BINDING
169169
FTYPE, dimension(:), intent(in), target :: finp
170170
type(SwigArrayWrapper), intent(out) :: iminp
171+
integer(C_SIZE_T) :: sz
171172
FTYPE, pointer :: imtemp
172173

173-
if (size(finp) > 0) then
174+
sz = size(finp, kind=C_SIZE_T)
175+
if (sz > 0_c_size_t) then
174176
imtemp => finp(1)
175177
iminp%data = c_loc(imtemp)
176-
iminp%size = size(finp)
177178
else
178179
iminp%data = c_null_ptr
179-
iminp%size = 0
180180
end if
181+
iminp%size = sz
181182
end subroutine}
182183

183184
// Fragment for converting array wrapper to array

Lib/fortran/openacc.i

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
%typemap(fin, noblock=1, fragment="f_use_openacc") CPPTYPE {
3434
$1%data = acc_deviceptr($input)
35-
$1%size = size($input)
35+
$1%size = size($input, kind=c_int)
3636
}
3737

3838
%typemap(ftype, noblock=1) CPPTYPE {

0 commit comments

Comments
 (0)