We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I'm trying to pass an array between Fortran and Python but the dimensions and type are not matched. In Fortran I have
(gdb) ptype tgrnd type = real(kind=8) (2,72,0:47)
And I pass it with your library with:
call set_state("tg", tgrnd) call call_function("foo", "bar")
And in Python the type and dimensions are:
def bar(STATE): tg = STATE.get("tg", np.nan) print("LIME_py0:", tg.shape) print("LIME_py0:", type(tg)) print("LIME_py0:", type(tg[0,0,0]))
Which outputs
LIME_py0: (25, 72, 2) LIME_py0: <class 'numpy.ndarray'> LIME_py0: <class 'numpy.float64'>
The suspicious part above is the dimensions are 0:47 and not 48. This array, tgrnd, is created with the following statement:
0:47
48
tgrnd
REAL*8, DIMENSION(2,GRID%I_STRT_HALO:GRID%I_STOP_HALO, & GRID%J_STRT_HALO:GRID%J_STOP_HALO) :: & TGRND,TGRN2,TGR4,E1 ! 2 for ocean,seaice
I have a work-around: I can create a new array with explicit dimensions, then copy the values to that, e.g.,
real*8, dimension(2,72,48) :: LIME_T LIME_T = tgrnd
And then if I pass LIME_T to set_state, everything works. I'm not yet sure how to fix this issue, but wanted to raise it.
LIME_T
set_state
The text was updated successfully, but these errors were encountered:
I wouldn't be surprised if there is some error related to using lbound!=1. This is the relevant portion of the code:
call_py_fort/src/callpy_mod.f90
Line 255 in b5f1ac5
Sorry, something went wrong.
No branches or pull requests
I'm trying to pass an array between Fortran and Python but the dimensions and type are not matched. In Fortran I have
And I pass it with your library with:
And in Python the type and dimensions are:
Which outputs
The suspicious part above is the dimensions are
0:47
and not48
. This array,tgrnd
, is created with the following statement:I have a work-around: I can create a new array with explicit dimensions, then copy the values to that, e.g.,
And then if I pass
LIME_T
toset_state
, everything works. I'm not yet sure how to fix this issue, but wanted to raise it.The text was updated successfully, but these errors were encountered: