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

Parser fails on asterisk in subroutine argument list #206

Closed
krystophny opened this issue Feb 20, 2024 · 2 comments · Fixed by #207
Closed

Parser fails on asterisk in subroutine argument list #206

krystophny opened this issue Feb 20, 2024 · 2 comments · Fixed by #207

Comments

@krystophny
Copy link
Contributor

Applying f90wrap to a code containing old-style routine headers like

SUBROUTINE odeint(ystart,nvar,x1,x2,eps,h1,hmin,nok,nbad,derivs,*rkqs)

with an asterisk throws an exception

Traceback (most recent call last):
  File "/home/ert/code/.venv/lib/python3.10/site-packages/f90wrap/scripts/main.py", line 304, in main
    parse_tree = fparse.read_files(args.files, doc_plugin_filename=doc_plugin_fname)
  File "/home/ert/code/.venv/lib/python3.10/site-packages/f90wrap/parser.py", line 1538, in read_files
    check = check_subt(cline, file)
  File "/home/ert/code/.venv/lib/python3.10/site-packages/f90wrap/parser.py", line 677, in check_subt
    del (argl[len(argl) - 1])
IndexError: list assignment index out of range
f90wrap: IndexError('list assignment index out of range')
         for help use --help

This happens even when the subroutine is skipped by --skip which was the workaround in f2py before.

Fix: Catch the condition when the header is not identified, e.g. in parser.py:671 replace

if has_args:

by

if has_args and ')' in cl:

Then the parser stage is passed and the subroutine can be skipped later.

@jameskermode
Copy link
Owner

Thanks for reporting. Would you be willing to open a PR with the fix and a new example that would have caught this problem?

@jameskermode
Copy link
Owner

Ah, I see you did already, thanks!

@jameskermode jameskermode linked a pull request Feb 20, 2024 that will close this issue
jameskermode added a commit that referenced this issue Feb 20, 2024
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

Successfully merging a pull request may close this issue.

2 participants