Skip to main content
  1. About
  2. For Teams
Asked
Viewed 95 times
2

I was trying to compile a legacy code written in f77 using f2py. The snippet of the code is shown below to demonstrate the issue I am facing.

      PROGRAM TEST
      IMPLICIT REAL*8(A-H,O-Z)
      CHARACTER IFILE*30, TITLE(8)*10
      DIMENSION XINT(100), X(200), Y(200), W(200)
      COMMON /HLM/ DUMMX(2000)
      COMMON /SMY/ DUMMY(2130)
      COMMON /BLK1/ PI,PI2,RAD,CONS
      END PROGRAM TEST

when I compile this using:

f2py -c test.f -m test

However when I load this module, I cannot see or access the arrays xint, x, y and w
Only the common block variables are avaialble.

Python 3.10.4 (main, Apr  2 2022, 09:04:19) [GCC 11.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import test
>>> dir(test)
['__doc__', '__f2py_numpy_version__', '__file__', '__loader__', '__name__', '__package__', '__spec__', '__version__', '_test_error', 'hlm']
>>> dir(test.hlm)
['__call__', '__class__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'dummx']
>>>

What would be the correct way to declare these variables such that they will be accessible in python ?

Thanks.

0

Your Answer

Post as a guest

Required, but never shown

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.

Morty Proxy This is a proxified and sanitized view of the page, visit original site.