<h3 dir="auto">Describe the issue:</h3>
<p dir="auto">Let's consider the following subroutine in a <code class="notranslate">test.f90</code> file that declares an automatic array from two variables(*):</p>
<div class="highlight highlight-source-fortran-modern notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="subroutine test (nx, ny, arr)

  implicit none

  integer, intent(in) :: nx
  integer, intent(in) :: ny
  integer, dimension(nx*ny) :: arr

return
end subroutine test"><pre class="notranslate"><span class="pl-k">subroutine</span> <span class="pl-en">test</span> (<span class="pl-v">nx</span>, <span class="pl-v">ny</span>, <span class="pl-v">arr</span>)

  <span class="pl-k">implicit none</span>

  <span class="pl-k">integer</span>, <span class="pl-k">intent</span>(<span class="pl-k">in</span>) <span class="pl-k">::</span> nx
  <span class="pl-k">integer</span>, <span class="pl-k">intent</span>(<span class="pl-k">in</span>) <span class="pl-k">::</span> ny
  <span class="pl-k">integer</span>, <span class="pl-k">dimension</span>(nx<span class="pl-k">*</span>ny) <span class="pl-k">::</span> arr

<span class="pl-k">return</span>
<span class="pl-k">end</span> <span class="pl-k">subroutine</span><span class="pl-en"> test</span></pre></div>
<p dir="auto">It used to work with numpy 1.22.0 or earlier, despite the <code class="notranslate">Warning: cross-dependence between variables "ny" and "nx"</code> and the weird shape checks as shown in the generated <code class="notranslate">test.pyf</code> signature file below:</p>
<div class="highlight highlight-source-fortran-modern notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="!    -*- f90 -*-
! Note: the context of this file is case sensitive.

python module test ! in 
    interface  ! in :test
        subroutine test(nx,ny,arr) ! in :test:src/test.f90
            integer, optional,intent(in),check(shape(arr, 0) == nx * ny),depend(ny,arr) :: nx=shape(arr, 0) / nx
            integer, optional,intent(in),check(shape(arr, 0) == nx * ny),depend(nx,arr) :: ny=shape(arr, 0) / nx
            integer dimension(nx * ny) :: arr
        end subroutine test
    end interface 
end python module test

! This file was auto-generated with f2py (version:1.22.0).
! See:
! https://web.archive.org/web/20140822061353/http://cens.ioc.ee/projects/f2py2e"><pre class="notranslate"><span class="pl-c"><span class="pl-c">!</span>    -*- f90 -*-</span>
<span class="pl-c"><span class="pl-c">!</span> Note: the context of this file is case sensitive.</span>

python <span class="pl-k">module</span> test <span class="pl-c"><span class="pl-c">!</span> in </span>
    <span class="pl-k">interface</span>  <span class="pl-c"><span class="pl-c">!</span> in :test</span>
        <span class="pl-k">subroutine</span> <span class="pl-en">test</span>(<span class="pl-v">nx</span>,<span class="pl-v">ny</span>,<span class="pl-v">arr</span>) <span class="pl-c"><span class="pl-c">!</span> in :test:src/test.f90</span>
            <span class="pl-k">integer</span>, <span class="pl-k">optional</span>,<span class="pl-k">intent</span>(<span class="pl-k">in</span>),check(<span class="pl-k">shape</span>(arr, <span class="pl-c1">0</span>) == nx <span class="pl-k">*</span> ny),depend(ny,arr) <span class="pl-k">::</span> nx<span class="pl-k">=</span><span class="pl-k">shape</span>(arr, <span class="pl-c1">0</span>) <span class="pl-k">/</span> nx
            <span class="pl-k">integer</span>, <span class="pl-k">optional</span>,<span class="pl-k">intent</span>(<span class="pl-k">in</span>),check(<span class="pl-k">shape</span>(arr, <span class="pl-c1">0</span>) == nx <span class="pl-k">*</span> ny),depend(nx,arr) <span class="pl-k">::</span> ny<span class="pl-k">=</span><span class="pl-k">shape</span>(arr, <span class="pl-c1">0</span>) <span class="pl-k">/</span> nx
            <span class="pl-k">integer</span> <span class="pl-k">dimension</span>(nx <span class="pl-k">*</span> ny) <span class="pl-k">::</span> arr
        <span class="pl-k">end</span> <span class="pl-k">subroutine</span><span class="pl-en"> test</span>
    <span class="pl-k">end interface</span> 
end python <span class="pl-k">module</span> test

