Comments (15)
Hi @Vutshi . thanks for report it. It's right that -l
and -L are not exposed to %%fortran
. I could support them, but, just to learn, Do u know which would be the difference with the f2py's --link-*
option (which is already available in the magic)?
from fortran_magic.
Hi Martín,
I'm new to f2py so I might be wrong. As far as I understand --link-* works with something which is already exposed to the system (so numpy knows about it). -L and -l allows you to use your own library and don't mess with the system settings.
from fortran_magic.
so, what do you think about to generalize in an --extra
option to pass all not explicitly defined flags ?
for example
%%fortran --extra ' -L/path_to_lib/lib -lopenblas -I/path/to/include/'
<code>
Also it would be nice to pass -03 to f2py
this could be done with --opt
%%fortran --opt "-O3"
from fortran_magic.
I think the --extra
option is a good idea.
The --opt
option is already occupied for me by --opt=-march=native
. However, it is not a problem since --extra
will take care about -O3 and anything else.
from fortran_magic.
I've implemented this. Please, upgrade and thy this.
%%fortran --extra ' -L/path_to_lib/lib -lopenblas -I/path/to/include/' --opt "-march=native -O3"
let me know if everything is ok.
cheers
martin
from fortran_magic.
Something is going wrong. I run the simple test:
%%fortran
subroutine f1(x, y, z)
real, intent(in) :: x,y
real, intent(out) :: z
z = sin(x+y)
end subroutine f1
and get the error:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-4-7c7c0006c542> in <module>()
----> 1 get_ipython().run_cell_magic(u'fortran', u'', u'subroutine f1(x, y, z)\n real, intent(in) :: x,y\n real, intent(out) :: z\n\n z = sin(x+y)\n\nend subroutine f1')
/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/IPython/core/interactiveshell.pyc in run_cell_magic(self, magic_name, line, cell)
2127 magic_arg_s = self.var_expand(line, stack_depth)
2128 with self.builtin_trap:
-> 2129 result = fn(magic_arg_s, cell)
2130 return result
2131
/Users/devasi/.ipython/extensions/fortranmagic.pyc in fortran(self, line, cell)
/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/IPython/core/magic.pyc in <lambda>(f, *a, **k)
189 # but it's overkill for just that one bit of state.
190 def magic_deco(arg):
--> 191 call = lambda f, *a, **k: f(*a, **k)
192
193 if callable(arg):
/Users/devasi/.ipython/extensions/fortranmagic.pyc in fortran(self, line, cell)
332 verbosity=args.verbosity)
333
--> 334 self._code_cache[key] = module_name
335 module = imp.load_dynamic(module_name, module_path)
336 self._import_all(module, verbosity=args.verbosity)
TypeError: unhashable type: 'list'
from fortran_magic.
ups. thats why we need tests.
ps: I`ll fix it in a moment
El 07/10/2013 11:48, "Denis Vasilyev" [email protected] escribió:
Something is going wrong. I run the simple test:
%%fortran
subroutine f1(x, y, z)
real, intent(in) :: x,y
real, intent(out) :: zz = sin(x+y)
end subroutine f1
and get the error:
TypeError Traceback (most recent call
last)
in ()
----> 1 get_ipython().run_cell_magic(u'fortran', u'', u'subroutine f1(x,
y, z)\n real, intent(in) :: x,y\n real, intent(out) :: z\n\n z =
sin(x+y)\n\nend subroutine f1')/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/IPython/core/interactiveshell.pyc
in run_cell_magic(self, magic_name, line, cell)
2127 magic_arg_s = self.var_expand(line, stack_depth)
2128 with self.builtin_trap:
-> 2129 result = fn(magic_arg_s, cell)
2130 return result
2131/Users/devasi/.ipython/extensions/fortranmagic.pyc in fortran(self, line,
cell)/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/IPython/core/magic.pyc
in (f, _a, *_k)
189 # but it's overkill for just that one bit of state.
190 def magic_deco(arg):
--> 191 call = lambda f, _a, *_k: f(_a, *_k)
192
193 if callable(arg):/Users/devasi/.ipython/extensions/fortranmagic.pyc in fortran(self, line,
cell)
332 verbosity=args.verbosity)
333
--> 334 self._code_cache[key] = module_name
335 module = imp.load_dynamic(module_name, module_path)
336 self._import_all(module, verbosity=args.verbosity)TypeError: unhashable type: 'list'
—
Reply to this email directly or view it on GitHub.
from fortran_magic.
bumped 0.4.1
from fortran_magic.
Hmmm something strange is going on here. Now everything works but not as expected :). The .so library compiled by the fortran magic doesn't contain link to the specified external library:
otool -L _fortran_magic_bb8a58e730478164cb30e999d1ef1ae7.so
gives
_fortran_magic_bb8a58e730478164cb30e999d1ef1ae7.so:
/usr/local/lib/libgfortran.3.dylib (compatibility version 4.0.0, current version 4.0.0)
/usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1669.0.0)
/usr/local/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)
/usr/local/lib/libquadmath.0.dylib (compatibility version 1.0.0, current version 1.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0)
but if I just copy the command generated by fortran magic and paste it into the terminal and run it then the library is properly compiled:
otool -L _fortran_magic_bb8a58e730478164cb30e999d1ef1ae7.so
_fortran_magic_bb8a58e730478164cb30e999d1ef1ae7.so:
/usr/local/lib/lib/libopenblas_sandybridgep-r0.2.8.dylib (compatibility version 0.0.0, current version 0.0.0)
/usr/local/lib/libgfortran.3.dylib (compatibility version 4.0.0, current version 4.0.0)
/usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1669.0.0)
/usr/local/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)
/usr/local/lib/libquadmath.0.dylib (compatibility version 1.0.0, current version 1.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0)
from fortran_magic.
Could you share a notebook or a pastebin with a fully verbose example of your usage?
from fortran_magic.
This is output of Fortran magic: http://pastebin.com/Z3qZ01fd
This is output of the same f2py command in terminal: http://pastebin.com/tKQ4xMMd
Here is the code to compile:
%%fortran -vvv --fcompiler=gnu95 --opt=-march=native --extra '-L/usr/local/lib/lib -lopenblas'
subroutine matmul2 (a,b,c,a_dim1,a_dim2,b_dim1,b_dim2)
implicit none
real(8), dimension(a_dim1,a_dim2), intent(in) :: a
real(8), dimension(b_dim1,b_dim2), intent(in) :: b
real(8), dimension(b_dim1,a_dim2), intent(out) :: c
integer, intent(in) :: a_dim1,a_dim2,b_dim1,b_dim2
!call openblas_set_num_threads(1)
call dgemm('N', 'N', a_dim1, a_dim1, a_dim1, 1.0D0, a, a_dim1, b, a_dim1, 0.0D0, c, a_dim1)
end subroutine matmul2
from fortran_magic.
It seems the problem is that the fortran magic provides -L"/usr/local/lib/lib -lopenblas"
to the compiler
from fortran_magic.
Thanks for debug it Denis.
I guess I patched it in bf644cf, but to avoid made a new broken release, could you test it before ?
Install that specific version with
%install_ext https://raw.github.com/mgaitan/fortran_magic/bf644cffa7da731439c762ff7b08d617290fc4a8/fortranmagic.py
from fortran_magic.
Now it works like magic! Thanks a lot!
from fortran_magic.
Great, thanks for your help. Released 0.4.2
from fortran_magic.
Related Issues (20)
- intent(hide) HOT 1
- ImportError: dlopen HOT 4
- Bytes/string error on Python 3.5 and IPython 4.0
- how to pass intel64 ifort compiler option from jupyter notebook?
- IPython warning HOT 5
- UnicodeDecodeError when debugging fortran code
- Running the Example notebook fails HOT 1
- fortranmagic sometimes works, sometimes doesn't
- version 0.7?
- Does not work on python3 HOT 1
- Ipython and Javascript error
- Retrieve fortran source code HOT 4
- failed to load fortranmagic HOT 5
- Getting gfortran compiler error when running example HOT 6
- Number bugs HOT 2
- Add optional support to other fortran wrapper tools HOT 1
- NameError with Python 3.3 HOT 1
- Problem running on Windows HOT 1
- fortranmagic should call f2py3 under Python 3 HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fortran_magic.