Skip to content

Commit da3cd27

Browse files
author
Dag Sverre Seljebotn
committed
Make Fortran wrapper ifort-compatible and fix an issue with alm/geom_info%n_local == 0
1 parent 6d97931 commit da3cd27

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

fortran/sharp.f90

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ module sharp
2121

2222
type sharp_geom_info
2323
type(c_ptr) :: handle
24-
integer(c_ptrdiff_t) :: n_local
24+
integer(c_intptr_t) :: n_local
2525
end type sharp_geom_info
2626

2727
type sharp_alm_info
2828
type(c_ptr) :: handle
29-
integer(c_ptrdiff_t) :: n_local
29+
integer(c_intptr_t) :: n_local
3030
end type sharp_alm_info
3131

3232
interface
@@ -37,7 +37,7 @@ subroutine sharp_make_general_alm_info( &
3737
use iso_c_binding
3838
integer(c_int), value, intent(in) :: lmax, nm, stride, flags
3939
integer(c_int), intent(in) :: mval(nm)
40-
integer(c_ptrdiff_t), intent(in) :: mvstart(nm)
40+
integer(c_intptr_t), intent(in) :: mvstart(nm)
4141
type(c_ptr), intent(out) :: alm_info
4242
end subroutine sharp_make_general_alm_info
4343

@@ -51,7 +51,7 @@ end subroutine c_sharp_make_mmajor_real_packed_alm_info
5151

5252
function c_sharp_alm_count(alm_info) bind(c, name='sharp_alm_count')
5353
use iso_c_binding
54-
integer(c_ptrdiff_t) :: c_sharp_alm_count
54+
integer(c_intptr_t) :: c_sharp_alm_count
5555
type(c_ptr), value, intent(in) :: alm_info
5656
end function c_sharp_alm_count
5757

@@ -77,7 +77,7 @@ end subroutine c_sharp_destroy_geom_info
7777

7878
function c_sharp_map_size(info) bind(c, name='sharp_map_size')
7979
use iso_c_binding
80-
integer(c_ptrdiff_t) :: c_sharp_map_size
80+
integer(c_intptr_t) :: c_sharp_map_size
8181
type(c_ptr), value :: info
8282
end function c_sharp_map_size
8383

@@ -107,15 +107,15 @@ end subroutine c_sharp_execute_mpi
107107
subroutine c_sharp_legendre_transform(bl, recfac, lmax, x, out, nx) &
108108
bind(c, name='sharp_legendre_transform')
109109
use iso_c_binding
110-
integer(c_ptrdiff_t), value :: lmax, nx
110+
integer(c_intptr_t), value :: lmax, nx
111111
real(c_double) :: bl(lmax + 1), x(nx), out(nx)
112112
real(c_double), optional :: recfac(lmax + 1)
113113
end subroutine c_sharp_legendre_transform
114114

115115
subroutine c_sharp_legendre_transform_s(bl, recfac, lmax, x, out, nx) &
116116
bind(c, name='sharp_legendre_transform_s')
117117
use iso_c_binding
118-
integer(c_ptrdiff_t), value :: lmax, nx
118+
integer(c_intptr_t), value :: lmax, nx
119119
real(c_float) :: bl(lmax + 1), x(nx), out(nx)
120120
real(c_float), optional :: recfac(lmax + 1)
121121
end subroutine c_sharp_legendre_transform_s
@@ -237,8 +237,8 @@ subroutine sharp_execute_d(type, spin, nmaps, alm, alm_info, map, geom_info, &
237237

238238
! Set up pointer table to access maps
239239
do k = 1, nmaps
240-
alm_ptr(k) = c_loc(alm(0, k))
241-
map_ptr(k) = c_loc(map(0, k))
240+
if (alm_info%n_local > 0) alm_ptr(k) = c_loc(alm(0, k))
241+
if (geom_info%n_local > 0) map_ptr(k) = c_loc(map(0, k))
242242
end do
243243

244244
if (present(comm)) then
@@ -265,19 +265,19 @@ subroutine sharp_legendre_transform_d(bl, x, out)
265265
real(c_double) :: bl(:)
266266
real(c_double) :: x(:), out(size(x))
267267
!--
268-
integer(c_ptrdiff_t) :: lmax, nx
269-
call c_sharp_legendre_transform(bl, lmax=int(size(bl) - 1, c_ptrdiff_t), &
270-
x=x, out=out, nx=int(size(x), c_ptrdiff_t))
268+
integer(c_intptr_t) :: lmax, nx
269+
call c_sharp_legendre_transform(bl, lmax=int(size(bl) - 1, c_intptr_t), &
270+
x=x, out=out, nx=int(size(x), c_intptr_t))
271271
end subroutine sharp_legendre_transform_d
272272

273273
subroutine sharp_legendre_transform_s(bl, x, out)
274274
use iso_c_binding
275275
real(c_float) :: bl(:)
276276
real(c_float) :: x(:), out(size(x))
277277
!--
278-
integer(c_ptrdiff_t) :: lmax, nx
279-
call c_sharp_legendre_transform_s(bl, lmax=int(size(bl) - 1, c_ptrdiff_t), &
280-
x=x, out=out, nx=int(size(x), c_ptrdiff_t))
278+
integer(c_intptr_t) :: lmax, nx
279+
call c_sharp_legendre_transform_s(bl, lmax=int(size(bl) - 1, c_intptr_t), &
280+
x=x, out=out, nx=int(size(x), c_intptr_t))
281281
end subroutine sharp_legendre_transform_s
282282

283283

0 commit comments

Comments
 (0)