<p dir="auto">The following code:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="subroutine s(n, a)
  integer :: n, a(1:2**n)
end"><pre class="notranslate"><code class="notranslate">subroutine s(n, a)
  integer :: n, a(1:2**n)
end
</code></pre></div>
<p dir="auto">causes f2py to crash with:</p>
<blockquote>
<p dir="auto">/tmp/tmprxk_Ew/src.linux-x86_64-2.7/f2py_bugmodule.c: In function ‘f2py_rout_f2py_bug_s’:<br>
/tmp/tmprxk_Ew/src.linux-x86_64-2.7/f2py_bugmodule.c:217:15: error: invalid type argument of unary ‘<em>’ (have ‘int’)<br>
a_Dims[0]=2</em>*n;<br>
^</p>
</blockquote>
<p dir="auto">Original report: <a href="http://stackoverflow.com/questions/35156750/f2py-invalid-type-argument-of-unary" rel="nofollow">http://stackoverflow.com/questions/35156750/f2py-invalid-type-argument-of-unary</a></p>
<p dir="auto">Full output:</p>
<blockquote>
<blockquote>
<p dir="auto">f2py -c f2py_bug.f90 -m f2py_bug<br>
running build<br>
running config_cc<br>
unifing config_cc, config, build_clib, build_ext, build commands --compiler options<br>
running config_fc<br>
unifing config_fc, config, build_clib, build_ext, build commands --fcompiler options<br>
running build_src<br>
build_src<br>
building extension "f2py_bug" sources<br>
f2py options: []<br>
f2py:&gt; /tmp/tmplNikU7/src.linux-x86_64-2.7/f2py_bugmodule.c<br>
creating /tmp/tmplNikU7/src.linux-x86_64-2.7<br>
Reading fortran codes...<br>
Reading file 'f2py_bug.f90' (format:free)<br>
Post-processing...<br>
Block: f2py_bug<br>
Block: s<br>
Post-processing (stage 2)...<br>
Building modules...<br>
Building module "f2py_bug"...<br>
Constructing wrapper function "s"...<br>
s(n,a)<br>
Wrote C/API module "f2py_bug" to file "/tmp/tmplNikU7/src.linux-x86_64-2.7/f2py_bugmodule.c"<br>
adding '/tmp/tmplNikU7/src.linux-x86_64-2.7/fortranobject.c' to sources.<br>
adding '/tmp/tmplNikU7/src.linux-x86_64-2.7' to include_dirs.<br>
copying /usr/lib64/python2.7/site-packages/numpy/f2py/src/fortranobject.c -&gt; /tmp/tmplNikU7/src.linux-x86_64-2.7<br>
copying /usr/lib64/python2.7/site-packages/numpy/f2py/src/fortranobject.h -&gt; /tmp/tmplNikU7/src.linux-x86_64-2.7<br>
build_src: building npy-pkg config files<br>
running build_ext<br>
customize UnixCCompiler<br>
customize UnixCCompiler using build_ext<br>
customize Gnu95FCompiler<br>
Found executable /usr/bin/gfortran<br>
customize Gnu95FCompiler<br>
customize Gnu95FCompiler using build_ext<br>
building 'f2py_bug' extension<br>
compiling C sources<br>
C compiler: gcc -pthread -fno-strict-aliasing -fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -g -DNDEBUG -fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -g -DOPENSSL_LOAD_CONF -fPIC</p>
</blockquote>
<p dir="auto">creating /tmp/tmplNikU7/tmp<br>
creating /tmp/tmplNikU7/tmp/tmplNikU7<br>
creating /tmp/tmplNikU7/tmp/tmplNikU7/src.linux-x86_64-2.7<br>
compile options: '-I/tmp/tmplNikU7/src.linux-x86_64-2.7 -I/usr/lib64/python2.7/site-packages/numpy/core/include -I/usr/include/python2.7 -c'<br>
gcc: /tmp/tmplNikU7/src.linux-x86_64-2.7/fortranobject.c<br>
In file included from /usr/lib64/python2.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1781:0,<br>
from /usr/lib64/python2.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:18,<br>
from /usr/lib64/python2.7/site-packages/numpy/core/include/numpy/arrayobject.h:4,<br>
from /tmp/tmplNikU7/src.linux-x86_64-2.7/fortranobject.h:13,<br>
from /tmp/tmplNikU7/src.linux-x86_64-2.7/fortranobject.c:2:<br>
/usr/lib64/python2.7/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]<br>
#warning "Using deprecated NumPy API, disable it by " <br>
^<br>
gcc: /tmp/tmplNikU7/src.linux-x86_64-2.7/f2py_bugmodule.c<br>
In file included from /usr/lib64/python2.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1781:0,<br>
from /usr/lib64/python2.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:18,<br>
from /usr/lib64/python2.7/site-packages/numpy/core/include/numpy/arrayobject.h:4,<br>
from /tmp/tmplNikU7/src.linux-x86_64-2.7/fortranobject.h:13,<br>
from /tmp/tmplNikU7/src.linux-x86_64-2.7/f2py_bugmodule.c:19:<br>
/usr/lib64/python2.7/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]<br>
#warning "Using deprecated NumPy API, disable it by " <br>
^<br>
/tmp/tmplNikU7/src.linux-x86_64-2.7/f2py_bugmodule.c: In function ‘f2py_rout_f2py_bug_s’:<br>
/tmp/tmplNikU7/src.linux-x86_64-2.7/f2py_bugmodule.c:217:15: error: invalid type argument of unary ‘<em>’ (have ‘int’)<br>
a_Dims[0]=2__n;<br>
^<br>
/tmp/tmplNikU7/src.linux-x86_64-2.7/f2py_bugmodule.c: At top level:<br>
/tmp/tmplNikU7/src.linux-x86_64-2.7/f2py_bugmodule.c:105:12: warning: ‘f2py_size’ defined but not used [-Wunused-function]<br>
static int f2py_size(PyArrayObject</em> var, ...)<br>
^<br>
In file included from /usr/lib64/python2.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1781:0,<br>
from /usr/lib64/python2.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:18,<br>
from /usr/lib64/python2.7/site-packages/numpy/core/include/numpy/arrayobject.h:4,<br>
from /tmp/tmplNikU7/src.linux-x86_64-2.7/fortranobject.h:13,<br>
from /tmp/tmplNikU7/src.linux-x86_64-2.7/f2py_bugmodule.c:19:<br>
/usr/lib64/python2.7/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]<br>
#warning "Using deprecated NumPy API, disable it by " <br>
^<br>
/tmp/tmplNikU7/src.linux-x86_64-2.7/f2py_bugmodule.c: In function ‘f2py_rout_f2py_bug_s’:<br>
/tmp/tmplNikU7/src.linux-x86_64-2.7/f2py_bugmodule.c:217:15: error: invalid type argument of unary ‘<em>’ (have ‘int’)<br>
a_Dims[0]=2__n;<br>
^<br>
/tmp/tmplNikU7/src.linux-x86_64-2.7/f2py_bugmodule.c: At top level:<br>
/tmp/tmplNikU7/src.linux-x86_64-2.7/f2py_bugmodule.c:105:12: warning: ‘f2py_size’ defined but not used [-Wunused-function]<br>
static int f2py_size(PyArrayObject</em> var, ...)<br>
^<br>
error: Command "gcc -pthread -fno-strict-aliasing -fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -g -DNDEBUG -fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -g -DOPENSSL_LOAD_CONF -fPIC -I/tmp/tmplNikU7/src.linux-x86_64-2.7 -I/usr/lib64/python2.7/site-packages/numpy/core/include -I/usr/include/python2.7 -c /tmp/tmplNikU7/src.linux-x86_64-2.7/f2py_bugmodule.c -o /tmp/tmplNikU7/tmp/tmplNikU7/src.linux-x86_64-2.7/f2py_bugmodule.o" failed with exit status 1</p>
</blockquote>
<p dir="auto">When I constructed an array named <code class="notranslate">list</code> in fortran, like code shown below:</p>
<div class="highlight highlight-source-fortran notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="subroutine blah(list, n)
    integer, intent(in) :: n
    real, intent(out) :: list(2*n,0:2**n)

    list = 1.0

