   Module Mod1
      Use, Intrinsic ::  iso_c_binding
   End Module Mod1

   Module Mod2
      Use, Intrinsic ::  iso_c_binding
      Interface
         Subroutine cfunc_int(i) bind(c,name='printint')
            Use Mod1
            Integer(c_int), value :: i
         End Subroutine
      End Interface
      Interface
         Subroutine cfunc_intstar(i) bind(c,name='printintptr')
            Use Mod1
            Integer(c_int) :: i
         End Subroutine
      End Interface
      Interface
         Subroutine cfunc_intarray(i,n) bind(c,name='printintarray')
            Use Mod1
            Type(C_Ptr), value     :: i
            Integer(c_int), value  :: n
         End Subroutine
      End Interface
   End Module Mod2
   
   Module Mod3
   Contains
      Subroutine printconstcharlistF(s_array,n)
         Use Mod1
         Character(len=256,kind=C_CHAR), dimension(:), pointer :: s_array
         Integer(c_int)                                   :: n
         
         Integer                                   :: i
         Do i = 1, n
           Write(*,99) i,trim(s_array(i))
          End Do 
      99 Format('s(',I1,'): "',A,'"')
      End Subroutine printconstcharlistF
   End Module Mod3
program main
   Use Mod2 
   Use Mod3
   implicit none

   Integer(c_int) :: i, n
   Integer(c_int), pointer :: iptr
   Integer(c_int), Dimension(:), pointer   :: i_array
   Character(len=256,kind=C_char), dimension(:), pointer :: s_array
   
   i = 12
   Call cfunc_int(i)
   iptr=13
   Call cfunc_intstar(iptr)
   n = 3
   Allocate(i_array(n))
   Do i = 1, n
      i_array(i) = i
   End Do
   Call cfunc_intarray(c_loc(i_array),n)
   DeAllocate(i_array)
   Allocate(s_array(n))
   Do i = 1, n
      Write(s_array(i), 100) i
   End Do
100 format('*** s_array /',I1,'/ ***')
   Call printconstcharlistF(s_array,n)
End program main