Closed kaanaksit closed 3 years ago
A new version of this library that contains both Matlab and python bindings is maintained by Alex Barnett at Flatiron Institute:
https://finufft.readthedocs.io/en/latest https://github.com/flatironinstitute/finufft
It is also straightforward to create python wrappers to Fortran90 code using f2py:
https://numpy.org/doc/stable/f2py/f2py.getting-started.html#the-quick-and-smart-way
Thank you for your reply! finufft
isn't really usable as far as I have experimented with it.
I wanted to give f2py
way a test by
python3 -m numpy.f2py -c -m nufft2d nufft2df90.f nufft2d_demof90.f dirft2d.f dfft.f next235.f
my gfortran,python versions are as follows:
gfortran --version
GNU Fortran (Ubuntu 10.2.0-13ubuntu1) 10.2.0
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
python3 --version
Python 3.8.6
and here are errors that popped up at the end of the compilation:
Error: Type mismatch in argument ‘ifac’ at (1); passed REAL(8) to INTEGER(4)
dfft.f:2758:72:
2758 | CALL DFFTF1 (N,R,WSAVE,WSAVE(N+1),WSAVE(2*N+1))
| 1
Error: Type mismatch in argument ‘ifac’ at (1); passed REAL(8) to INTEGER(4)
dfft.f:2691:72:
2691 | CALL DFFTB1 (N,R,WSAVE,WSAVE(N+1),WSAVE(2*N+1))
| 1
Error: Type mismatch in argument ‘ifac’ at (1); passed REAL(8) to INTEGER(4)
dfft.f:877:72:
877 | CALL ZFFTB1 (N,C,WSAVE,WSAVE(IW1),WSAVE(IW2))
| 1
Error: Type mismatch in argument ‘ifac’ at (1); passed REAL(8) to INTEGER(4)
dfft.f:948:72:
948 | CALL ZFFTF1 (N,C,WSAVE,WSAVE(IW1),WSAVE(IW2))
| 1
Error: Type mismatch in argument ‘ifac’ at (1); passed REAL(8) to INTEGER(4)
dfft.f:1019:72:
1019 | CALL ZFFTI1 (N,WSAVE(IW1),WSAVE(IW2))
| 1
Error: Type mismatch in argument ‘ifac’ at (1); passed REAL(8) to INTEGER(4)
dfft.f:1354:72:
1354 | CALL DZFFT1 (N,WSAVE(2*N+1),WSAVE(3*N+1))
| 1
Error: Type mismatch in argument ‘ifac’ at (1); passed REAL(8) to INTEGER(4)
dfft.f:2935:72:
2935 | CALL DSINT1(N,X,WSAVE,WSAVE(IW1),WSAVE(IW2),WSAVE(IW3))
| 1
Error: Type mismatch in argument ‘ifac’ at (1); passed REAL(8) to INTEGER(4)
I have also found this repository on github, and it looks like this ends up with the same problem.
gfortran-10 has obsoleted perfectly valid Fortran77 and Fortran90 codes, that use argument type mismatch. It is possible to turn the support back on by using -std=legacy command line flag. Please let me know, if that fixes this issue.
Thank you for your fast reply! May I ask how do I use -std=legacy
syntax in the case of numpy.f2py
?
and I do confirm fortran compilation works with -std=legacy
:
gfortran-10 -std=legacy nufft2df90.f nufft2d_demof90.f dirft2d.f dfft.f next235.f
At the very least, I can see I get no error, just warnings.
This seems to complete numpy.f2py
without any errors:
python3 -m numpy.f2py -c -m nufft2d nufft2df90.f nufft2d_demof90.f dirft2d.f dfft.f next235.f --f90flags="-std=legacy"
and I can import created library as follows:
ipython3
Python 3.8.6 (default, Sep 25 2020, 09:36:53)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.17.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: import nufft2d
Not completely sure about numpy.f2py script, but you can specify extra compiler flags to f2py. A good workaround is to use the standard gcc-9 compiler that comes with Ubuntu 20.04LTS, or to install gcc-8 compiler.
So this gets me to my next question, assume that I am going to use this library in an another open-source project. What is the best practice for that?
*.so
to the project?Unfortunately, I am not familiar with python packaging systems. You can try to look how to interface with pip by creating a proper setup.py file.
The reason why I am asking advice here is not because I need guidance in python packaging systems but because I do not want to scoop your work. If there is a good way to favour your work, I want to do that. Otherwise, I will just follow what the other library did and copy your files to a new repository, and we can consider this issue closed in that case.
I see. This library is distributed under the two-clause simplified BSD license with is compatible with most open-source licenses. Please see license.txt for the terms.
Thank you for putting this all together. Is there or will there be a python wrapper for your code?