I guess so, I think his point is that he wants to keep all of his interfaces C-style row-major.
From my experience I would definitely advise going in this direction. I don’t know how they interact at the source code with the FORTRAN libraries. But if one would like to have arrays being row-major on the python side of things, yet enable interacting with Fortran in a column-major approach it is possible:
let’s say I have a module that I compile to a dll in a file fortran2python.f90
Summary
module wrapper
use iso_c_binding
implicit none
contains
subroutine say_hello(X,dim,num_points)
!DEC$ ATTRIBUTES STDCALL,REFERENCE,ALIAS:'say_hello', DLLEXPORT :: say_hello
! Variables
integer(c_int), intent(in):: num_points
integer(c_int), intent(in):: dim
real(c_double), intent(inout) :: X(dim,num_points) !! array of coordinates
integer :: i
!-------------------------------
print *, 'hello from fortran'
do i = 1, num_points
print *, 'by data point', x(:,i)
end do
x(1,2) = 2*x(1,2)
end subroutine say_hello
end module
and a python test.py
Summary
import numpy as np
import ctypes
folderpath = 'D:\your\full\folder\path'
DLLname = 'fortran2python.dll'
api = np.ctypeslib.load_library(DLLname,folderpath)
X = np.array([
[1.0, 2.0],
[3.0, 4.0],
[5.0, 6.0],
])
print('X shape:',X.shape)
print(X[0,0],X[0,1])
print(X[1,0],X[1,1])
print(X[2,0],X[2,1])
api.say_hello( ctypes.byref(np.ctypeslib.as_ctypes( X )) ,
ctypes.byref(ctypes.c_int(X.shape[1])) ,
ctypes.byref(ctypes.c_int(X.shape[0]))
)
print('back in python')
print(X[0,0],X[0,1])
print(X[1,0],X[1,1])
print(X[2,0],X[2,1])
This will print
X shape: (3, 2)
1.0 2.0
3.0 4.0
5.0 6.0
hello from fortran
by data point 1.00000000000000 2.00000000000000
by data point 3.00000000000000 4.00000000000000
by data point 5.00000000000000 6.00000000000000
back in python
1.0 2.0
6.0 4.0
5.0 6.0
So, you can see that on the python side of things you handle the data in a row-major manner, on the Fortran side on a colum-major manner. No need to copy the data or Transpose the array.
It would be instructive to see an actual use-case of their dilemma, but I’m pretty convinced it could be handled.