Rewrite Fortran expression as f2py supported C expression. Due to the lack of a proper expression parser in f2py, this function uses a heuristic approach that assumes that Fortran arithmetic expressions are valid C arithmetic expressions when mapping Fortran function calls to the co
(expr)
| 236 | |
| 237 | |
| 238 | def f2cexpr(expr): |
| 239 | """Rewrite Fortran expression as f2py supported C expression. |
| 240 | |
| 241 | Due to the lack of a proper expression parser in f2py, this |
| 242 | function uses a heuristic approach that assumes that Fortran |
| 243 | arithmetic expressions are valid C arithmetic expressions when |
| 244 | mapping Fortran function calls to the corresponding C function/CPP |
| 245 | macros calls. |
| 246 | |
| 247 | """ |
| 248 | # TODO: support Fortran `len` function with optional kind parameter |
| 249 | expr = re.sub(r'\blen\b', 'f2py_slen', expr) |
| 250 | return expr |
| 251 | |
| 252 | |
| 253 | def getstrlength(var): |