-
-
Couldn't load subscription status.
- Fork 11.6k
Description
this is for f2py (version 1.20.2)
when use f90-style
character(len=n), dimension(m) :: variabledefinition it fails (creates single byte string of length m (dim=(), dtype='|Sm')) whereas when I use F77-style length specification
character*n, dimension(m) :: variableit correctly produces an array dim=(m,), dtype = '|Sn'.
I am hoping that crackfortran could be relatively(?) easily adjusted to add a regexp to also accept the f90-style character length specification? For context (see example below), I use a *.f code file (f77 format) for the code layout, but the same Fortran code should be allowable either way, whether using .f or .f90. (I have not tested whether this already works in an .f90 file.)
Or maybe I am just overlooking something?
Reproducing code example:
To give an real-world example, I have the snippets
integer(kind=int32), parameter :: ndtz = 30 character(len=8), dimension(ndtz) ::
& idtcsym
common/charsave/
& idtcsymand then after compilation
In [4]: k._kepler.charsave.idtcsym
Out[4]: array(b'dtr dtt
6850
dtd dtq ', dtype='|S30')
whereas
character*8, dimension(ndtz) ::
& idtcsym
common/charsave/
& idtcsymas, as it should lines in the output of compilation
analyzevars: charselector={'len': '8'} unhandled.analyzevars: charselector={'len': '8'} unhandled.analyzevars: character array "character*8 idtcsym(30)" is considered as "character idtcsym(30,8)"; "intent(c)" is forced.
and resulting in
In [3]: k._kepler.charsave.idtcsym
Out[3]:
array([b'dtr ', b'dtt ', b'dtd ', b'dtq ', b'dti ',
b'dtl ', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'',
b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b''],
dtype='|S8')
as it should be.
Error message:
N/A
NumPy/Python version information:
In [1]: import sys, numpy; print(numpy.__version__, sys.version)
1.20.2 3.9.2 (default, Feb 20 2021, 13:24:34)
[GCC 10.2.1 20201125 (Red Hat 10.2.1-9)]