<span class="pl-c"><span class="pl-c">!</span> This file was auto-generated with f2py (version:1.22.0).</span>
<span class="pl-c"><span class="pl-c">!</span> See:</span>
<span class="pl-c"><span class="pl-c">!</span> https://web.archive.org/web/20140822061353/http://cens.ioc.ee/projects/f2py2e</span></pre></div>
<p dir="auto">However, with numpy 1.22.1 or later, it generates a <code class="notranslate">test.pyf</code> with "swapped" nx / ny:</p>
<div class="highlight highlight-source-fortran-modern notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="!    -*- f90 -*-
! Note: the context of this file is case sensitive.

python module test ! in 
    interface  ! in :test
        subroutine test(nx,ny,arr) ! in :test:src/test.f90
            integer, optional,intent(in),check(shape(arr, 0) == nx * ny),depend(ny,arr) :: nx=shape(arr, 0) / ny
            integer, optional,intent(in),check(shape(arr, 0) == nx * ny),depend(arr,nx) :: ny=shape(arr, 0) / nx
            integer dimension(nx * ny) :: arr
        end subroutine test
    end interface 
end python module test

! This file was auto-generated with f2py (version:1.22.1).
! See:
! https://web.archive.org/web/20140822061353/http://cens.ioc.ee/projects/f2py2e"><pre class="notranslate"><span class="pl-c"><span class="pl-c">!</span>    -*- f90 -*-</span>
<span class="pl-c"><span class="pl-c">!</span> Note: the context of this file is case sensitive.</span>

python <span class="pl-k">module</span> test <span class="pl-c"><span class="pl-c">!</span> in </span>
    <span class="pl-k">interface</span>  <span class="pl-c"><span class="pl-c">!</span> in :test</span>
        <span class="pl-k">subroutine</span> <span class="pl-en">test</span>(<span class="pl-v">nx</span>,<span class="pl-v">ny</span>,<span class="pl-v">arr</span>) <span class="pl-c"><span class="pl-c">!</span> in :test:src/test.f90</span>
            <span class="pl-k">integer</span>, <span class="pl-k">optional</span>,<span class="pl-k">intent</span>(<span class="pl-k">in</span>),check(<span class="pl-k">shape</span>(arr, <span class="pl-c1">0</span>) == nx <span class="pl-k">*</span> ny),depend(ny,arr) <span class="pl-k">::</span> nx<span class="pl-k">=</span><span class="pl-k">shape</span>(arr, <span class="pl-c1">0</span>) <span class="pl-k">/</span> ny
            <span class="pl-k">integer</span>, <span class="pl-k">optional</span>,<span class="pl-k">intent</span>(<span class="pl-k">in</span>),check(<span class="pl-k">shape</span>(arr, <span class="pl-c1">0</span>) == nx <span class="pl-k">*</span> ny),depend(arr,nx) <span class="pl-k">::</span> ny<span class="pl-k">=</span><span class="pl-k">shape</span>(arr, <span class="pl-c1">0</span>) <span class="pl-k">/</span> nx
            <span class="pl-k">integer</span> <span class="pl-k">dimension</span>(nx <span class="pl-k">*</span> ny) <span class="pl-k">::</span> arr
        <span class="pl-k">end</span> <span class="pl-k">subroutine</span><span class="pl-en"> test</span>
    <span class="pl-k">end interface</span> 
end python <span class="pl-k">module</span> test

<span class="pl-c"><span class="pl-c">!</span> This file was auto-generated with f2py (version:1.22.1).</span>
<span class="pl-c"><span class="pl-c">!</span> See:</span>
<span class="pl-c"><span class="pl-c">!</span> https://web.archive.org/web/20140822061353/http://cens.ioc.ee/projects/f2py2e</span></pre></div>
<p dir="auto">Which causes the following recursion error when trying to generate the Python extension from the signature file:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Reading fortran codes...
        Reading file 'test.pyf' (format:free)
Post-processing...
        Block: test
                        Block: test
Traceback (most recent call last):
  File &quot;/Users/me/env/bin/f2py&quot;, line 8, in &lt;module&gt;
    sys.exit(main())
  File &quot;/Users/me/env/lib/python3.9/site-packages/numpy/f2py/f2py2e.py&quot;, line 693, in main
    run_main(sys.argv[1:])
  File &quot;/Users/me/env/lib/python3.9/site-packages/numpy/f2py/f2py2e.py&quot;, line 430, in run_main
    postlist = callcrackfortran(files, options)
  File &quot;/Users/me/env/lib/python3.9/site-packages/numpy/f2py/f2py2e.py&quot;, line 333, in callcrackfortran
    postlist = crackfortran.crackfortran(files)
  File &quot;/Users/me/env/lib/python3.9/site-packages/numpy/f2py/crackfortran.py&quot;, line 3209, in crackfortran
    postlist = postcrack(grouplist[0])
  File &quot;/Users/me/env/lib/python3.9/site-packages/numpy/f2py/crackfortran.py&quot;, line 1926, in postcrack
    g = postcrack(g, tab=tab + '\t')
  File &quot;/Users/me/env/lib/python3.9/site-packages/numpy/f2py/crackfortran.py&quot;, line 1945, in postcrack
    block['body'] = analyzebody(block, args, tab=tab)
  File &quot;/Users/me/env/lib/python3.9/site-packages/numpy/f2py/crackfortran.py&quot;, line 2107, in analyzebody
    b = postcrack(b, as_, tab=tab + '\t')
  File &quot;/Users/me/env/lib/python3.9/site-packages/numpy/f2py/crackfortran.py&quot;, line 1945, in postcrack
    block['body'] = analyzebody(block, args, tab=tab)
  File &quot;/Users/me/env/lib/python3.9/site-packages/numpy/f2py/crackfortran.py&quot;, line 2107, in analyzebody
    b = postcrack(b, as_, tab=tab + '\t')
  File &quot;/Users/me/env/lib/python3.9/site-packages/numpy/f2py/crackfortran.py&quot;, line 1941, in postcrack
    block['vars'] = analyzevars(block)
  File &quot;/Users/me/env/lib/python3.9/site-packages/numpy/f2py/crackfortran.py&quot;, line 2458, in analyzevars
    params = get_parameters(vars, get_useparameters(block))
  File &quot;/Users/me/env/lib/python3.9/site-packages/numpy/f2py/crackfortran.py&quot;, line 2329, in get_parameters
    for n in get_sorted_names(vars):
  File &quot;/Users/me/env/lib/python3.9/site-packages/numpy/f2py/crackfortran.py&quot;, line 2257, in get_sorted_names
    depend_dict = _calc_depend_dict(vars)
  File &quot;/Users/me/env/lib/python3.9/site-packages/numpy/f2py/crackfortran.py&quot;, line 2250, in _calc_depend_dict
    _get_depend_dict(n, vars, depend_dict)
  File &quot;/Users/me/env/lib/python3.9/site-packages/numpy/f2py/crackfortran.py&quot;, line 2236, in _get_depend_dict
    or _get_depend_dict(word, vars, deps):
  File &quot;/Users/me/env/lib/python3.9/site-packages/numpy/f2py/crackfortran.py&quot;, line 2236, in _get_depend_dict
    or _get_depend_dict(word, vars, deps):
  File &quot;/Users/me/env/lib/python3.9/site-packages/numpy/f2py/crackfortran.py&quot;, line 2236, in _get_depend_dict
    or _get_depend_dict(word, vars, deps):
  [Previous line repeated 979 more times]
  File &quot;/Users/me/env/lib/python3.9/site-packages/numpy/f2py/crackfortran.py&quot;, line 2228, in _get_depend_dict
    if '=' in vars[name] and not isstring(vars[name]):
  File &quot;/Users/me/env/lib/python3.9/site-packages/numpy/f2py/auxfuncs.py&quot;, line 77, in isstring
    return _isstring(var) and not isarray(var)
  File &quot;/Users/me/env/lib/python3.9/site-packages/numpy/f2py/auxfuncs.py&quot;, line 72, in _isstring
    return 'typespec' in var and var['typespec'] == 'character' and \
RecursionError: maximum recursion depth exceeded in comparison"><pre class="notranslate"><code class="notranslate">Reading fortran codes...
        Reading file 'test.pyf' (format:free)
Post-processing...
        Block: test
                        Block: test
