GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — BUG,MAINT: `f2py` doesn't map `iso_c_binding` values by default · Issue #24553 · numpy/numpy Closed DescriptionReproducerConsider: ! isoc_oddity.f90
module coddity
use iso_c_binding, only: c_double
implicit none
contains
subroutine c_add(a, b, c) bind(c, name="c_add")
real(c_double), intent(in) :: a, b
real(c_double), intent(out) :: c
print*, "a is", a
print*, "b is", b
c = a + b
end subroutine c_add
end module coddityWhich compiles fine but doesn't do what one might expect: python -m numpy.f2py -c isoc_oddity.f90 -m buggy
python -c 'import buggy;res=buggy.coddity.c_add(1, 2); print(f"res: {res}, exp: 3, eq: {res==3}")'
a is 2.0000004731118679
b is 5.3049894774131808E-315
res: 1.0, exp: 3, eq: FalseClearly, # isoc_f2cmap dict( real=dict(c_double="double"), ) Will work correctly: python -m numpy.f2py -c isoc_oddity.f90 -m buggy --f2cmap isoc_f2cmap
python -c 'import buggy;res=buggy.coddity.c_add(1, 2); print(f"res: {res}, exp: 3, eq: {res==3}")'
a is 1.0000000000000000
b is 2.0000000000000000
res: 3.0, exp: 3, eq: TrueSuggestionThis is definitely unexpected behavior, Reacted by Ralf Gommers Activity
MetadataMetadataAssigneesTypeProjectsMilestoneRelationshipsDevelopmentIssue actions |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |