mod_type.f90 565 Bytes
Newer Older
Mozul Rémy's avatar
Mozul Rémy committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34

module test_type

  use iso_c_binding

  implicit none

  type, bind(c) :: myftype
    integer(c_int) :: i, j
    real(c_double) :: s, s2
  end type myftype

  contains

  subroutine print_type(ft) bind(c, name='print_type')
    type(myftype) :: ft

    print *, ft%i
    print *, ft%j
    print *, ft%s

  end subroutine

  subroutine increment(ft) bind(c,name='increment')
    implicit none
    type(myftype) :: ft

    ft%i = ft%i+1
    ft%j = ft%j-1
    ft%s = dsqrt(real(ft%i,c_double)*ft%i+real(ft%j,c_double)*ft%j)
  end subroutine

end module test_type