Traceback (most recent call last):
  File "/Users/me/env/bin/f2py", line 8, in &lt;module&gt;
    sys.exit(main())
  File "/Users/me/env/lib/python3.9/site-packages/numpy/f2py/f2py2e.py", line 693, in main
    run_main(sys.argv[1:])
  File "/Users/me/env/lib/python3.9/site-packages/numpy/f2py/f2py2e.py", line 430, in run_main
    postlist = callcrackfortran(files, options)
  File "/Users/me/env/lib/python3.9/site-packages/numpy/f2py/f2py2e.py", line 333, in callcrackfortran
    postlist = crackfortran.crackfortran(files)
  File "/Users/me/env/lib/python3.9/site-packages/numpy/f2py/crackfortran.py", line 3209, in crackfortran
    postlist = postcrack(grouplist[0])
  File "/Users/me/env/lib/python3.9/site-packages/numpy/f2py/crackfortran.py", line 1926, in postcrack
    g = postcrack(g, tab=tab + '\t')
  File "/Users/me/env/lib/python3.9/site-packages/numpy/f2py/crackfortran.py", line 1945, in postcrack
    block['body'] = analyzebody(block, args, tab=tab)
  File "/Users/me/env/lib/python3.9/site-packages/numpy/f2py/crackfortran.py", line 2107, in analyzebody
    b = postcrack(b, as_, tab=tab + '\t')
  File "/Users/me/env/lib/python3.9/site-packages/numpy/f2py/crackfortran.py", line 1945, in postcrack
    block['body'] = analyzebody(block, args, tab=tab)
  File "/Users/me/env/lib/python3.9/site-packages/numpy/f2py/crackfortran.py", line 2107, in analyzebody
    b = postcrack(b, as_, tab=tab + '\t')
  File "/Users/me/env/lib/python3.9/site-packages/numpy/f2py/crackfortran.py", line 1941, in postcrack
    block['vars'] = analyzevars(block)
  File "/Users/me/env/lib/python3.9/site-packages/numpy/f2py/crackfortran.py", line 2458, in analyzevars
    params = get_parameters(vars, get_useparameters(block))
  File "/Users/me/env/lib/python3.9/site-packages/numpy/f2py/crackfortran.py", line 2329, in get_parameters
    for n in get_sorted_names(vars):
  File "/Users/me/env/lib/python3.9/site-packages/numpy/f2py/crackfortran.py", line 2257, in get_sorted_names
    depend_dict = _calc_depend_dict(vars)
  File "/Users/me/env/lib/python3.9/site-packages/numpy/f2py/crackfortran.py", line 2250, in _calc_depend_dict
    _get_depend_dict(n, vars, depend_dict)
  File "/Users/me/env/lib/python3.9/site-packages/numpy/f2py/crackfortran.py", line 2236, in _get_depend_dict
    or _get_depend_dict(word, vars, deps):
  File "/Users/me/env/lib/python3.9/site-packages/numpy/f2py/crackfortran.py", line 2236, in _get_depend_dict
    or _get_depend_dict(word, vars, deps):
  File "/Users/me/env/lib/python3.9/site-packages/numpy/f2py/crackfortran.py", line 2236, in _get_depend_dict
    or _get_depend_dict(word, vars, deps):
  [Previous line repeated 979 more times]
  File "/Users/me/env/lib/python3.9/site-packages/numpy/f2py/crackfortran.py", line 2228, in _get_depend_dict
    if '=' in vars[name] and not isstring(vars[name]):
  File "/Users/me/env/lib/python3.9/site-packages/numpy/f2py/auxfuncs.py", line 77, in isstring
    return _isstring(var) and not isarray(var)
  File "/Users/me/env/lib/python3.9/site-packages/numpy/f2py/auxfuncs.py", line 72, in _isstring
    return 'typespec' in var and var['typespec'] == 'character' and \
RecursionError: maximum recursion depth exceeded in comparison
</code></pre></div>
<p dir="auto">The difference between the two generated signature files seems to be a result of <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="1092861959" data-permission-text="Title is private" data-url="https://github.com/numpy/numpy/issues/20721" data-hovercard-type="pull_request" data-hovercard-url="/numpy/numpy/pull/20721/hovercard" href="https://github.com/numpy/numpy/pull/20721">#20721</a>.</p>
<p dir="auto">(*) Do you think the issue here could be considered as a regression? Or is the example here wrong and we should not declare dimensions of automatic arrays from two or more variables? Not sure about this as I'm not a Fortran expert and haven't found much info about this practice, although I'd be surprised that compilers let us do it if it wasn't valid.</p>
<h3 dir="auto">Reproduce the code example:</h3>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="see f90 / pyf source above"><pre class="notranslate"><span class="pl-s1">see</span> <span class="pl-s1">f90</span> <span class="pl-c1">/</span> <span class="pl-s1">pyf</span> <span class="pl-s1">source</span> <span class="pl-s1">above</span></pre></div>
<h3 dir="auto">Error message:</h3>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="See recursion error above."><pre class="notranslate">See recursion error above.</pre></div>
<h3 dir="auto">NumPy/Python version information:</h3>
<p dir="auto">Numpy 1.22.0 / 1.22.1<br>
Python 3.9</p>
<h3 dir="auto">Describe the issue:</h3>
<p dir="auto">Let's consider the following subroutine in a <code class="notranslate">test.f90</code> file that declares an automatic array from two variables(*):</p>
<div class="highlight highlight-source-fortran-modern notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="subroutine test (nx, ny, arr)

  implicit none

  integer, intent(in) :: nx
  integer, intent(in) :: ny
  integer, dimension(nx*ny) :: arr

