Passing both scalars and arrays (of any dimensions) from Fortran to C
问题 I have the following Fortran subroutine named show_value that calls a C function named show_value : INTERFACE SUBROUTINE show_value(variable) BIND(C, name = "show_value") USE, INTRINSIC :: iso_c_binding TYPE(*) :: variable END SUBROUTINE END INTERFACE The C function show_value : void show_value(const void *variable) { printf("%d\n", *(int *) variable); } The Fortran subroutine works well when passing scalars to it. Example: INTEGER :: x x = 12 call show_value(x) This will call the C function