2

I am in the process of converting a Fortran 90 code to python. The Fortran code includes multidimensional array like:

integer fvpair(3,12,2)
integer jpair(3,2)
real*8 aread(3,12)

I wonder if the following numpy array are correct equivalent, assuming zero initialization:

fvpair = np.array([[np.zeros(3)],[np.zeros(12)],[np.zeros(2)]])
jpair = np.array([[np.zeros(3)],[np.zeros(2)]])
aread = np.array([[np.zeros(3)],[np.zeros(12)]])
1
  • 4
    You probably want fvpair = np.zeros((3,12,2), dtype=int). Commented Nov 28, 2020 at 3:50

1 Answer 1

3

If you want to preserve the original Fortran array storage order (column-major), do not forget to pass the order='F' flag!

fvpair = np.zeros((3,12,2), dtype=int, order='F')
jpair = np.zeros((3,2), dtype=int, order='F')
aread = np.zeros((3,2), dtype=float64, order='F')
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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.