Size: 1143
Comment:
|
← Revision 14 as of 2012-12-06 09:23:18 ⇥
Size: 1160
Comment:
|
Deletions are marked like this. | Additions are marked like this. |
Line 38: | Line 38: |
== Signatures == | |
Line 40: | Line 40: |
file (watermask, 10x10 degrees, 250m resolution): /home/zmaw/m300036/PythonSeminar/watermask/MOD44W.A2000055.h18v04.005.2009212173853.hdf pure python script: /home/zmaw/m300036/PythonSeminar/watermask/resize_pure_python.py python-fortran script: /home/zmaw/m300036/PythonSeminar/watermask/resize_watermask.py |
file (watermask, 10x10 degrees, 250m resolution): {{{/home/zmaw/m300036/PythonSeminar/watermask/MOD44W.A2000055.h18v04.005.2009212173853.hdf}}} Real world example: moving window averaging * Fortran code: [[ /ArStats | code ]] * Python code: [[/ResizeWaterMaskPython | code]] * Fortran+Python: [[ /ResizeWaterMaskFortran | code]] |
F2PY
A tool that provides connection between Python and Fortran languages Official website
Advanced examples how to use f2py
Type: f2py # to see the usage options f2py -c --help-fcompiler # to see what local fortran compilers does f2py recognize
f2py wraps Fortran code and allows to use it as a Python module.
"Hello world"
C File hello_world.f subroutine foo (a) integer a print*, "Hello from Fortran!" print*, "a=",a end
Compile:
f2py -c -m hello hello.f --fcompiler=gfortran
Try it in Python:
import hello print hello.__doc__ hello.foo(4)
Compare pure Python and Python+Fortran
file (watermask, 10x10 degrees, 250m resolution): /home/zmaw/m300036/PythonSeminar/watermask/MOD44W.A2000055.h18v04.005.2009212173853.hdf
Real world example: moving window averaging