return
end subroutine test"><pre class="notranslate"><span class="pl-k">subroutine</span> <span class="pl-en">test</span> (<span class="pl-v">nx</span>, <span class="pl-v">ny</span>, <span class="pl-v">arr</span>)

  <span class="pl-k">implicit none</span>

  <span class="pl-k">integer</span>, <span class="pl-k">intent</span>(<span class="pl-k">in</span>) <span class="pl-k">::</span> nx
  <span class="pl-k">integer</span>, <span class="pl-k">intent</span>(<span class="pl-k">in</span>) <span class="pl-k">::</span> ny
  <span class="pl-k">integer</span>, <span class="pl-k">dimension</span>(nx<span class="pl-k">*</span>ny) <span class="pl-k">::</span> arr

<span class="pl-k">return</span>
<span class="pl-k">end</span> <span class="pl-k">subroutine</span><span class="pl-en"> test</span></pre></div>
<p dir="auto">It used to work with numpy 1.22.0 or earlier, despite the <code class="notranslate">Warning: cross-dependence between variables "ny" and "nx"</code> and the weird shape checks as shown in the generated <code class="notranslate">test.pyf</code> signature file below:</p>
<div class="highlight highlight-source-fortran-modern notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="!    -*- f90 -*-
! Note: the context of this file is case sensitive.

python module test ! in 
    interface  ! in :test
        subroutine test(nx,ny,arr) ! in :test:src/test.f90
            integer, optional,intent(in),check(shape(arr, 0) == nx * ny),depend(ny,arr) :: nx=shape(arr, 0) / nx
            integer, optional,intent(in),check(shape(arr, 0) == nx * ny),depend(nx,arr) :: ny=shape(arr, 0) / nx
            integer dimension(nx * ny) :: arr
        end subroutine test
    end interface 
end python module test

! This file was auto-generated with f2py (version:1.22.0).
! See:
! https://web.archive.org/web/20140822061353/http://cens.ioc.ee/projects/f2py2e"><pre class="notranslate"><span class="pl-c"><span class="pl-c">!</span>    -*- f90 -*-</span>
<span class="pl-c"><span class="pl-c">!</span> Note: the context of this file is case sensitive.</span>

python <span class="pl-k">module</span> test <span class="pl-c"><span class="pl-c">!</span> in </span>
    <span class="pl-k">interface</span>  <span class="pl-c"><span class="pl-c">!</span> in :test</span>
        <span class="pl-k">subroutine</span> <span class="pl-en">test</span>(<span class="pl-v">nx</span>,<span class="pl-v">ny</span>,<span class="pl-v">arr</span>) <span class="pl-c"><span class="pl-c">!</span> in :test:src/test.f90</span>
            <span class="pl-k">integer</span>, <span class="pl-k">optional</span>,<span class="pl-k">intent</span>(<span class="pl-k">in</span>),check(<span class="pl-k">shape</span>(arr, <span class="pl-c1">0</span>) == nx <span class="pl-k">*</span> ny),depend(ny,arr) <span class="pl-k">::</span> nx<span class="pl-k">=</span><span class="pl-k">shape</span>(arr, <span class="pl-c1">0</span>) <span class="pl-k">/</span> nx
            <span class="pl-k">integer</span>, <span class="pl-k">optional</span>,<span class="pl-k">intent</span>(<span class="pl-k">in</span>),check(<span class="pl-k">shape</span>(arr, <span class="pl-c1">0</span>) == nx <span class="pl-k">*</span> ny),depend(nx,arr) <span class="pl-k">::</span> ny<span class="pl-k">=</span><span class="pl-k">shape</span>(arr, <span class="pl-c1">0</span>) <span class="pl-k">/</span> nx
            <span class="pl-k">integer</span> <span class="pl-k">dimension</span>(nx <span class="pl-k">*</span> ny) <span class="pl-k">::</span> arr
        <span class="pl-k">end</span> <span class="pl-k">subroutine</span><span class="pl-en"> test</span>
    <span class="pl-k">end interface</span> 
end python <span class="pl-k">module</span> test

<span class="pl-c"><span class="pl-c">!</span> This file was auto-generated with f2py (version:1.22.0).</span>
<span class="pl-c"><span class="pl-c">!</span> See:</span>
<span class="pl-c"><span class="pl-c">!</span> https://web.archive.org/web/20140822061353/http://cens.ioc.ee/projects/f2py2e</span></pre></div>
<p dir="auto">However, with numpy 1.22.1 or later, it generates a <code class="notranslate">test.pyf</code> with "swapped" nx / ny:</p>
<div class="highlight highlight-source-fortran-modern notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="!    -*- f90 -*-
! Note: the context of this file is case sensitive.

python module test ! in 
    interface  ! in :test
        subroutine test(nx,ny,arr) ! in :test:src/test.f90
            integer, optional,intent(in),check(shape(arr, 0) == nx * ny),depend(ny,arr) :: nx=shape(arr, 0) / ny
            integer, optional,intent(in),check(shape(arr, 0) == nx * ny),depend(arr,nx) :: ny=shape(arr, 0) / nx
            integer dimension(nx * ny) :: arr
        end subroutine test
    end interface 
end python module test

! This file was auto-generated with f2py (version:1.22.1).
! See:
! https://web.archive.org/web/20140822061353/http://cens.ioc.ee/projects/f2py2e"><pre class="notranslate"><span class="pl-c"><span class="pl-c">!</span>    -*- f90 -*-</span>
<span class="pl-c"><span class="pl-c">!</span> Note: the context of this file is case sensitive.</span>

python <span class="pl-k">module</span> test <span class="pl-c"><span class="pl-c">!</span> in </span>
    <span class="pl-k">interface</span>  <span class="pl-c"><span class="pl-c">!</span> in :test</span>
        <span class="pl-k">subroutine</span> <span class="pl-en">test</span>(<span class="pl-v">nx</span>,<span class="pl-v">ny</span>,<span class="pl-v">arr</span>) <span class="pl-c"><span class="pl-c">!</span> in :test:src/test.f90</span>
            <span class="pl-k">integer</span>, <span class="pl-k">optional</span>,<span class="pl-k">intent</span>(<span class="pl-k">in</span>),check(<span class="pl-k">shape</span>(arr, <span class="pl-c1">0</span>) == nx <span class="pl-k">*</span> ny),depend(ny,arr) <span class="pl-k">::</span> nx<span class="pl-k">=</span><span class="pl-k">shape</span>(arr, <span class="pl-c1">0</span>) <span class="pl-k">/</span> ny
            <span class="pl-k">integer</span>, <span class="pl-k">optional</span>,<span class="pl-k">intent</span>(<span class="pl-k">in</span>),check(<span class="pl-k">shape</span>(arr, <span class="pl-c1">0</span>) == nx <span class="pl-k">*</span> ny),depend(arr,nx) <span class="pl-k">::</span> ny<span class="pl-k">=</span><span class="pl-k">shape</span>(arr, <span class="pl-c1">0</span>) <span class="pl-k">/</span> nx
            <span class="pl-k">integer</span> <span class="pl-k">dimension</span>(nx <span class="pl-k">*</span> ny) <span class="pl-k">::</span> arr
        <span class="pl-k">end</span> <span class="pl-k">subroutine</span><span class="pl-en"> test</span>
    <span class="pl-k">end interface</span> 
end python <span class="pl-k">module</span> test

<span class="pl-c"><span class="pl-c">!</span> This file was auto-generated with f2py (version:1.22.1).</span>
<span class="pl-c"><span class="pl-c">!</span> See:</span>
<span class="pl-c"><span class="pl-c">!</span> https://web.archive.org/web/20140822061353/http://cens.ioc.ee/projects/f2py2e</span></pre></div>
<p dir="auto">Which causes the following recursion error when trying to generate the Python extension from the signature file:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Reading fortran codes...
        Reading file 'test.pyf' (format:free)
Post-processing...
        Block: test
                        Block: test
Traceback (most recent call last):
  File &quot;/Users/me/env/bin/f2py&quot;, line 8, in &lt;module&gt;
    sys.exit(main())
  File &quot;/Users/me/env/lib/python3.9/site-packages/numpy/f2py/f2py2e.py&quot;, line 693, in main
    run_main(sys.argv[1:])
  File &quot;/Users/me/env/lib/python3.9/site-packages/numpy/f2py/f2py2e.py&quot;, line 430, in run_main
    postlist = callcrackfortran(files, options)
  File &quot;/Users/me/env/lib/python3.9/site-packages/numpy/f2py/f2py2e.py&quot;, line 333, in callcrackfortran
    postlist = crackfortran.crackfortran(files)
  File &quot;/Users/me/env/lib/python3.9/site-packages/numpy/f2py/crackfortran.py&quot;, line 3209, in crackfortran
    postlist = postcrack(grouplist[0])
  File &quot;/Users/me/env/lib/python3.9/site-packages/numpy/f2py/crackfortran.py&quot;, line 1926, in postcrack
    g = postcrack(g, tab=tab + '\t')
  File &quot;/Users/me/env/lib/python3.9/site-packages/numpy/f2py/crackfortran.py&quot;, line 1945, in postcrack
    block['body'] = analyzebody(block, args, tab=tab)
  File &quot;/Users/me/env/lib/python3.9/site-packages/numpy/f2py/crackfortran.py&quot;, line 2107, in analyzebody
    b = postcrack(b, as_, tab=tab + '\t')
  File &quot;/Users/me/env/lib/python3.9/site-packages/numpy/f2py/crackfortran.py&quot;, line 1945, in postcrack
    block['body'] = analyzebody(block, args, tab=tab)
  File &quot;/Users/me/env/lib/python3.9/site-packages/numpy/f2py/crackfortran.py&quot;, line 2107, in analyzebody
    b = postcrack(b, as_, tab=tab + '\t')
  File &quot;/Users/me/env/lib/python3.9/site-packages/numpy/f2py/crackfortran.py&quot;, line 1941, in postcrack
    block['vars'] = analyzevars(block)
  File &quot;/Users/me/env/lib/python3.9/site-packages/numpy/f2py/crackfortran.py&quot;, line 2458, in analyzevars
    params = get_parameters(vars, get_useparameters(block))
  File &quot;/Users/me/env/lib/python3.9/site-packages/numpy/f2py/crackfortran.py&quot;, line 2329, in get_parameters
    for n in get_sorted_names(vars):
  File &quot;/Users/me/env/lib/python3.9/site-packages/numpy/f2py/crackfortran.py&quot;, line 2257, in get_sorted_names
    depend_dict = _calc_depend_dict(vars)
  File &quot;/Users/me/env/lib/python3.9/site-packages/numpy/f2py/crackfortran.py&quot;, line 2250, in _calc_depend_dict
    _get_depend_dict(n, vars, depend_dict)
  File &quot;/Users/me/env/lib/python3.9/site-packages/numpy/f2py/crackfortran.py&quot;, line 2236, in _get_depend_dict
    or _get_depend_dict(word, vars, deps):
  File &quot;/Users/me/env/lib/python3.9/site-packages/numpy/f2py/crackfortran.py&quot;, line 2236, in _get_depend_dict
    or _get_depend_dict(word, vars, deps):
  File &quot;/Users/me/env/lib/python3.9/site-packages/numpy/f2py/crackfortran.py&quot;, line 2236, in _get_depend_dict
    or _get_depend_dict(word, vars, deps):
  [Previous line repeated 979 more times]
  File &quot;/Users/me/env/lib/python3.9/site-packages/numpy/f2py/crackfortran.py&quot;, line 2228, in _get_depend_dict
    if '=' in vars[name] and not isstring(vars[name]):
  File &quot;/Users/me/env/lib/python3.9/site-packages/numpy/f2py/auxfuncs.py&quot;, line 77, in isstring
    return _isstring(var) and not isarray(var)
  File &quot;/Users/me/env/lib/python3.9/site-packages/numpy/f2py/auxfuncs.py&quot;, line 72, in _isstring
    return 'typespec' in var and var['typespec'] == 'character' and \
RecursionError: maximum recursion depth exceeded in comparison"><pre class="notranslate"><code class="notranslate">Reading fortran codes...
        Reading file 'test.pyf' (format:free)
Post-processing...
        Block: test
                        Block: test
