module f_mod use, intrinsic :: iso_c_binding, only : c_int, c_double, c_ptr, c_loc implicit none contains subroutine f_func(data) type, bind(C) :: c_matrix integer(c_int) :: m integer(c_int) :: n type(c_ptr) :: data end type c_matrix interface subroutine c_function(mat, d) BIND(C, name='c_function') import c_matrix, c_double type(c_matrix) :: mat real(c_double), value :: d end subroutine c_function end interface type(c_matrix) :: mat double precision, dimension(:, :), allocatable, intent(in) :: data real(c_double) :: d = 1.45 mat%m = size(data, 1) mat%n = size(data, 2) mat%data = c_loc(data(lbound(data,1), lbound(data, 2))) call c_function(mat, d) end subroutine f_func end module f_mod