pearu / f2py

Automatically exported from code.google.com/p/f2py
Other
54 stars 38 forks source link

AssertionError when compiling dcuhre #47

Open maxnoe opened 6 years ago

maxnoe commented 6 years ago

Trying to wrap this integration module: https://jblevins.org/mirror/amiller/dcuhre.f90, I get the following error, I have no idea, where I need to start debugging. Any help will be appreciated.

running build
running config_cc
unifing config_cc, config, build_clib, build_ext, build commands --compiler options
running config_fc
unifing config_fc, config, build_clib, build_ext, build commands --fcompiler options
running build_src
build_src
building extension "dcuhre" sources
f2py options: []
f2py:> /tmp/tmpvlbnqe4n/src.linux-x86_64-3.6/dcuhremodule.c
creating /tmp/tmpvlbnqe4n/src.linux-x86_64-3.6
Reading fortran codes...
    Reading file 'dcuhre.f90' (format:free)
rmbadname1: Replacing "index" with "index_bn".
rmbadname1: Replacing "index" with "index_bn".
rmbadname1: Replacing "index" with "index_bn".
Traceback (most recent call last):
  File "/home/maxnoe/.local/anaconda3/bin/f2py", line 28, in <module>
    main()
  File "/home/maxnoe/.local/anaconda3/lib/python3.6/site-packages/numpy/f2py/f2py2e.py", line 648, in main
    run_compile()
  File "/home/maxnoe/.local/anaconda3/lib/python3.6/site-packages/numpy/f2py/f2py2e.py", line 633, in run_compile
    setup(ext_modules=[ext])
  File "/home/maxnoe/.local/anaconda3/lib/python3.6/site-packages/numpy/distutils/core.py", line 169, in setup
    return old_setup(**new_attr)
  File "/home/maxnoe/.local/anaconda3/lib/python3.6/distutils/core.py", line 148, in setup
    dist.run_commands()
  File "/home/maxnoe/.local/anaconda3/lib/python3.6/distutils/dist.py", line 955, in run_commands
    self.run_command(cmd)
  File "/home/maxnoe/.local/anaconda3/lib/python3.6/distutils/dist.py", line 974, in run_command
    cmd_obj.run()
  File "/home/maxnoe/.local/anaconda3/lib/python3.6/site-packages/numpy/distutils/command/build.py", line 47, in run
    old_build.run(self)
  File "/home/maxnoe/.local/anaconda3/lib/python3.6/distutils/command/build.py", line 135, in run
    self.run_command(cmd_name)
  File "/home/maxnoe/.local/anaconda3/lib/python3.6/distutils/cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "/home/maxnoe/.local/anaconda3/lib/python3.6/distutils/dist.py", line 974, in run_command
    cmd_obj.run()
  File "/home/maxnoe/.local/anaconda3/lib/python3.6/site-packages/numpy/distutils/command/build_src.py", line 148, in run
    self.build_sources()
  File "/home/maxnoe/.local/anaconda3/lib/python3.6/site-packages/numpy/distutils/command/build_src.py", line 165, in build_sources
    self.build_extension_sources(ext)
  File "/home/maxnoe/.local/anaconda3/lib/python3.6/site-packages/numpy/distutils/command/build_src.py", line 327, in build_extension_sources
    sources = self.f2py_sources(sources, ext)
  File "/home/maxnoe/.local/anaconda3/lib/python3.6/site-packages/numpy/distutils/command/build_src.py", line 564, in f2py_sources
    ['-m', ext_name]+f_sources)
  File "/home/maxnoe/.local/anaconda3/lib/python3.6/site-packages/numpy/f2py/f2py2e.py", line 408, in run_main
    postlist = callcrackfortran(files, options)
  File "/home/maxnoe/.local/anaconda3/lib/python3.6/site-packages/numpy/f2py/f2py2e.py", line 329, in callcrackfortran
    postlist = crackfortran.crackfortran(files)
  File "/home/maxnoe/.local/anaconda3/lib/python3.6/site-packages/numpy/f2py/crackfortran.py", line 3246, in crackfortran
    readfortrancode(files, crackline)
  File "/home/maxnoe/.local/anaconda3/lib/python3.6/site-packages/numpy/f2py/crackfortran.py", line 510, in readfortrancode
    dowithline(finalline)
  File "/home/maxnoe/.local/anaconda3/lib/python3.6/site-packages/numpy/f2py/crackfortran.py", line 781, in crackline
    analyzeline(m, pat[1], line)
  File "/home/maxnoe/.local/anaconda3/lib/python3.6/site-packages/numpy/f2py/crackfortran.py", line 1087, in analyzeline
    last_name = updatevars(typespec, selector, attr, edecl)
  File "/home/maxnoe/.local/anaconda3/lib/python3.6/site-packages/numpy/f2py/crackfortran.py", line 1543, in updatevars
    el = [x.strip() for x in markoutercomma(entitydecl).split('@,@')]
  File "/home/maxnoe/.local/anaconda3/lib/python3.6/site-packages/numpy/f2py/crackfortran.py", line 821, in markoutercomma
    assert not f, repr((f, line, l, cc))
AssertionError: (2, ' dim2w(14,5) = reshape( (/   0.3379692360134460d-01,  0.9508589607597761d-01, 0.1176006468056962d+00,  0.2657774586326950d-01, 0.1701441770200640d-01,  0.0000000000000000d+00, 0.1626593098637410d-01,  0.1344892658526199d+00, 0.1328032165460149d+00,  0.5637474769991870d-01, 0.3908279081310500d-02,  0.3012798777432150d-01, 0.1030873234689166d+00, 0.6250000000000000d-01, ', ' dim2w(14,5) = reshape( (/   0.3379692360134460d-01,  0.9508589607597761d-01, 0.1176006468056962d+00,  0.2657774586326950d-01, 0.1701441770200640d-01,  0.0000000000000000d+00, 0.1626593098637410d-01,  0.1344892658526199d+00, 0.1328032165460149d+00,  0.5637474769991870d-01, 0.3908279081310500d-02,  0.3012798777432150d-01, 0.1030873234689166d+00, 0.6250000000000000d-01, ', ')')
pearu commented 6 years ago

This is f2py bug in "parsing" the fortran code and the place to start fixing it would be to check why the assert statement fails and work out a fix.

You can use the following workaround to continue with your project:

  1. Make a copy of dcuhre.f90, say dcuhre-mine.f90
  2. Remove the problematic declaration REAL (dp), PARAMETER :: dim2w(14,5) = RESHAPE ... from dcuhre-mine.f90 (it is local to function and f2py does not use it).
  3. Generate a signature file: f2py -h mymod.pyf -m mymod dcuhre-mine.f90
  4. Build extension module: f2py -c mymod.pyf dcuhre.f90
maxnoe commented 6 years ago

I found out that it was the empty lines in the array declaration