Traceback (most recent call last):
  File "/Users/me/env/bin/f2py", line 8, in &lt;module&gt;
    sys.exit(main())
  File "/Users/me/env/lib/python3.9/site-packages/numpy/f2py/f2py2e.py", line 693, in main
    run_main(sys.argv[1:])
  File "/Users/me/env/lib/python3.9/site-packages/numpy/f2py/f2py2e.py", line 430, in run_main
    postlist = callcrackfortran(files, options)
  File "/Users/me/env/lib/python3.9/site-packages/numpy/f2py/f2py2e.py", line 333, in callcrackfortran
    postlist = crackfortran.crackfortran(files)
  File "/Users/me/env/lib/python3.9/site-packages/numpy/f2py/crackfortran.py", line 3209, in crackfortran
    postlist = postcrack(grouplist[0])
  File "/Users/me/env/lib/python3.9/site-packages/numpy/f2py/crackfortran.py", line 1926, in postcrack
    g = postcrack(g, tab=tab + '\t')
  File "/Users/me/env/lib/python3.9/site-packages/numpy/f2py/crackfortran.py", line 1945, in postcrack
    block['body'] = analyzebody(block, args, tab=tab)
  File "/Users/me/env/lib/python3.9/site-packages/numpy/f2py/crackfortran.py", line 2107, in analyzebody
    b = postcrack(b, as_, tab=tab + '\t')
  File "/Users/me/env/lib/python3.9/site-packages/numpy/f2py/crackfortran.py", line 1945, in postcrack
    block['body'] = analyzebody(block, args, tab=tab)
  File "/Users/me/env/lib/python3.9/site-packages/numpy/f2py/crackfortran.py", line 2107, in analyzebody
    b = postcrack(b, as_, tab=tab + '\t')
  File "/Users/me/env/lib/python3.9/site-packages/numpy/f2py/crackfortran.py", line 1941, in postcrack
    block['vars'] = analyzevars(block)
  File "/Users/me/env/lib/python3.9/site-packages/numpy/f2py/crackfortran.py", line 2458, in analyzevars
    params = get_parameters(vars, get_useparameters(block))
  File "/Users/me/env/lib/python3.9/site-packages/numpy/f2py/crackfortran.py", line 2329, in get_parameters
    for n in get_sorted_names(vars):
  File "/Users/me/env/lib/python3.9/site-packages/numpy/f2py/crackfortran.py", line 2257, in get_sorted_names
    depend_dict = _calc_depend_dict(vars)
  File "/Users/me/env/lib/python3.9/site-packages/numpy/f2py/crackfortran.py", line 2250, in _calc_depend_dict
    _get_depend_dict(n, vars, depend_dict)
  File "/Users/me/env/lib/python3.9/site-packages/numpy/f2py/crackfortran.py", line 2236, in _get_depend_dict
    or _get_depend_dict(word, vars, deps):
  File "/Users/me/env/lib/python3.9/site-packages/numpy/f2py/crackfortran.py", line 2236, in _get_depend_dict
    or _get_depend_dict(word, vars, deps):
  File "/Users/me/env/lib/python3.9/site-packages/numpy/f2py/crackfortran.py", line 2236, in _get_depend_dict
    or _get_depend_dict(word, vars, deps):
  [Previous line repeated 979 more times]
  File "/Users/me/env/lib/python3.9/site-packages/numpy/f2py/crackfortran.py", line 2228, in _get_depend_dict
    if '=' in vars[name] and not isstring(vars[name]):
  File "/Users/me/env/lib/python3.9/site-packages/numpy/f2py/auxfuncs.py", line 77, in isstring
    return _isstring(var) and not isarray(var)
  File "/Users/me/env/lib/python3.9/site-packages/numpy/f2py/auxfuncs.py", line 72, in _isstring
    return 'typespec' in var and var['typespec'] == 'character' and \
RecursionError: maximum recursion depth exceeded in comparison
</code></pre></div>
<p dir="auto">The difference between the two generated signature files seems to be a result of <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="1092861959" data-permission-text="Title is private" data-url="https://github.com/numpy/numpy/issues/20721" data-hovercard-type="pull_request" data-hovercard-url="/numpy/numpy/pull/20721/hovercard" href="https://github.com/numpy/numpy/pull/20721">#20721</a>.</p>
<p dir="auto">(*) Do you think the issue here could be considered as a regression? Or is the example here wrong and we should not declare dimensions of automatic arrays from two or more variables? Not sure about this as I'm not a Fortran expert and haven't found much info about this practice, although I'd be surprised that compilers let us do it if it wasn't valid.</p>
<h3 dir="auto">Reproduce the code example:</h3>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="# see f90 / pyf source above"><pre class="notranslate"><span class="pl-c"># see f90 / pyf source above</span></pre></div>
<h3 dir="auto">Error message:</h3>
<p dir="auto"><em>No response</em></p>
<h3 dir="auto">NumPy/Python version information:</h3>
<p dir="auto">Numpy 1.22.0 / 1.22.1<br>
Python 3.9</p>