Created
August 6, 2015 17:52
-
-
Save tmbdev/1e5b7b387ad45c751ea6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"Overwriting testmod.f90\n" | |
] | |
} | |
], | |
"source": [ | |
"%%file testmod.f90\n", | |
"module testmod\n", | |
"contains\n", | |
"subroutine pdims(a)\n", | |
"real, dimension(:,:) :: a\n", | |
"print *, size(a,1), size(a,2)\n", | |
"end subroutine\n", | |
"end module testmod" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"\u001b[39mrunning build\u001b[0m\n", | |
"\u001b[39mrunning config_cc\u001b[0m\n", | |
"\u001b[39munifing config_cc, config, build_clib, build_ext, build commands --compiler options\u001b[0m\n", | |
"\u001b[39mrunning config_fc\u001b[0m\n", | |
"\u001b[39munifing config_fc, config, build_clib, build_ext, build commands --fcompiler options\u001b[0m\n", | |
"\u001b[39mrunning build_src\u001b[0m\n", | |
"\u001b[39mbuild_src\u001b[0m\n", | |
"\u001b[39mbuilding extension \"testmod\" sources\u001b[0m\n", | |
"\u001b[39mf2py options: []\u001b[0m\n", | |
"\u001b[39mf2py:> /tmp/tmpQQL61E/src.linux-x86_64-2.7/testmodmodule.c\u001b[0m\n", | |
"\u001b[39mcreating /tmp/tmpQQL61E/src.linux-x86_64-2.7\u001b[0m\n", | |
"Reading fortran codes...\n", | |
"\tReading file 'testmod.f90' (format:free)\n", | |
"Post-processing...\n", | |
"\tBlock: testmod\n", | |
"\t\t\tBlock: testmod\n", | |
"\t\t\t\tBlock: pdims\n", | |
"Post-processing (stage 2)...\n", | |
"\tBlock: testmod\n", | |
"\t\tBlock: unknown_interface\n", | |
"\t\t\tBlock: testmod\n", | |
"\t\t\t\tBlock: pdims\n", | |
"Building modules...\n", | |
"\tBuilding module \"testmod\"...\n", | |
"\t\tConstructing F90 module support for \"testmod\"...\n", | |
"\t\tCreating wrapper for Fortran subroutine \"pdims\"(\"pdims\")...\n", | |
"\t\t\tConstructing wrapper function \"testmod.pdims\"...\n", | |
"\t\t\t pdims(a)\n", | |
"\tWrote C/API module \"testmod\" to file \"/tmp/tmpQQL61E/src.linux-x86_64-2.7/testmodmodule.c\"\n", | |
"\tFortran 90 wrappers are saved to \"/tmp/tmpQQL61E/src.linux-x86_64-2.7/testmod-f2pywrappers2.f90\"\n", | |
"\u001b[39m adding '/tmp/tmpQQL61E/src.linux-x86_64-2.7/fortranobject.c' to sources.\u001b[0m\n", | |
"\u001b[39m adding '/tmp/tmpQQL61E/src.linux-x86_64-2.7' to include_dirs.\u001b[0m\n", | |
"\u001b[39mcopying /usr/local/lib/python2.7/dist-packages/numpy/f2py/src/fortranobject.c -> /tmp/tmpQQL61E/src.linux-x86_64-2.7\u001b[0m\n", | |
"\u001b[39mcopying /usr/local/lib/python2.7/dist-packages/numpy/f2py/src/fortranobject.h -> /tmp/tmpQQL61E/src.linux-x86_64-2.7\u001b[0m\n", | |
"\u001b[39m adding '/tmp/tmpQQL61E/src.linux-x86_64-2.7/testmod-f2pywrappers2.f90' to sources.\u001b[0m\n", | |
"\u001b[39mbuild_src: building npy-pkg config files\u001b[0m\n", | |
"\u001b[39mrunning build_ext\u001b[0m\n", | |
"\u001b[39mcustomize UnixCCompiler\u001b[0m\n", | |
"\u001b[39mcustomize UnixCCompiler using build_ext\u001b[0m\n", | |
"\u001b[39mcustomize Gnu95FCompiler\u001b[0m\n", | |
"\u001b[39mFound executable /usr/bin/gfortran\u001b[0m\n", | |
"\u001b[39mcustomize Gnu95FCompiler\u001b[0m\n", | |
"\u001b[39mcustomize Gnu95FCompiler using build_ext\u001b[0m\n", | |
"\u001b[39mbuilding 'testmod' extension\u001b[0m\n", | |
"\u001b[39mcompiling C sources\u001b[0m\n", | |
"\u001b[39mC compiler: x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC\n", | |
"\u001b[0m\n", | |
"\u001b[39mcreating /tmp/tmpQQL61E/tmp\u001b[0m\n", | |
"\u001b[39mcreating /tmp/tmpQQL61E/tmp/tmpQQL61E\u001b[0m\n", | |
"\u001b[39mcreating /tmp/tmpQQL61E/tmp/tmpQQL61E/src.linux-x86_64-2.7\u001b[0m\n", | |
"\u001b[39mcompile options: '-I/tmp/tmpQQL61E/src.linux-x86_64-2.7 -I/usr/local/lib/python2.7/dist-packages/numpy/core/include -I/usr/include/python2.7 -c'\u001b[0m\n", | |
"\u001b[39mx86_64-linux-gnu-gcc: /tmp/tmpQQL61E/src.linux-x86_64-2.7/fortranobject.c\u001b[0m\n", | |
"In file included from /usr/local/lib/python2.7/dist-packages/numpy/core/include/numpy/ndarraytypes.h:1804:0,\n", | |
" from /usr/local/lib/python2.7/dist-packages/numpy/core/include/numpy/ndarrayobject.h:17,\n", | |
" from /usr/local/lib/python2.7/dist-packages/numpy/core/include/numpy/arrayobject.h:4,\n", | |
" from /tmp/tmpQQL61E/src.linux-x86_64-2.7/fortranobject.h:13,\n", | |
" from /tmp/tmpQQL61E/src.linux-x86_64-2.7/fortranobject.c:2:\n", | |
"/usr/local/lib/python2.7/dist-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:15:2: warning: #warning \"Using deprecated NumPy API, disable it by \" \"#defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION\" [-Wcpp]\n", | |
" #warning \"Using deprecated NumPy API, disable it by \" \\\n", | |
" ^\n", | |
"\u001b[39mx86_64-linux-gnu-gcc: /tmp/tmpQQL61E/src.linux-x86_64-2.7/testmodmodule.c\u001b[0m\n", | |
"In file included from /usr/local/lib/python2.7/dist-packages/numpy/core/include/numpy/ndarraytypes.h:1804:0,\n", | |
" from /usr/local/lib/python2.7/dist-packages/numpy/core/include/numpy/ndarrayobject.h:17,\n", | |
" from /usr/local/lib/python2.7/dist-packages/numpy/core/include/numpy/arrayobject.h:4,\n", | |
" from /tmp/tmpQQL61E/src.linux-x86_64-2.7/fortranobject.h:13,\n", | |
" from /tmp/tmpQQL61E/src.linux-x86_64-2.7/testmodmodule.c:18:\n", | |
"/usr/local/lib/python2.7/dist-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:15:2: warning: #warning \"Using deprecated NumPy API, disable it by \" \"#defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION\" [-Wcpp]\n", | |
" #warning \"Using deprecated NumPy API, disable it by \" \\\n", | |
" ^\n", | |
"/tmp/tmpQQL61E/src.linux-x86_64-2.7/testmodmodule.c:104:12: warning: ‘f2py_size’ defined but not used [-Wunused-function]\n", | |
" static int f2py_size(PyArrayObject* var, ...)\n", | |
" ^\n", | |
"\u001b[39mcompiling Fortran 90 module sources\u001b[0m\n", | |
"\u001b[39mFortran f77 compiler: /usr/bin/gfortran -Wall -g -ffixed-form -fno-second-underscore -fPIC -O3 -funroll-loops\n", | |
"Fortran f90 compiler: /usr/bin/gfortran -Wall -g -fno-second-underscore -fPIC -O3 -funroll-loops\n", | |
"Fortran fix compiler: /usr/bin/gfortran -Wall -g -ffixed-form -fno-second-underscore -Wall -g -fno-second-underscore -fPIC -O3 -funroll-loops\u001b[0m\n", | |
"\u001b[39mcompile options: '-I/tmp/tmpQQL61E/src.linux-x86_64-2.7 -I/usr/local/lib/python2.7/dist-packages/numpy/core/include -I/usr/include/python2.7 -c'\n", | |
"extra options: '-J/tmp/tmpQQL61E/ -I/tmp/tmpQQL61E/'\u001b[0m\n", | |
"\u001b[39mgfortran:f90: testmod.f90\u001b[0m\n", | |
"\u001b[39mcompiling Fortran sources\u001b[0m\n", | |
"\u001b[39mFortran f77 compiler: /usr/bin/gfortran -Wall -g -ffixed-form -fno-second-underscore -fPIC -O3 -funroll-loops\n", | |
"Fortran f90 compiler: /usr/bin/gfortran -Wall -g -fno-second-underscore -fPIC -O3 -funroll-loops\n", | |
"Fortran fix compiler: /usr/bin/gfortran -Wall -g -ffixed-form -fno-second-underscore -Wall -g -fno-second-underscore -fPIC -O3 -funroll-loops\u001b[0m\n", | |
"\u001b[39mcompile options: '-I/tmp/tmpQQL61E/src.linux-x86_64-2.7 -I/usr/local/lib/python2.7/dist-packages/numpy/core/include -I/usr/include/python2.7 -c'\n", | |
"extra options: '-J/tmp/tmpQQL61E/ -I/tmp/tmpQQL61E/'\u001b[0m\n", | |
"\u001b[39mgfortran:f90: /tmp/tmpQQL61E/src.linux-x86_64-2.7/testmod-f2pywrappers2.f90\u001b[0m\n", | |
"\u001b[39m/usr/bin/gfortran -Wall -g -Wall -g -shared /tmp/tmpQQL61E/tmp/tmpQQL61E/src.linux-x86_64-2.7/testmodmodule.o /tmp/tmpQQL61E/tmp/tmpQQL61E/src.linux-x86_64-2.7/fortranobject.o /tmp/tmpQQL61E/testmod.o /tmp/tmpQQL61E/tmp/tmpQQL61E/src.linux-x86_64-2.7/testmod-f2pywrappers2.o -lgfortran -o ./testmod.so\u001b[0m\n", | |
"Removing build directory /tmp/tmpQQL61E\n" | |
] | |
} | |
], | |
"source": [ | |
"!f2py -c -m testmod testmod.f90" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 3, | |
"metadata": { | |
"collapsed": true | |
}, | |
"outputs": [], | |
"source": [ | |
"import testmod" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 4, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"Populating the interactive namespace from numpy and matplotlib\n" | |
] | |
} | |
], | |
"source": [ | |
"%pylab inline" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 5, | |
"metadata": { | |
"collapsed": true | |
}, | |
"outputs": [], | |
"source": [ | |
"a = randn(17,34)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 6, | |
"metadata": { | |
"collapsed": true | |
}, | |
"outputs": [], | |
"source": [ | |
"reload(testmod); testmod.testmod.pdims(a)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": { | |
"collapsed": true | |
}, | |
"outputs": [], | |
"source": [] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Python 2", | |
"language": "python", | |
"name": "python2" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 2 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython2", | |
"version": "2.7.9" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 0 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment