'Calling C subroutine from Fortran

I want to create a Fortran interface to call C subroutines using the following structure, where I have in the structure a double pointer.

struct compact{
    int number;
    double static_array[10];
    size_t length_dyn;
    double ** dynamic_matrix;
};

How could I create the interface?

If the pointer is single, the interface would look like this

module c_struct
use, intrinsic :: iso_c_binding
    type, bind(c) :: compact
        integer(kind=c_int)              :: number
        real(kind=c_double)              :: static_array(10)
        integer(kind=c_size_t)           :: length_dyn
        type(c_ptr)                      :: dynamic_array   
    end type compact
end module c_struct

How do I implement a double pointer?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source