Skip to content

Commit

Permalink
actualizacion clase 6
Browse files Browse the repository at this point in the history
  • Loading branch information
mgaitan committed Jun 3, 2015
1 parent 8110c13 commit 0766f42
Show file tree
Hide file tree
Showing 2 changed files with 331 additions and 56 deletions.
101 changes: 46 additions & 55 deletions Clase 5b.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 1,
"metadata": {
"collapsed": false
},
Expand All @@ -130,12 +130,12 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Overwriting dot_product.f90\n"
"Overwriting suma.f90\n"
]
}
],
"source": [
"%%file dot_product.f90 \n",
"%%file suma.f90 \n",
"\n",
"subroutine dot(n, v)\n",
" ! Compute the dot product between u and v (length n) and put the result in product\n",
Expand All @@ -156,7 +156,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 2,
"metadata": {
"collapsed": false
},
Expand All @@ -172,25 +172,25 @@
"\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 \"dot_product\" sources\u001b[0m\n",
"\u001b[39mbuilding extension \"suma\" sources\u001b[0m\n",
"\u001b[39mf2py options: []\u001b[0m\n",
"\u001b[39mf2py:> /tmp/tmpao__h24v/src.linux-x86_64-3.4/dot_productmodule.c\u001b[0m\n",
"\u001b[39mcreating /tmp/tmpao__h24v/src.linux-x86_64-3.4\u001b[0m\n",
"\u001b[39mf2py:> /tmp/tmph2h41h8s/src.linux-x86_64-3.4/sumamodule.c\u001b[0m\n",
"\u001b[39mcreating /tmp/tmph2h41h8s/src.linux-x86_64-3.4\u001b[0m\n",
"Reading fortran codes...\n",
"\tReading file 'dot_product.f90' (format:free)\n",
"\tReading file 'suma.f90' (format:free)\n",
"Post-processing...\n",
"\tBlock: dot_product\n",
"\tBlock: suma\n",
"\t\t\tBlock: dot\n",
"Post-processing (stage 2)...\n",
"Building modules...\n",
"\tBuilding module \"dot_product\"...\n",
"\tBuilding module \"suma\"...\n",
"\t\tConstructing wrapper function \"dot\"...\n",
"\t\t v = dot(n)\n",
"\tWrote C/API module \"dot_product\" to file \"/tmp/tmpao__h24v/src.linux-x86_64-3.4/dot_productmodule.c\"\n",
"\u001b[39m adding '/tmp/tmpao__h24v/src.linux-x86_64-3.4/fortranobject.c' to sources.\u001b[0m\n",
"\u001b[39m adding '/tmp/tmpao__h24v/src.linux-x86_64-3.4' to include_dirs.\u001b[0m\n",
"\u001b[39mcopying /home/tin/.virtualenvs/curso/lib/python3.4/site-packages/numpy/f2py/src/fortranobject.c -> /tmp/tmpao__h24v/src.linux-x86_64-3.4\u001b[0m\n",
"\u001b[39mcopying /home/tin/.virtualenvs/curso/lib/python3.4/site-packages/numpy/f2py/src/fortranobject.h -> /tmp/tmpao__h24v/src.linux-x86_64-3.4\u001b[0m\n",
"\tWrote C/API module \"suma\" to file \"/tmp/tmph2h41h8s/src.linux-x86_64-3.4/sumamodule.c\"\n",
"\u001b[39m adding '/tmp/tmph2h41h8s/src.linux-x86_64-3.4/fortranobject.c' to sources.\u001b[0m\n",
"\u001b[39m adding '/tmp/tmph2h41h8s/src.linux-x86_64-3.4' to include_dirs.\u001b[0m\n",
"\u001b[39mcopying /home/tin/.virtualenvs/curso/lib/python3.4/site-packages/numpy/f2py/src/fortranobject.c -> /tmp/tmph2h41h8s/src.linux-x86_64-3.4\u001b[0m\n",
"\u001b[39mcopying /home/tin/.virtualenvs/curso/lib/python3.4/site-packages/numpy/f2py/src/fortranobject.h -> /tmp/tmph2h41h8s/src.linux-x86_64-3.4\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",
Expand All @@ -199,47 +199,47 @@
"\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 'dot_product' extension\u001b[0m\n",
"\u001b[39mbuilding 'suma' 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 -g -fstack-protector-strong -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -fPIC\n",
"\u001b[0m\n",
"\u001b[39mcreating /tmp/tmpao__h24v/tmp\u001b[0m\n",
"\u001b[39mcreating /tmp/tmpao__h24v/tmp/tmpao__h24v\u001b[0m\n",
"\u001b[39mcreating /tmp/tmpao__h24v/tmp/tmpao__h24v/src.linux-x86_64-3.4\u001b[0m\n",
"\u001b[39mcompile options: '-I/tmp/tmpao__h24v/src.linux-x86_64-3.4 -I/home/tin/.virtualenvs/curso/lib/python3.4/site-packages/numpy/core/include -I/usr/include/python3.4m -I/home/tin/.virtualenvs/curso/include/python3.4m -c'\u001b[0m\n",
"\u001b[39mx86_64-linux-gnu-gcc: /tmp/tmpao__h24v/src.linux-x86_64-3.4/fortranobject.c\u001b[0m\n",
"\u001b[39mcreating /tmp/tmph2h41h8s/tmp\u001b[0m\n",
"\u001b[39mcreating /tmp/tmph2h41h8s/tmp/tmph2h41h8s\u001b[0m\n",
"\u001b[39mcreating /tmp/tmph2h41h8s/tmp/tmph2h41h8s/src.linux-x86_64-3.4\u001b[0m\n",
"\u001b[39mcompile options: '-I/tmp/tmph2h41h8s/src.linux-x86_64-3.4 -I/home/tin/.virtualenvs/curso/lib/python3.4/site-packages/numpy/core/include -I/usr/include/python3.4m -I/home/tin/.virtualenvs/curso/include/python3.4m -c'\u001b[0m\n",
"\u001b[39mx86_64-linux-gnu-gcc: /tmp/tmph2h41h8s/src.linux-x86_64-3.4/fortranobject.c\u001b[0m\n",
"In file included from /home/tin/.virtualenvs/curso/lib/python3.4/site-packages/numpy/core/include/numpy/ndarraytypes.h:1804:0,\n",
" from /home/tin/.virtualenvs/curso/lib/python3.4/site-packages/numpy/core/include/numpy/ndarrayobject.h:17,\n",
" from /home/tin/.virtualenvs/curso/lib/python3.4/site-packages/numpy/core/include/numpy/arrayobject.h:4,\n",
" from /tmp/tmpao__h24v/src.linux-x86_64-3.4/fortranobject.h:13,\n",
" from /tmp/tmpao__h24v/src.linux-x86_64-3.4/fortranobject.c:2:\n",
" from /tmp/tmph2h41h8s/src.linux-x86_64-3.4/fortranobject.h:13,\n",
" from /tmp/tmph2h41h8s/src.linux-x86_64-3.4/fortranobject.c:2:\n",
"/home/tin/.virtualenvs/curso/lib/python3.4/site-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/tmpao__h24v/src.linux-x86_64-3.4/dot_productmodule.c\u001b[0m\n",
"\u001b[39mx86_64-linux-gnu-gcc: /tmp/tmph2h41h8s/src.linux-x86_64-3.4/sumamodule.c\u001b[0m\n",
"In file included from /home/tin/.virtualenvs/curso/lib/python3.4/site-packages/numpy/core/include/numpy/ndarraytypes.h:1804:0,\n",
" from /home/tin/.virtualenvs/curso/lib/python3.4/site-packages/numpy/core/include/numpy/ndarrayobject.h:17,\n",
" from /home/tin/.virtualenvs/curso/lib/python3.4/site-packages/numpy/core/include/numpy/arrayobject.h:4,\n",
" from /tmp/tmpao__h24v/src.linux-x86_64-3.4/fortranobject.h:13,\n",
" from /tmp/tmpao__h24v/src.linux-x86_64-3.4/dot_productmodule.c:17:\n",
" from /tmp/tmph2h41h8s/src.linux-x86_64-3.4/fortranobject.h:13,\n",
" from /tmp/tmph2h41h8s/src.linux-x86_64-3.4/sumamodule.c:17:\n",
"/home/tin/.virtualenvs/curso/lib/python3.4/site-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[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/tmpao__h24v/src.linux-x86_64-3.4 -I/home/tin/.virtualenvs/curso/lib/python3.4/site-packages/numpy/core/include -I/usr/include/python3.4m -I/home/tin/.virtualenvs/curso/include/python3.4m -c'\u001b[0m\n",
"\u001b[39mgfortran:f90: dot_product.f90\u001b[0m\n",
"\u001b[39m/usr/bin/gfortran -Wall -g -Wall -g -shared /tmp/tmpao__h24v/tmp/tmpao__h24v/src.linux-x86_64-3.4/dot_productmodule.o /tmp/tmpao__h24v/tmp/tmpao__h24v/src.linux-x86_64-3.4/fortranobject.o /tmp/tmpao__h24v/dot_product.o -lgfortran -o ./dot_product.cpython-34m.so\u001b[0m\n",
"Removing build directory /tmp/tmpao__h24v\n"
"\u001b[39mcompile options: '-I/tmp/tmph2h41h8s/src.linux-x86_64-3.4 -I/home/tin/.virtualenvs/curso/lib/python3.4/site-packages/numpy/core/include -I/usr/include/python3.4m -I/home/tin/.virtualenvs/curso/include/python3.4m -c'\u001b[0m\n",
"\u001b[39mgfortran:f90: suma.f90\u001b[0m\n",
"\u001b[39m/usr/bin/gfortran -Wall -g -Wall -g -shared /tmp/tmph2h41h8s/tmp/tmph2h41h8s/src.linux-x86_64-3.4/sumamodule.o /tmp/tmph2h41h8s/tmp/tmph2h41h8s/src.linux-x86_64-3.4/fortranobject.o /tmp/tmph2h41h8s/suma.o -lgfortran -o ./suma.cpython-34m.so\u001b[0m\n",
"Removing build directory /tmp/tmph2h41h8s\n"
]
}
],
"source": [
"# Si queres evitar el output podés guardar en una variable\n",
"# _ = !f2py -m dot_product -c dot_product.f90 \n",
"!/home/tin/.virtualenvs/curso/bin/f2py3.4 -m dot_product -c dot_product.f90 "
"!/home/tin/.virtualenvs/curso/bin/f2py3.4 -m suma -c suma.f90 "
]
},
{
Expand All @@ -252,34 +252,25 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 7,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"v = dot(n)\n",
"\n",
"Wrapper for ``dot``.\n",
"\n",
"Parameters\n",
"----------\n",
"n : input int\n",
"\n",
"Returns\n",
"-------\n",
"v : int\n",
"\n"
"ename": "ImportError",
"evalue": "No module named suma",
"output_type": "error",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[1;31mImportError\u001b[0m Traceback (most recent call last)",
"\u001b[1;32m<ipython-input-7-0e16479c1973>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[1;32mimport\u001b[0m \u001b[0msuma\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[1;31mImportError\u001b[0m: No module named suma"
]
}
],
"source": [
"import dot_product\n",
"\n",
"print(dot_product.)"
"import suma"
]
},
{
Expand Down Expand Up @@ -1339,21 +1330,21 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"display_name": "Python 3",
"language": "python",
"name": "python2"
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.8"
"pygments_lexer": "ipython3",
"version": "3.4.2"
}
},
"nbformat": 4,
Expand Down
286 changes: 285 additions & 1 deletion Clase 6.ipynb

Large diffs are not rendered by default.

0 comments on commit 0766f42

Please sign in to comment.