Code Monkey home page Code Monkey logo

Comments (15)

lstagner avatar lstagner commented on July 18, 2024

I have been able to avoid this problem by separating my program and module definitions into different files. I am able to run f90wrap (after defining a kind map) but I run into the the following error when I try to run f2py

...
Line #10712 in f90wrap_libfida.f90:"          intent(hide), depend(nlaunch) :: n3 = shape(nlaunch,0)"
	analyzeline: cannot handle multiple attributes without type specification. Ignoring ' depend(nlaunch)'.
Line #10714 in f90wrap_libfida.f90:"          intent(hide), depend(nlaunch) :: n4 = shape(nlaunch,1)"
	analyzeline: cannot handle multiple attributes without type specification. Ignoring ' depend(nlaunch)'.
Line #10716 in f90wrap_libfida.f90:"          intent(hide), depend(nlaunch) :: n5 = shape(nlaunch,2)"
	analyzeline: cannot handle multiple attributes without type specification. Ignoring ' depend(nlaunch)'.
Line #10929 in f90wrap_libfida.f90:"    use libfida, only: assignment(=), profiles"
	analyzeline: Not local=>use pattern found in 'assignment(=)'
Traceback (most recent call last):
  File "/home/lstagner/anaconda3/bin/f2py", line 28, in <module>
    main()
  File "/home/lstagner/anaconda3/lib/python3.5/site-packages/numpy/f2py/f2py2e.py", line 648, in main
    run_compile()
  File "/home/lstagner/anaconda3/lib/python3.5/site-packages/numpy/f2py/f2py2e.py", line 633, in run_compile
    setup(ext_modules=[ext])
  File "/home/lstagner/anaconda3/lib/python3.5/site-packages/numpy/distutils/core.py", line 169, in setup
    return old_setup(**new_attr)
  File "/home/lstagner/anaconda3/lib/python3.5/distutils/core.py", line 148, in setup
    dist.run_commands()
  File "/home/lstagner/anaconda3/lib/python3.5/distutils/dist.py", line 955, in run_commands
    self.run_command(cmd)
  File "/home/lstagner/anaconda3/lib/python3.5/distutils/dist.py", line 974, in run_command
    cmd_obj.run()
  File "/home/lstagner/anaconda3/lib/python3.5/site-packages/numpy/distutils/command/build.py", line 47, in run
    old_build.run(self)
  File "/home/lstagner/anaconda3/lib/python3.5/distutils/command/build.py", line 135, in run
    self.run_command(cmd_name)
  File "/home/lstagner/anaconda3/lib/python3.5/distutils/cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "/home/lstagner/anaconda3/lib/python3.5/distutils/dist.py", line 974, in run_command
    cmd_obj.run()
  File "/home/lstagner/anaconda3/lib/python3.5/site-packages/numpy/distutils/command/build_src.py", line 147, in run
    self.build_sources()
  File "/home/lstagner/anaconda3/lib/python3.5/site-packages/numpy/distutils/command/build_src.py", line 164, in build_sources
    self.build_extension_sources(ext)
  File "/home/lstagner/anaconda3/lib/python3.5/site-packages/numpy/distutils/command/build_src.py", line 326, in build_extension_sources
    sources = self.f2py_sources(sources, ext)
  File "/home/lstagner/anaconda3/lib/python3.5/site-packages/numpy/distutils/command/build_src.py", line 563, in f2py_sources
    ['-m', ext_name]+f_sources)
  File "/home/lstagner/anaconda3/lib/python3.5/site-packages/numpy/f2py/f2py2e.py", line 408, in run_main
    postlist = callcrackfortran(files, options)
  File "/home/lstagner/anaconda3/lib/python3.5/site-packages/numpy/f2py/f2py2e.py", line 329, in callcrackfortran
    postlist = crackfortran.crackfortran(files)
  File "/home/lstagner/anaconda3/lib/python3.5/site-packages/numpy/f2py/crackfortran.py", line 3216, in crackfortran
    readfortrancode(files, crackline)
  File "/home/lstagner/anaconda3/lib/python3.5/site-packages/numpy/f2py/crackfortran.py", line 511, in readfortrancode
    dowithline(finalline)
  File "/home/lstagner/anaconda3/lib/python3.5/site-packages/numpy/f2py/crackfortran.py", line 782, in crackline
    analyzeline(m, pat[1], line)
  File "/home/lstagner/anaconda3/lib/python3.5/site-packages/numpy/f2py/crackfortran.py", line 936, in analyzeline
    for x in markoutercomma(args).split('@,@')])
  File "/home/lstagner/anaconda3/lib/python3.5/site-packages/numpy/f2py/crackfortran.py", line 822, in markoutercomma
    assert not f, repr((f, line, l, cc))
AssertionError: (1, '=@)@@(@p1=p1_ptr%p, p2=p2_ptr%p', '=@)@@(@p1=p1_ptr%p, p2=p2_ptr%p', ')')

Any assistance would be appreciated.

from f90wrap.

jameskermode avatar jameskermode commented on July 18, 2024

Thanks for reporting, I'll have a look ASAP.

from f90wrap.

jameskermode avatar jameskermode commented on July 18, 2024

The missing Program uses clause is now fixed. The second error was caused by the overloaded assignment(=) interface, which should be converted to Fortran code along the lines of a = b instead of call assignment(=)(a, b). I just pushed a fix for this as well, which allows me to wrap your fidasim.f90 module, but I haven't tested thoroughly so please report back before we close this issue. Also, would you be happy for me to add this fidasim as an example/regression test?

from f90wrap.

lstagner avatar lstagner commented on July 18, 2024

Thanks for addressing this quickly. I/we will try out the changes shortly (@kgage).

What does making fidasim a regression test involve?

from f90wrap.

lstagner avatar lstagner commented on July 18, 2024

I still having issues with creating the wrapper. The f90wrap stage works now however when I get to the f2py stage I'm getting a bunch of the following errors

f90wrap_fidasim.f90:10941:4:

     p1=p1_ptr%p = p2=p2_ptr%p
    1
Error: Unclassifiable statement at (1)

The error occurs in the assignment operator wrappers.

Here is how I am envoking f90wrap/f2py
D3DEnergetic/FIDASIM@b65dcf4

from f90wrap.

jameskermode avatar jameskermode commented on July 18, 2024

Can you try using the modified version of f2py distributed with f90wrap, f2py-f90wrap? This is working for me with your code.

By making it a regression test I mean including findasim.f90 in the examples/ directory and writing a short Python test script that runs some of the functions.

from f90wrap.

lstagner avatar lstagner commented on July 18, 2024

I tried using f2py-f90wrap as you suggested and the same error persists. Additionally the error occurs on both python 2 and 3. Here is the generated f90wrap_fidasim.f90 file https://gist.github.com/lstagner/9a25148bfce36f546a118a9bc55ed44e

from f90wrap.

jameskermode avatar jameskermode commented on July 18, 2024

You are right, there is still a bug in the Fortran wrapper generation. Not sure how I missed that. Fix coming shortly.

from f90wrap.

jameskermode avatar jameskermode commented on July 18, 2024

Try now - last commit leads to f2py-generated C code that compiles, but I didn't try to link with your library or test the Python interface.

In any case, I'm not sure how best to expose assignment(=) interfaces from Python. For now I simply renamed to assignment to avoid syntax errors, but I don't think it is that useful.

from f90wrap.

jameskermode avatar jameskermode commented on July 18, 2024

Commit 65119c8 fixes one further issue: you have Fortran elements named class which need to be renamed to avoid clashing with the Python reserved word.

from f90wrap.

lstagner avatar lstagner commented on July 18, 2024

I am having openmp issues (_libfida.cpython-35m-x86_64-linux-gnu.so: undefined symbol: GOMP_parallel) with python 3 but I can get it to work with python 2.

I do have one other issue. The module variables defined here (https://github.com/D3DEnergetic/FIDASIM/blob/master/src/fidasim.f90#L959) are not in the python module.

from f90wrap.

jameskermode avatar jameskermode commented on July 18, 2024

Linking with -lgfortran -lgomp may help with your OpenMP issues.

I'm not sure which module variables you mean are missing - are they public?

from f90wrap.

lstagner avatar lstagner commented on July 18, 2024

I was able to get the wrapper to work with python 3. The definitions of the module variables start here(they are public) Unlike the other module variables that were wrapped, these variables are instances of derived types. Are they not supported?

from f90wrap.

jameskermode avatar jameskermode commented on July 18, 2024

As can be seen in the f90wrap log output, these instances are removed as derived type instances in modules can only be wrapped if they have the target attribute - this is because we have to be able to attach pointers to them. If you are able to add target attributes to your Fortran sources they will appear in Python. I appreciated this should be better documented, pull requests welcome...

from f90wrap.

lstagner avatar lstagner commented on July 18, 2024

Yes, that fixed the issue. Thanks for all your help with this. In regards to adding fidasim to the example directory I don't think it would be practical because of its dependencies. I would however be happy to list fidasim in the readme as a case study that uses f90wrap once I have made it ready for public consumption.

from f90wrap.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.