end subroutine"><pre class="notranslate"><span class="pl-k">subroutine</span> <span class="pl-en">blah</span>(<span class="pl-v">list</span>, <span class="pl-v">n</span>)
    <span class="pl-k">integer</span>, <span class="pl-k">intent</span>(<span class="pl-k">in</span>) <span class="pl-k">::</span> n
    <span class="pl-k">real</span>, <span class="pl-k">intent</span>(<span class="pl-k">out</span>) <span class="pl-k">::</span> list(<span class="pl-c1">2</span><span class="pl-k">*</span>n,<span class="pl-c1">0</span>:<span class="pl-c1">2</span><span class="pl-k">**</span>n)

    list <span class="pl-k">=</span> <span class="pl-c1">1.0</span>

<span class="pl-k">end</span> <span class="pl-k">subroutine</span></pre></div>
<p dir="auto">I encountered the following error, which seems to treat exponentiation as a pointer. Any ideas how to get rid of it? Thanks!</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="/tmp/tmpHYL2Dx/src.linux-x86_64-2.7/cmmodule.c:216:37: error: invalid type argument of unary ‘*’ (have ‘int’)
   list_Dims[0]=2 * n,list_Dims[1]=2**n+1;
                                    ^"><pre class="notranslate"><code class="notranslate">/tmp/tmpHYL2Dx/src.linux-x86_64-2.7/cmmodule.c:216:37: error: invalid type argument of unary ‘*’ (have ‘int’)
   list_Dims[0]=2 * n,list_Dims[1]=2**n+1;
                                    ^
</code></pre></div>