Comments (9)
Thanks for reporting, I'm sure we can come up with a fix. As you can see, Python does not allow optional arguments to come before non-optional ones. One possible solution would be to re-order the arguments, so the Python interface to the function above would become wrap(def_, opt=None)
. Would that be an acceptable solution?
(By the way, as a quick work around, if you don't need access to the routines that are causing this problem, you could omit them from the wrapper generation with the --skip
argument to f90wrap.)
from f90wrap.
Thank you very much for your reply.
One possible solution would be to re-order the arguments, so the Python interface to the function above would become wrap(def_, opt=None). Would that be an acceptable solution?
That was exactly the solution I was thinking so it's definitely an acceptable solution.
(By the way, as a quick work around, if you don't need access to the routines that are causing this problem, you could omit them from the wrapper generation with the --skip argument to f90wrap.)
Unfortunately, it's in some pretty big part of the program so we can't just skip them.
from f90wrap.
@jameskermode Just wondering whether you have any update on this? I'm thinking of writing a script which would reorder the variables during build time myself, if you are currently working on this and are making progress then I guess I'd wait.
from f90wrap.
Hi Nelson, sorry, I didn't manage to work on this yet. I'd hope to be able to do it in the next week or so.
Rather than writing a script to modify your Fortran, if I point you to the relevant part of the f90wrap
code would you be willing to try to add this feature directly? You would need to add a new subclass of FortranVisitor
to transform.py
and call this from transform_to_py_wrapper
. The new class should be similar to RenameArgumentsPython
but should instead re-order the arguments so any optionals come at the end.
from f90wrap.
Should now be fixed - as is often the case, it was not much work when I got round to it!
I added a version of your test case as a examples/optional_args_issue53
, and this is now working correctly. (Note that I had to change from a program to a standalone subroutine to get it to link correctly but this is unrelated to the wrapping issue).
I will leave this issue open for the moment,so you can let me know of any further problems, but if all is well we can close it soon.
from f90wrap.
Sorry for the late reply. I can't actually get f90wrap working again. Following my details in this issue, I will get the error:
ImportError: /home/theory/phukgm/Documents/test/_test.so: undefined symbol: wrap_
For ONETEP, I'm getting the error
ImportError: dynamic module does not define init function (PyInit__onetep)
I feel like this is simply a setup issue with my system, but I can't quite figure out what.
from f90wrap.
I think the first error may be due to how you set up the Fortran code to be wrapped. Can you try to build the example in f90wrap/examples/optional_args_issue53
by running make
from that directory?
from f90wrap.
I get ImportError: dynamic module does not define init function (PyInit_sizeof_fortran_t)
during the make process.
from f90wrap.
Fixed (in person rather than on Github!). Problem as a mixture of Python 2 and 3, and of intel and GNU compilers.
from f90wrap.
Related Issues (20)
- IndentationError with python 3.9 HOT 5
- Extra (unnecessary) newline character in .py file for long variable names HOT 3
- more explanations on the provided examples HOT 2
- Handling reserved Python words in f90wrap HOT 6
- Help wrapping a project HOT 7
- Data type determined at run time
- Issues with Compiling MPI Program HOT 3
- Support for Intel oneAPI2022
- multidimensional arrays in derived types broken if compiled with long integers as default HOT 1
- Python 3.11 support HOT 8
- Pre-build f90wrap wheels for windows HOT 3
- Derived types containing allocatable character arrays
- `integer, value, intent(in)`/`integer, value` arguments converted to/wrapped as `real`
- Wrong module class name in a call to `f90wrap.runtime.FortranDerivedTypeArray` HOT 2
- numpy > 1.23 support HOT 2
- Switch to pyproject.toml based build system HOT 7
- duplicate symbol in formal argument list HOT 2
- Issues on Mac OS X - for f90wrap 0.2.12 HOT 1
- BUG: Routines including procedure arguments (callbacks) are excluded HOT 1
- Can `f90wrap`parse FORD docstrings?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from f90wrap.