Skip to content

BUG: f2py failing to parse fix-form Fortran #28749

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ClarkMyWords opened this issue Apr 17, 2025 · 3 comments
Closed

BUG: f2py failing to parse fix-form Fortran #28749

ClarkMyWords opened this issue Apr 17, 2025 · 3 comments

Comments

@ClarkMyWords
Copy link

ClarkMyWords commented Apr 17, 2025

Describe the issue:

I'm trying to compile a fix-form Fortran file with f2py. In the past I have had this working, but apparently some recent change has broken this? Or perhaps I'm doing something wrong.

I'm including a very simple test file on which it is also failing. I'm getting the same type of error on a much larger file. It seems to me like it doesn't like the fix-form spacing or something, but the file hasn't changed since I previously had it working with f2py.

Reproduce the code example:

Example Fortran File where I'm having the issue:

TEST.f

      subroutine test ()

      implicit none

      character(8) name
      name = 'TEST'

      return
      end

Then running:

f2py -h TEST.pyf TEST.f -m TEST --overwrite-signature --verbose

My actual program is an Abaqus UMAT, so it also only implements subroutines and no main.

Error message:

Reading fortran codes...
	Reading file 'TEST.f' (format:fix,strict)
analyzeline: Creating module block 'TEST'
analyzeline: Creating additional interface block (groupcounter=2).
Line #7 in TEST.f:"      name = 'TEST' "
	crackline:3: No pattern for line
Line #8 in TEST.f:"      return "
	crackline:3: No pattern for line
Post-processing...
	Block: TEST
			Block: test
In: :TEST:TEST.f:test
buildimplicitrules: no implicit rules for routine 'test'.
In: :TEST:TEST.f:test
buildimplicitrules: no implicit rules for routine 'test'.
Applying post-processing hooks...
  character_backward_compatibility_hook
Post-processing (stage 2)...
Saving signatures to file "./TEST.pyf"
Stopping. Edit the signature file and then run f2py on the signature file: f2py ./TEST.pyf

Python and NumPy Versions:

2.2.4
3.13.0 (main, Oct 16 2024, 03:23:02) [Clang 18.1.8 ]

Runtime Environment:

[{'numpy_version': '2.2.4',
'python': '3.13.0 (main, Oct 16 2024, 03:23:02) [Clang 18.1.8 ]',
'uname': uname_result(system='Linux', node='clarklaptop', release='6.14.2-arch1-1', version='#1 SMP PREEMPT_DYNAMIC Thu, 10 Apr 2025 18:43:59 +0000', machine='x86_64')},
{'simd_extensions': {'baseline': ['SSE', 'SSE2', 'SSE3'],
'found': ['SSSE3',
'SSE41',
'POPCNT',
'SSE42',
'AVX',
'F16C',
'FMA3',
'AVX2',
'AVX512F',
'AVX512CD',
'AVX512_SKX',
'AVX512_CLX',
'AVX512_CNL',
'AVX512_ICL'],
'not_found': ['AVX512_KNL', 'AVX512_KNM']}},
{'architecture': 'SkylakeX',
'filepath': '/home/clark/Research/SinglePointSimulator/.venv/lib/python3.13/site-packages/numpy.libs/libscipy_openblas64_-6bb31eeb.so',
'internal_api': 'openblas',
'num_threads': 16,
'prefix': 'libscipy_openblas',
'threading_layer': 'pthreads',
'user_api': 'blas',
'version': '0.3.28'}]

Context for the issue:

I think it's very possible that I'm just formatting something incorrectly, but I need a second set of eyes to look at this. I have run into a similar issue before, but I was using non-standard Fortran extensions, and now I have fixed that issue, but this seems to persist.

Happy to include a longer traceback of what's failing with my actual script, but it's the same "crackline:3; No pattern for line"

TIA for any and all help!

@charris
Copy link
Member

charris commented Apr 18, 2025

@HaoZeke Ping.

@ClarkMyWords
Copy link
Author

Hello,

So, to update, I had something broken in my Fortran. This code had not changed since I'd last used f2py, but it also isn't working in the proprietary software (Abaqus), so I must have done something wrong.

Regardless, t he "crackline:3: No pattern for line" error is showing up, but I realize now that it's essentially just a warning for lines it can't match, i.e. bare returns or variable definitions. I would suggest that those be formatted different to make it clear that those are simply ignored for the .pyf generation, rather than an actual error, because that is what confused me, but clearly it's not a real issue.

I won't close this myself, since that was a little unclear to me, but my issue has been managed!

@melissawm
Copy link
Member

I'm going to close this for now then - thanks for following up, @ClarkMyWords !

@melissawm melissawm closed this as not planned Won't fix, can't repro, duplicate, stale May 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy