Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extra (unnecessary) newline character in .py file for long variable names #155

Open
nenanth opened this issue Jun 12, 2021 · 3 comments
Open

Comments

@nenanth
Copy link

nenanth commented Jun 12, 2021

I tried out the latest f90wrap (0.2.3) for wrapping a legacy fortran project, and noticed that in the f90wrap-generated .py file, there are some unnecessary newline characters introduced in the setter methods when the variable names are over a certain size.

Luckily for me, this happened with only 2 variables, so I could manually change it to continue working. However, for derived types with many long variable names, I can see this being an issue.

Something in the source code generator needs to check whether there is a LHS for the expression in the setter method (is there ever a return value for these?) and not introduce the newline character \

@jameskermode
Copy link
Owner

Thanks for reporting, but I don’t quite understand the problem. Could you provide a minimal example?

@nenanth
Copy link
Author

nenanth commented Jun 13, 2021

Sure!
Here's a simple example in zip format. I've also included some Fortran + CMake scripts to handle compilation across all platforms.

To test,

  1. create a build/ directory (can call it anything) under cmake/
  2. cd to build/
  3. FC=gfortran cmake ../../
  4. make

test.py will be created in main folder, try to import it and you may see something like this:

>>> import test

----------------------------------------------------------------------------------------------
<stdin> 1 <module>
1

IndentationError:
expected an indented block
('/Users/ananthsridharan/codes/f90wrap_test/test.py', 33, 13, '            _test.f90wrap_highest_level__set__thisisaveryveryverylongvariablename(thisisaveryveryverylongvariablename)\n')
/Users/ananthsridharan/codes/f90wrap_test/test.py

Actual fortran module looks very simple
module blah
real(kind=8) :: thisisaveryveryveryveryveryverylongvariablename
end module

@nenanth
Copy link
Author

nenanth commented Jun 13, 2021

f90wrap_test.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants