jameskermode/f90wrap

Parser fails on asterisk in subroutine argument list

krystophny opened this issue · 2 comments

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.

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

Ah, I see you did already, thanks!