title: Access Common Block variables from ctypes
body: <p>I am trying to access the data stored in a Fortran 77 common block from a Python script. The question is that I don't know where this data is stored.
  The Python application that I am developing makes use of different libraries. These libraries contain functions with the following directives:</p>
  
  <pre><code>#include &lt;tcsisc_common.inc&gt;
  </code></pre>
  
  <p>The common block contains:</p>
  
  <pre><code>C
        INTEGER*4 IDEBUG
  C
  C.... ARRAY DIMENSIONS
        DIMENSION IDEBUG(10)
  C
  C.... COMMON BLOCK
        COMMON /TCSD/ IDEBUG
  C
  </code></pre>
  
  <p>On the Python part (on the example I have used iPython), I load the library: </p>
  
  <pre><code>In [1]: import ctypes
  In [2]: _libtcsisc= /home/jfreixa/project/bin/libtcsisc.so
  In [3]: _tcsisc   = ctypes.CDLL(_libtcsisc, ctypes.RTLD_GLOBAL)
  </code></pre>
  
  <p>The problem is that I don't know how to get IDEBUG. I have tried the following, but I just get tcsd as a c_long initialized to 0.</p>
  
  <pre><code>In [4]: tcsd = ctypes.c_int.in_dll(_tcsisc, "TCSD_")
  In [5]: tcsd
  Out[5]: c_long(0)
  In [6]: idebug = ctypes.c_int.in_dll(_tcsisc, "IDEBUG_")
  ---------------------------------------------------------------------------
  ValueError                                Traceback (most recent call last)
  &lt;ipython-input-6-ee5018286275&gt; in &lt;module&gt;()
  
  ----&gt; 1 idebug = ctypes.c_int.in_dll(_tcsisc,'IDEBUG_')
  
  ValueError: ld.so.1: python2.7: fatal: IDEBUG_: can't find symbol
  </code></pre>
  
  <p>Any idea to correctly get the variable?</p>